diff options
Diffstat (limited to 'buildSrc/src/main')
11 files changed, 372 insertions, 0 deletions
diff --git a/buildSrc/src/main/groovy/refinery-frontend-conventions.gradle b/buildSrc/src/main/groovy/refinery-frontend-conventions.gradle new file mode 100644 index 00000000..da9370fe --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-frontend-conventions.gradle | |||
@@ -0,0 +1,14 @@ | |||
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 new file mode 100644 index 00000000..35410db4 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-frontend-workspace.gradle | |||
@@ -0,0 +1,28 @@ | |||
1 | plugins { | ||
2 | id 'refinery-frontend-conventions' | ||
3 | } | ||
4 | |||
5 | tasks.named('installNode') { | ||
6 | dependsOn rootProject.tasks.named('installNode') | ||
7 | enabled = false | ||
8 | } | ||
9 | |||
10 | tasks.named('installYarnGlobally') { | ||
11 | dependsOn rootProject.tasks.named('installYarnGlobally') | ||
12 | enabled = false | ||
13 | } | ||
14 | |||
15 | tasks.named('installYarn') { | ||
16 | dependsOn rootProject.tasks.named('installYarn') | ||
17 | enabled = false | ||
18 | } | ||
19 | |||
20 | def rootInstallFrontend = rootProject.tasks.named('installFrontend') | ||
21 | rootInstallFrontend.configure { | ||
22 | inputs.file "${projectDir}/package.json" | ||
23 | } | ||
24 | |||
25 | tasks.named('installFrontend') { | ||
26 | dependsOn rootInstallFrontend | ||
27 | enabled = false | ||
28 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-frontend-worktree.gradle b/buildSrc/src/main/groovy/refinery-frontend-worktree.gradle new file mode 100644 index 00000000..e1324746 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-frontend-worktree.gradle | |||
@@ -0,0 +1,96 @@ | |||
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 | def 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 (FileNotFoundException | IOException e) { | ||
24 | return null | ||
25 | } finally { | ||
26 | if (inputStream != null) { | ||
27 | inputStream.close() | ||
28 | } | ||
29 | } | ||
30 | return props.get(propertyName) | ||
31 | } | ||
32 | |||
33 | def String 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 e) { | ||
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 e) { | ||
52 | return true; | ||
53 | } finally { | ||
54 | if (outputStream != null) { | ||
55 | outputStream.close() | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | |||
60 | tasks.named('installNode') { | ||
61 | onlyIf { | ||
62 | getFrontendProperty('installedNodeVersion') != frontend.nodeVersion.get() | ||
63 | } | ||
64 | doLast { | ||
65 | putFrontedProperty('installedNodeVersion', frontend.nodeVersion.get()) | ||
66 | } | ||
67 | } | ||
68 | |||
69 | tasks.named('installYarnGlobally') { | ||
70 | onlyIf { | ||
71 | getFrontendProperty('installedYarn1Version') != project.ext['frontend.yarn1Version'] | ||
72 | } | ||
73 | doLast { | ||
74 | putFrontedProperty('installedYarn1Version', project.ext['frontend.yarn1Version']) | ||
75 | } | ||
76 | outputs.dir "${frontend.nodeInstallDirectory.get()}/lib/node_modules/yarn" | ||
77 | } | ||
78 | |||
79 | tasks.named('installYarn') { | ||
80 | outputs.file ".yarn/releases/yarn-${frontend.yarnVersion.get()}.cjs" | ||
81 | } | ||
82 | |||
83 | tasks.named('installFrontend') { | ||
84 | inputs.files('package.json', 'yarn.lock') | ||
85 | outputs.files('.pnp.cjs', '.pnp.loader.mjs') | ||
86 | } | ||
87 | |||
88 | tasks.register('clobberFrontend', Delete) { | ||
89 | delete frontend.nodeInstallDirectory.get() | ||
90 | delete '.yarn/cache' | ||
91 | delete '.yarn/install-state.gz' | ||
92 | delete '.yarn/sdks' | ||
93 | delete '.yarn/unplugged' | ||
94 | delete '.pnp.cjs' | ||
95 | delete '.pnp.loader.mjs' | ||
96 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-java-application.gradle b/buildSrc/src/main/groovy/refinery-java-application.gradle new file mode 100644 index 00000000..c38ccdb3 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-java-application.gradle | |||
@@ -0,0 +1,11 @@ | |||
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 new file mode 100644 index 00000000..b2efd7e9 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-java-conventions.gradle | |||
@@ -0,0 +1,79 @@ | |||
1 | plugins { | ||
2 | id 'eclipse' | ||
3 | id 'jacoco' | ||
4 | id 'java' | ||
5 | } | ||
6 | |||
7 | repositories { | ||
8 | mavenCentral() | ||
9 | maven { | ||
10 | url 'https://repo.eclipse.org/content/groups/releases/' | ||
11 | } | ||
12 | } | ||
13 | |||
14 | dependencies { | ||
15 | testImplementation libs.hamcrest | ||
16 | testImplementation libs.junit.api | ||
17 | testRuntimeOnly libs.junit.engine | ||
18 | testImplementation libs.junit.params | ||
19 | testImplementation libs.mockito.core | ||
20 | testImplementation libs.mockito.junit | ||
21 | } | ||
22 | |||
23 | sourceCompatibility = '17' | ||
24 | targetCompatibility = '17' | ||
25 | |||
26 | def jacocoTestReport = tasks.named('jacocoTestReport') | ||
27 | jacocoTestReport.configure { | ||
28 | dependsOn test | ||
29 | reports { | ||
30 | xml.required = true | ||
31 | } | ||
32 | } | ||
33 | |||
34 | tasks.named('test') { | ||
35 | useJUnitPlatform { | ||
36 | excludeTags 'slow' | ||
37 | } | ||
38 | finalizedBy jacocoTestReport | ||
39 | } | ||
40 | |||
41 | tasks.register('slowTest', Test) { | ||
42 | useJUnitPlatform() | ||
43 | finalizedBy jacocoTestReport | ||
44 | } | ||
45 | |||
46 | tasks.named('jar') { | ||
47 | manifest { | ||
48 | attributes( | ||
49 | 'Bundle-SymbolicName': "${project.group}.${project.name}", | ||
50 | 'Bundle-Version': project.version | ||
51 | ) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | def generateEclipseSourceFolders = tasks.register('generateEclipseSourceFolders') | ||
56 | |||
57 | tasks.register('prepareEclipse') { | ||
58 | dependsOn generateEclipseSourceFolders | ||
59 | dependsOn tasks.named('eclipseJdt') | ||
60 | } | ||
61 | |||
62 | tasks.named('eclipseClasspath') { | ||
63 | dependsOn generateEclipseSourceFolders | ||
64 | } | ||
65 | |||
66 | eclipse { | ||
67 | classpath.file.whenMerged { | ||
68 | for (entry in entries) { | ||
69 | if (entry.path.endsWith('-gen')) { | ||
70 | entry.entryAttributes['ignore_optional_problems'] = true | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | jdt.file.withProperties { properties -> | ||
76 | // Allow @SupperessWarnings to suppress SonarLint warnings | ||
77 | properties['org.eclipse.jdt.core.compiler.problem.unhandledWarningToken'] = 'ignore' | ||
78 | } | ||
79 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-java-library.gradle b/buildSrc/src/main/groovy/refinery-java-library.gradle new file mode 100644 index 00000000..daa80f17 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-java-library.gradle | |||
@@ -0,0 +1,4 @@ | |||
1 | plugins { | ||
2 | id 'java-library' | ||
3 | id 'refinery-java-conventions' | ||
4 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-jmh.gradle b/buildSrc/src/main/groovy/refinery-jmh.gradle new file mode 100644 index 00000000..48e0c133 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-jmh.gradle | |||
@@ -0,0 +1,58 @@ | |||
1 | plugins { | ||
2 | id 'refinery-java-conventions' | ||
3 | id 'refinery-sonarqube' | ||
4 | } | ||
5 | |||
6 | configurations { | ||
7 | jmh { | ||
8 | extendsFrom implementation | ||
9 | } | ||
10 | } | ||
11 | |||
12 | sourceSets { | ||
13 | jmh { | ||
14 | java.srcDirs = ['src/jmh/java'] | ||
15 | resources.srcDirs = ['src/jmh/resources'] | ||
16 | compileClasspath += sourceSets.main.runtimeClasspath | ||
17 | compileClasspath += sourceSets.test.runtimeClasspath | ||
18 | } | ||
19 | } | ||
20 | |||
21 | dependencies { | ||
22 | jmhImplementation libs.jmh.core | ||
23 | jmhAnnotationProcessor libs.jmh.annprocess | ||
24 | } | ||
25 | |||
26 | tasks.register('jmh', JavaExec) { | ||
27 | dependsOn tasks.named('jmhClasses') | ||
28 | main = 'org.openjdk.jmh.Main' | ||
29 | classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath | ||
30 | } | ||
31 | |||
32 | eclipse.classpath { | ||
33 | plusConfigurations += [configurations.jmhCompileClasspath, configurations.jmhRuntimeClasspath] | ||
34 | |||
35 | file.whenMerged { classpath -> | ||
36 | for (entry in classpath.entries) { | ||
37 | // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081 | ||
38 | if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) { | ||
39 | def usedBy = (entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',') | ||
40 | if (usedBy == ['jmh']) { | ||
41 | // Allow test helper classes to be used in benchmarks from Eclipse | ||
42 | // and do not expose JMH dependencies to the main source code. | ||
43 | entry.entryAttributes['test'] = true | ||
44 | } else if ((usedBy.contains('main') || usedBy.contains('test')) && !usedBy.contains('jmh')) { | ||
45 | // main and test sources are also used by jmh sources. | ||
46 | usedBy += 'jmh' | ||
47 | entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',') | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | sonarqube.properties { | ||
55 | properties['sonar.tests'] += [ | ||
56 | 'src/jmh/java', | ||
57 | ] | ||
58 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-mwe2.gradle b/buildSrc/src/main/groovy/refinery-mwe2.gradle new file mode 100644 index 00000000..c7f15e82 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-mwe2.gradle | |||
@@ -0,0 +1,16 @@ | |||
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 new file mode 100644 index 00000000..d84f4ada --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-sonarqube.gradle | |||
@@ -0,0 +1,8 @@ | |||
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-xtend.gradle b/buildSrc/src/main/groovy/refinery-xtend.gradle new file mode 100644 index 00000000..9186dbc5 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-xtend.gradle | |||
@@ -0,0 +1,37 @@ | |||
1 | plugins { | ||
2 | id 'org.xtext.xtend' | ||
3 | id 'refinery-java-conventions' | ||
4 | id 'refinery-sonarqube' | ||
5 | } | ||
6 | |||
7 | sourceSets { | ||
8 | main { | ||
9 | xtendOutputDir = 'src/main/xtend-gen' | ||
10 | } | ||
11 | test { | ||
12 | xtendOutputDir = 'src/test/xtend-gen' | ||
13 | } | ||
14 | } | ||
15 | |||
16 | xtend.generator { | ||
17 | // As of Xtext 2.26.0.M2, the Xbase compiler doesn't know how to handle Java 12 and up | ||
18 | // and the build fails with a NullPointerException if such Java version is specified. | ||
19 | javaSourceLevel = '11' | ||
20 | } | ||
21 | |||
22 | tasks.named('clean') { | ||
23 | delete 'src/main/xtend-gen' | ||
24 | delete 'src/test/xtend-gen' | ||
25 | } | ||
26 | |||
27 | sonarqube.properties { | ||
28 | properties['sonar.exclusions'] += [ | ||
29 | 'src/main/xtend-gen/**', | ||
30 | 'src/test/xtend-gen/**', | ||
31 | ] | ||
32 | } | ||
33 | |||
34 | tasks.named('generateEclipseSourceFolders') { | ||
35 | dependsOn tasks.named('generateXtext') | ||
36 | dependsOn tasks.named('generateTestXtext') | ||
37 | } | ||
diff --git a/buildSrc/src/main/groovy/refinery-xtext-conventions.gradle b/buildSrc/src/main/groovy/refinery-xtext-conventions.gradle new file mode 100644 index 00000000..0c7c82f0 --- /dev/null +++ b/buildSrc/src/main/groovy/refinery-xtext-conventions.gradle | |||
@@ -0,0 +1,21 @@ | |||
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 | } | ||