blob: ddd15fc2ceb840e08daeb4b77560156b5aba4076 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
plugins {
id 'eclipse'
}
// Workaround from https://github.com/gradle/gradle/issues/898#issuecomment-885765821
def eclipseResourceEncoding = tasks.register('eclipseResourceEncoding') {
ext.outputFile = file('.settings/org.eclipse.core.resources.prefs')
def compileTask = tasks.findByName('compileJava')
ext.encoding = provider({ compileTask?.options?.encoding }).orElse(providers.systemProperty('file.encoding'))
inputs.property("file.encoding", encoding)
outputs.file(outputFile).withPropertyName('outputFile')
doLast {
Properties eclipseEncodingProperties = new Properties(Collections.singletonMap('eclipse.preferences.version','1'))
eclipseEncodingProperties.put('encoding/<project>', encoding.get())
outputFile.withOutputStream {
eclipseEncodingProperties.store(it, 'generated by ' + name)
}
eclipseEncodingProperties.list(System.out)
}
}
tasks.named('eclipse') {
dependsOn(eclipseResourceEncoding)
}
eclipse.synchronizationTasks(eclipseResourceEncoding)
|