diff options
author | 2023-04-08 22:56:44 +0200 | |
---|---|---|
committer | 2023-04-08 22:58:21 +0200 | |
commit | 561fac70fd3dc3ebe1cfbc50146757495fb828d5 (patch) | |
tree | 20aa72bbe438aaa70c8de264ff0d366758e7772d /buildSrc/src/main/groovy | |
parent | refactor: remove TupleLike (diff) | |
download | refinery-561fac70fd3dc3ebe1cfbc50146757495fb828d5.tar.gz refinery-561fac70fd3dc3ebe1cfbc50146757495fb828d5.tar.zst refinery-561fac70fd3dc3ebe1cfbc50146757495fb828d5.zip |
build: convert Gradle scripts to Kotlin
Improves IDE support build scripts in IntelliJ.
There is no Eclipse IDE support, but Eclipse didn't have support for Groovy
either, so there is no degradation of functionality.
Diffstat (limited to 'buildSrc/src/main/groovy')
12 files changed, 0 insertions, 418 deletions
diff --git a/buildSrc/src/main/groovy/refinery-eclipse.gradle b/buildSrc/src/main/groovy/refinery-eclipse.gradle deleted file mode 100644 index 15dcb5ce..00000000 --- a/buildSrc/src/main/groovy/refinery-eclipse.gradle +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
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 = | ||
16 | new Properties(Collections.singletonMap('eclipse.preferences.version', '1')) | ||
17 | eclipseEncodingProperties.put('encoding/<project>', encoding.get()) | ||
18 | outputFile.withOutputStream { | ||
19 | eclipseEncodingProperties.store(it, 'generated by ' + name) | ||
20 | } | ||
21 | } | ||
22 | } | ||
23 | |||
24 | tasks.named('eclipse') { | ||
25 | dependsOn(eclipseResourceEncoding) | ||
26 | } | ||
27 | |||
28 | eclipse.synchronizationTasks(eclipseResourceEncoding) | ||
diff --git a/buildSrc/src/main/groovy/refinery-frontend-conventions.gradle b/buildSrc/src/main/groovy/refinery-frontend-conventions.gradle deleted file mode 100644 index da9370fe..00000000 --- a/buildSrc/src/main/groovy/refinery-frontend-conventions.gradle +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'org.siouan.frontend-jdk11' | ||
3 | } | ||
4 | |||
5 | frontend { | ||
6 | nodeVersion = project.ext['frontend.nodeVersion'] | ||
7 | nodeInstallDirectory = file("${rootDir}/.node") | ||
8 | yarnEnabled = true | ||
9 | yarnVersion = project.ext['frontend.yarnVersion'] | ||
10 | } | ||
11 | |||
12 | tasks.named('enableYarnBerry') { | ||
13 | enabled = false | ||
14 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-frontend-workspace.gradle b/buildSrc/src/main/groovy/refinery-frontend-workspace.gradle deleted file mode 100644 index 9c6d7b13..00000000 --- a/buildSrc/src/main/groovy/refinery-frontend-workspace.gradle +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'refinery-eclipse' | ||
3 | id 'refinery-frontend-conventions' | ||
4 | } | ||
5 | |||
6 | tasks.named('installNode') { | ||
7 | dependsOn rootProject.tasks.named('installNode') | ||
8 | enabled = false | ||
9 | } | ||
10 | |||
11 | tasks.named('installYarnGlobally') { | ||
12 | dependsOn rootProject.tasks.named('installYarnGlobally') | ||
13 | enabled = false | ||
14 | } | ||
15 | |||
16 | tasks.named('installYarn') { | ||
17 | dependsOn rootProject.tasks.named('installYarn') | ||
18 | enabled = false | ||
19 | } | ||
20 | |||
21 | def rootInstallFrontend = rootProject.tasks.named('installFrontend') | ||
22 | rootInstallFrontend.configure { | ||
23 | inputs.file "${projectDir}/package.json" | ||
24 | } | ||
25 | |||
26 | tasks.named('installFrontend') { | ||
27 | dependsOn rootInstallFrontend | ||
28 | enabled = false | ||
29 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-frontend-worktree.gradle b/buildSrc/src/main/groovy/refinery-frontend-worktree.gradle deleted file mode 100644 index 1d239fd5..00000000 --- a/buildSrc/src/main/groovy/refinery-frontend-worktree.gradle +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'refinery-frontend-conventions' | ||
3 | } | ||
4 | |||
5 | frontend { | ||
6 | yarnGlobalInstallScript = "install -g yarn@${project.ext['frontend.yarn1Version']}" | ||
7 | yarnInstallScript = "set version ${frontend.yarnVersion.get()} --only-if-needed" | ||
8 | if (project.hasProperty('ci')) { | ||
9 | installScript = 'install --immutable --inline-builds' | ||
10 | } else { | ||
11 | installScript = 'install' | ||
12 | } | ||
13 | } | ||
14 | |||
15 | ext.frontedPropertiesFile = "${frontend.nodeInstallDirectory.get()}/frontend.properties" | ||
16 | |||
17 | String getFrontendProperty(String propertyName) { | ||
18 | FileInputStream inputStream = null | ||
19 | Properties props = new Properties() | ||
20 | try { | ||
21 | inputStream = new FileInputStream(frontedPropertiesFile) | ||
22 | props.load(inputStream) | ||
23 | } catch (IOException ignored) { | ||
24 | return null | ||
25 | } finally { | ||
26 | if (inputStream != null) { | ||
27 | inputStream.close() | ||
28 | } | ||
29 | } | ||
30 | return props.get(propertyName) | ||
31 | } | ||
32 | |||
33 | void putFrontedProperty(String propertyName, String propertyValue) { | ||
34 | FileInputStream inputStream = null | ||
35 | Properties props = new Properties() | ||
36 | try { | ||
37 | inputStream = new FileInputStream(frontedPropertiesFile) | ||
38 | props.load(inputStream) | ||
39 | } catch (FileNotFoundException ignored) { | ||
40 | // Use an empty Properties object instead | ||
41 | } finally { | ||
42 | if (inputStream != null) { | ||
43 | inputStream.close() | ||
44 | } | ||
45 | } | ||
46 | props.put(propertyName, propertyValue) | ||
47 | FileOutputStream outputStream = null | ||
48 | try { | ||
49 | outputStream = new FileOutputStream(frontedPropertiesFile) | ||
50 | props.store(outputStream, null) | ||
51 | } catch (IOException ignored) { | ||
52 | } finally { | ||
53 | if (outputStream != null) { | ||
54 | outputStream.close() | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | tasks.named('installNode') { | ||
60 | onlyIf { | ||
61 | getFrontendProperty('installedNodeVersion') != frontend.nodeVersion.get() | ||
62 | } | ||
63 | doLast { | ||
64 | putFrontedProperty('installedNodeVersion', frontend.nodeVersion.get()) | ||
65 | } | ||
66 | } | ||
67 | |||
68 | tasks.named('installYarnGlobally') { | ||
69 | onlyIf { | ||
70 | getFrontendProperty('installedYarn1Version') != project.ext['frontend.yarn1Version'] | ||
71 | } | ||
72 | doLast { | ||
73 | putFrontedProperty('installedYarn1Version', project.ext['frontend.yarn1Version']) | ||
74 | } | ||
75 | outputs.dir "${frontend.nodeInstallDirectory.get()}/lib/node_modules/yarn" | ||
76 | } | ||
77 | |||
78 | tasks.named('installYarn') { | ||
79 | outputs.file ".yarn/releases/yarn-${frontend.yarnVersion.get()}.cjs" | ||
80 | } | ||
81 | |||
82 | tasks.named('installFrontend') { | ||
83 | inputs.files('package.json', 'yarn.lock') | ||
84 | outputs.files('.pnp.cjs', '.pnp.loader.mjs') | ||
85 | } | ||
86 | |||
87 | tasks.register('clobberFrontend', Delete) { | ||
88 | delete frontend.nodeInstallDirectory.get() | ||
89 | delete '.yarn/cache' | ||
90 | delete '.yarn/install-state.gz' | ||
91 | delete '.yarn/sdks' | ||
92 | delete '.yarn/unplugged' | ||
93 | delete '.pnp.cjs' | ||
94 | delete '.pnp.loader.mjs' | ||
95 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-java-application.gradle b/buildSrc/src/main/groovy/refinery-java-application.gradle deleted file mode 100644 index c38ccdb3..00000000 --- a/buildSrc/src/main/groovy/refinery-java-application.gradle +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'application' | ||
3 | id 'com.github.johnrengelman.shadow' | ||
4 | id 'refinery-java-conventions' | ||
5 | } | ||
6 | |||
7 | for (taskName in ['distTar', 'distZip', 'shadowDistTar', 'shadowDistZip']) { | ||
8 | tasks.named(taskName) { | ||
9 | enabled = false | ||
10 | } | ||
11 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-java-conventions.gradle b/buildSrc/src/main/groovy/refinery-java-conventions.gradle deleted file mode 100644 index fdf5818a..00000000 --- a/buildSrc/src/main/groovy/refinery-java-conventions.gradle +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'jacoco' | ||
3 | id 'java' | ||
4 | id 'refinery-eclipse' | ||
5 | } | ||
6 | |||
7 | repositories { | ||
8 | mavenCentral() | ||
9 | maven { | ||
10 | url 'https://repo.eclipse.org/content/groups/releases/' | ||
11 | } | ||
12 | } | ||
13 | |||
14 | dependencies { | ||
15 | compileOnly libs.jetbrainsAnnotations | ||
16 | testCompileOnly libs.jetbrainsAnnotations | ||
17 | testImplementation libs.hamcrest | ||
18 | testImplementation libs.junit.api | ||
19 | testRuntimeOnly libs.junit.engine | ||
20 | testImplementation libs.junit.params | ||
21 | testImplementation libs.mockito.core | ||
22 | testImplementation libs.mockito.junit | ||
23 | } | ||
24 | |||
25 | java.toolchain { | ||
26 | languageVersion = JavaLanguageVersion.of(19) | ||
27 | } | ||
28 | |||
29 | tasks.withType(JavaCompile) { | ||
30 | options.release.set(17) | ||
31 | } | ||
32 | |||
33 | def jacocoTestReport = tasks.named('jacocoTestReport') | ||
34 | jacocoTestReport.configure { | ||
35 | dependsOn test | ||
36 | reports { | ||
37 | xml.required = true | ||
38 | } | ||
39 | } | ||
40 | |||
41 | tasks.named('test') { | ||
42 | useJUnitPlatform { | ||
43 | excludeTags 'slow' | ||
44 | } | ||
45 | finalizedBy jacocoTestReport | ||
46 | } | ||
47 | |||
48 | tasks.register('slowTest', Test) { | ||
49 | useJUnitPlatform() | ||
50 | finalizedBy jacocoTestReport | ||
51 | } | ||
52 | |||
53 | tasks.named('jar') { | ||
54 | manifest { | ||
55 | attributes( | ||
56 | 'Bundle-SymbolicName': "${project.group}.${project.name}", | ||
57 | 'Bundle-Version': project.version | ||
58 | ) | ||
59 | } | ||
60 | } | ||
61 | |||
62 | def generateEclipseSourceFolders = tasks.register('generateEclipseSourceFolders') | ||
63 | |||
64 | tasks.register('prepareEclipse') { | ||
65 | dependsOn generateEclipseSourceFolders | ||
66 | dependsOn tasks.named('eclipseJdt') | ||
67 | } | ||
68 | |||
69 | tasks.named('eclipseClasspath') { | ||
70 | dependsOn generateEclipseSourceFolders | ||
71 | } | ||
72 | |||
73 | eclipse { | ||
74 | classpath.file.whenMerged { | ||
75 | for (entry in entries) { | ||
76 | if (entry.path.endsWith('-gen')) { | ||
77 | entry.entryAttributes['ignore_optional_problems'] = true | ||
78 | } | ||
79 | // If a project has a main dependency on a project and an test dependency on the testFixtures of a project, | ||
80 | // it will be erroneously added as a test-only dependency to Eclipse. | ||
81 | // As a workaround, we add all project dependencies as main dependencies | ||
82 | // (we do not deliberately use test-only project dependencies). | ||
83 | if (entry in org.gradle.plugins.ide.eclipse.model.ProjectDependency) { | ||
84 | entry.entryAttributes.remove('test') | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
89 | jdt.file.withProperties { properties -> | ||
90 | // Allow @SuppressWarnings to suppress SonarLint warnings | ||
91 | properties['org.eclipse.jdt.core.compiler.problem.unhandledWarningToken'] = 'ignore' | ||
92 | } | ||
93 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-java-library.gradle b/buildSrc/src/main/groovy/refinery-java-library.gradle deleted file mode 100644 index daa80f17..00000000 --- a/buildSrc/src/main/groovy/refinery-java-library.gradle +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'java-library' | ||
3 | id 'refinery-java-conventions' | ||
4 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle b/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle deleted file mode 100644 index 02568abd..00000000 --- a/buildSrc/src/main/groovy/refinery-java-test-fixtures.gradle +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry | ||
2 | |||
3 | plugins { | ||
4 | id 'java-test-fixtures' | ||
5 | id 'refinery-java-conventions' | ||
6 | } | ||
7 | |||
8 | eclipse.classpath { | ||
9 | containsTestFixtures = true | ||
10 | |||
11 | file.whenMerged { classpath -> | ||
12 | def hasTest = classpath.entries.any { entry -> | ||
13 | entry in AbstractClasspathEntry && | ||
14 | entry.entryAttributes['gradle_scope'] == 'test' | ||
15 | } | ||
16 | for (entry in classpath.entries) { | ||
17 | // Workaround https://github.com/gradle/gradle/issues/11845 based on | ||
18 | // https://discuss.gradle.org/t/gradle-used-by-scope-not-correctly-generated-when-the-java-test-fixtures-plugin-is-used/39935/2 | ||
19 | if (entry in AbstractClasspathEntry) { | ||
20 | def usedBy = new LinkedHashSet( | ||
21 | Arrays.asList((entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',')) | ||
22 | ) | ||
23 | if (usedBy.contains('main')) { | ||
24 | usedBy += 'testFixtures' | ||
25 | } | ||
26 | if (hasTest && usedBy.contains('testFixtures')) { | ||
27 | usedBy += 'test' | ||
28 | } | ||
29 | if (!usedBy.empty) { | ||
30 | entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',') | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-jmh.gradle b/buildSrc/src/main/groovy/refinery-jmh.gradle deleted file mode 100644 index 1ab9edc3..00000000 --- a/buildSrc/src/main/groovy/refinery-jmh.gradle +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | import org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry | ||
2 | |||
3 | plugins { | ||
4 | id 'refinery-java-conventions' | ||
5 | id 'refinery-sonarqube' | ||
6 | } | ||
7 | |||
8 | configurations { | ||
9 | jmh { | ||
10 | extendsFrom implementation | ||
11 | } | ||
12 | } | ||
13 | |||
14 | sourceSets { | ||
15 | jmh { | ||
16 | java.srcDirs = ['src/jmh/java'] | ||
17 | resources.srcDirs = ['src/jmh/resources'] | ||
18 | compileClasspath += sourceSets.main.runtimeClasspath | ||
19 | compileClasspath += sourceSets.test.runtimeClasspath | ||
20 | } | ||
21 | } | ||
22 | |||
23 | dependencies { | ||
24 | jmhImplementation libs.jmh.core | ||
25 | jmhAnnotationProcessor libs.jmh.annprocess | ||
26 | } | ||
27 | |||
28 | tasks.register('jmh', JavaExec) { | ||
29 | dependsOn tasks.named('jmhClasses') | ||
30 | mainClass = 'org.openjdk.jmh.Main' | ||
31 | classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath | ||
32 | } | ||
33 | |||
34 | eclipse.classpath.file.whenMerged { classpath -> | ||
35 | for (entry in classpath.entries) { | ||
36 | if (entry in AbstractClasspathEntry) { | ||
37 | // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081 | ||
38 | if (entry.entryAttributes['gradle_scope'] == 'jmh') { | ||
39 | // Allow test helper classes to be used in benchmarks from Eclipse | ||
40 | // and do not expose JMH dependencies to the main source code. | ||
41 | entry.entryAttributes['test'] = true | ||
42 | } else { | ||
43 | // Workaround based on | ||
44 | // https://discuss.gradle.org/t/gradle-used-by-scope-not-correctly-generated-when-the-java-test-fixtures-plugin-is-used/39935/2 | ||
45 | def usedBy = new LinkedHashSet( | ||
46 | Arrays.asList((entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',')) | ||
47 | ) | ||
48 | if (['main', 'test', 'testFixtures'].any { e -> usedBy.contains(e) }) { | ||
49 | // main and test sources are also used by jmh sources. | ||
50 | usedBy += 'jmh' | ||
51 | } | ||
52 | if (!usedBy.empty) { | ||
53 | entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',') | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | |||
60 | sonarqube.properties { | ||
61 | properties['sonar.tests'] += [ | ||
62 | 'src/jmh/java', | ||
63 | ] | ||
64 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-mwe2.gradle b/buildSrc/src/main/groovy/refinery-mwe2.gradle deleted file mode 100644 index c7f15e82..00000000 --- a/buildSrc/src/main/groovy/refinery-mwe2.gradle +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'eclipse' | ||
3 | id 'refinery-java-conventions' | ||
4 | } | ||
5 | |||
6 | configurations { | ||
7 | mwe2 { | ||
8 | extendsFrom implementation | ||
9 | } | ||
10 | } | ||
11 | |||
12 | dependencies { | ||
13 | mwe2 libs.mwe2.launch | ||
14 | } | ||
15 | |||
16 | eclipse.classpath.plusConfigurations += [configurations.mwe2] | ||
diff --git a/buildSrc/src/main/groovy/refinery-sonarqube.gradle b/buildSrc/src/main/groovy/refinery-sonarqube.gradle deleted file mode 100644 index d84f4ada..00000000 --- a/buildSrc/src/main/groovy/refinery-sonarqube.gradle +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'org.sonarqube' | ||
3 | } | ||
4 | |||
5 | sonarqube.properties { | ||
6 | // Make sure `exclusions` is a List in every subproject | ||
7 | property 'sonar.exclusions', [] | ||
8 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-xtext-conventions.gradle b/buildSrc/src/main/groovy/refinery-xtext-conventions.gradle deleted file mode 100644 index 0c7c82f0..00000000 --- a/buildSrc/src/main/groovy/refinery-xtext-conventions.gradle +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | plugins { | ||
2 | id 'refinery-java-conventions' | ||
3 | id 'refinery-sonarqube' | ||
4 | } | ||
5 | |||
6 | sourceSets { | ||
7 | main { | ||
8 | java.srcDirs += ['src/main/xtext-gen'] | ||
9 | resources.srcDirs += ['src/main/xtext-gen'] | ||
10 | } | ||
11 | } | ||
12 | |||
13 | tasks.named('clean') { | ||
14 | delete 'src/main/xtext-gen' | ||
15 | } | ||
16 | |||
17 | sonarqube.properties { | ||
18 | properties['sonar.exclusions'] += [ | ||
19 | 'src/main/xtext-gen/**', | ||
20 | ] | ||
21 | } | ||