2013-04-30 2 views
3

Я сделал проект wtp eclipse с градиентом. Когда я бегу «Gradle затмение», это делает затмение проект, но там не один файл».settings/org.eclipse.core.resources.prefs'Создание проекта eclipse wtp с градиентом

Этот файл имеет для проекта Infomation кодировкой

eclipse.preferences.version=1 
encoding/<project>=utf-8 

И вот моя настройка плагина eclipse.

eclipse { 
classpath { 
    downloadSources=true 
} 

jdt { 
    file { 
     withProperties { 
      properties -> properties.setProperty("encoding//src/main/java", "utf-8") 
         properties.setProperty("encoding//src/main/resources", "utf-8") 
         properties.setProperty("encoding//src/test/java", "utf-8") 
         properties.setProperty("encoding//src/test/resources", "utf-8") 
     }  
    } 
} 

wtp { 
    component { 
     contextPath = '/' 
    } 

    facet { 
     facets = facets 

     //facet name: 'jst.web', version: '2.5' 
     facet name: 'jst.java', version: '6.0' 
    } 
} 

project { 
     natures 'com.google.gwt.eclipse.core.gwtNature' 
     natures 'org.springframework.ide.eclipse.core.springnature' 
     buildCommand 'org.springframework.ide.eclipse.core.springbuilder' 
} 
    } 

Как это сделать?

Пожалуйста, помогите.

Спасибо.

ответ

5

Существует обходной путь упоминается (мной) на this JIRA issue

eclipseJdt << { 
    File f = file('.settings/org.eclipse.core.resources.prefs') 
    f.write('eclipse.preferences.version=1\n') 
    f.append('encoding/<project>=utf-8') 
} 
+0

Спасибо! Это очень полезно. –

1

Для меня решение JB Nizet не работал, как я хотел. Файл конфигурации появился, когда я явно вызвал задачу «eclipse», но я хотел, чтобы она автоматически генерировалась после импорта проекта. Вот что сделал трюк для меня:

apply plugin: 'java' 
apply plugin: 'eclipse' 

compileJava.options.encoding = 'utf-8' 

eclipse { 
    jdt { 
    sourceCompatibility = 1.8 
    targetCompatibility = 1.8 

    file { 
     File dir = file('.settings') 
     dir.mkdirs() 

     File f = file('.settings/org.eclipse.core.resources.prefs') 
     f.write('eclipse.preferences.version=1\n') 
     f.append('encoding/<project>=utf-8') 
    } 
    } 
} 


cleanEclipse << { 
    File f = file('.settings/org.eclipse.core.resources.prefs') 
    f.delete() 
} 

repositories { 
    jcenter() 
} 

dependencies { 
    testCompile 'junit:junit:4.12', 'org.hamcrest:hamcrest-all:1.3' 
} 
+0

Мне нравится это решение, но я бы добавил проверку существования org.eclipse.core.resources.prefs, иначе он будет перезаписан в каждом проекте Refresh Gradle Project, удалив любые пользовательские настройки: if (! F.exists()) {f.write ...} – xtian

Смежные вопросы