diff options
author | 2022-07-28 15:30:10 +0200 | |
---|---|---|
committer | 2022-07-28 15:30:10 +0200 | |
commit | c1f0da324605c18caf137631e58878136a707df4 (patch) | |
tree | 37c91983a65d4e7d0816d5ac1b4b2be614fd1e74 /buildSrc/src/main/groovy/refinery-eclipse.gradle | |
parent | build: fix testFixtures classpath in eclipse (diff) | |
download | refinery-c1f0da324605c18caf137631e58878136a707df4.tar.gz refinery-c1f0da324605c18caf137631e58878136a707df4.tar.zst refinery-c1f0da324605c18caf137631e58878136a707df4.zip |
build: file encoding import into Eclipse
See https://github.com/gradle/gradle/issues/898
Diffstat (limited to 'buildSrc/src/main/groovy/refinery-eclipse.gradle')
-rw-r--r-- | buildSrc/src/main/groovy/refinery-eclipse.gradle | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/buildSrc/src/main/groovy/refinery-eclipse.gradle b/buildSrc/src/main/groovy/refinery-eclipse.gradle new file mode 100644 index 00000000..ddd15fc2 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-eclipse.gradle | |||
@@ -0,0 +1,28 @@ | |||
1 | plugins { | ||
2 | id 'eclipse' | ||
3 | } | ||
4 | |||
5 | // Workaround from https://github.com/gradle/gradle/issues/898#issuecomment-885765821 | ||
6 | def eclipseResourceEncoding = tasks.register('eclipseResourceEncoding') { | ||
7 | ext.outputFile = file('.settings/org.eclipse.core.resources.prefs') | ||
8 | def compileTask = tasks.findByName('compileJava') | ||
9 | ext.encoding = provider({ compileTask?.options?.encoding }).orElse(providers.systemProperty('file.encoding')) | ||
10 | |||
11 | inputs.property("file.encoding", encoding) | ||
12 | outputs.file(outputFile).withPropertyName('outputFile') | ||
13 | |||
14 | doLast { | ||
15 | Properties eclipseEncodingProperties = new Properties(Collections.singletonMap('eclipse.preferences.version','1')) | ||
16 | eclipseEncodingProperties.put('encoding/<project>', encoding.get()) | ||
17 | outputFile.withOutputStream { | ||
18 | eclipseEncodingProperties.store(it, 'generated by ' + name) | ||
19 | } | ||
20 | eclipseEncodingProperties.list(System.out) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | tasks.named('eclipse') { | ||
25 | dependsOn(eclipseResourceEncoding) | ||
26 | } | ||
27 | |||
28 | eclipse.synchronizationTasks(eclipseResourceEncoding) | ||