diff options
Diffstat (limited to 'buildSrc')
8 files changed, 231 insertions, 0 deletions
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..74fe04fb --- /dev/null +++ b/buildSrc/build.gradle | |||
@@ -0,0 +1,12 @@ | |||
1 | plugins { | ||
2 | id 'groovy-gradle-plugin' | ||
3 | } | ||
4 | |||
5 | repositories { | ||
6 | gradlePluginPortal() | ||
7 | } | ||
8 | |||
9 | dependencies { | ||
10 | implementation libs.sonarqubeGradle | ||
11 | implementation libs.xtendGradle | ||
12 | } | ||
diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle new file mode 100644 index 00000000..794aa2a1 --- /dev/null +++ b/buildSrc/settings.gradle | |||
@@ -0,0 +1,9 @@ | |||
1 | enableFeaturePreview 'VERSION_CATALOGS' | ||
2 | |||
3 | dependencyResolutionManagement { | ||
4 | versionCatalogs { | ||
5 | libs { | ||
6 | from files('../gradle/libs.versions.toml') | ||
7 | } | ||
8 | } | ||
9 | } | ||
diff --git a/buildSrc/src/main/groovy/tools.refinery.java-conventions.gradle b/buildSrc/src/main/groovy/tools.refinery.java-conventions.gradle new file mode 100644 index 00000000..6bea6e46 --- /dev/null +++ b/buildSrc/src/main/groovy/tools.refinery.java-conventions.gradle | |||
@@ -0,0 +1,45 @@ | |||
1 | plugins { | ||
2 | id 'eclipse' | ||
3 | } | ||
4 | |||
5 | repositories { | ||
6 | mavenCentral() | ||
7 | maven { | ||
8 | url 'https://repo.eclipse.org/content/groups/releases/' | ||
9 | } | ||
10 | } | ||
11 | |||
12 | sourceCompatibility = '17' | ||
13 | targetCompatibility = '17' | ||
14 | |||
15 | tasks.named('jar') { | ||
16 | manifest { | ||
17 | attributes 'Bundle-SymbolicName': project.name | ||
18 | } | ||
19 | } | ||
20 | |||
21 | def generateEclipseSourceFolders = tasks.register('generateEclipseSourceFolders') | ||
22 | |||
23 | tasks.register('prepareEclipse') { | ||
24 | dependsOn generateEclipseSourceFolders | ||
25 | dependsOn tasks.named('eclipseJdt') | ||
26 | } | ||
27 | |||
28 | tasks.named('eclipseClasspath') { | ||
29 | dependsOn generateEclipseSourceFolders | ||
30 | } | ||
31 | |||
32 | eclipse { | ||
33 | classpath.file.whenMerged { | ||
34 | for (entry in entries) { | ||
35 | if (entry.path.endsWith('-gen')) { | ||
36 | entry.entryAttributes['ignore_optional_problems'] = true | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | jdt.file.withProperties { properties -> | ||
42 | // Allow @SupperessWarnings to suppress SonarLint warnings | ||
43 | properties['org.eclipse.jdt.core.compiler.problem.unhandledWarningToken'] = 'ignore' | ||
44 | } | ||
45 | } | ||
diff --git a/buildSrc/src/main/groovy/tools.refinery.jmh-conventions.gradle b/buildSrc/src/main/groovy/tools.refinery.jmh-conventions.gradle new file mode 100644 index 00000000..0a82ae4b --- /dev/null +++ b/buildSrc/src/main/groovy/tools.refinery.jmh-conventions.gradle | |||
@@ -0,0 +1,58 @@ | |||
1 | plugins { | ||
2 | id 'org.sonarqube' | ||
3 | id 'tools.refinery.java-conventions' | ||
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/tools.refinery.junit-conventions.gradle b/buildSrc/src/main/groovy/tools.refinery.junit-conventions.gradle new file mode 100644 index 00000000..d62207b7 --- /dev/null +++ b/buildSrc/src/main/groovy/tools.refinery.junit-conventions.gradle | |||
@@ -0,0 +1,33 @@ | |||
1 | plugins { | ||
2 | id 'jacoco' | ||
3 | id 'tools.refinery.java-conventions' | ||
4 | } | ||
5 | |||
6 | dependencies { | ||
7 | testImplementation libs.hamcrest | ||
8 | testImplementation libs.junit.api | ||
9 | testRuntimeOnly libs.junit.engine | ||
10 | testImplementation libs.junit.params | ||
11 | testImplementation libs.mockito.core | ||
12 | testImplementation libs.mockito.junit | ||
13 | } | ||
14 | |||
15 | def jacocoTestReport = tasks.named('jacocoTestReport') | ||
16 | jacocoTestReport.configure { | ||
17 | dependsOn test | ||
18 | reports { | ||
19 | xml.required = true | ||
20 | } | ||
21 | } | ||
22 | |||
23 | tasks.named('test') { | ||
24 | useJUnitPlatform { | ||
25 | excludeTags 'slow' | ||
26 | } | ||
27 | finalizedBy jacocoTestReport | ||
28 | } | ||
29 | |||
30 | tasks.register('slowTest', Test) { | ||
31 | useJUnitPlatform() | ||
32 | finalizedBy jacocoTestReport | ||
33 | } | ||
diff --git a/buildSrc/src/main/groovy/tools.refinery.mwe2-conventions.gradle b/buildSrc/src/main/groovy/tools.refinery.mwe2-conventions.gradle new file mode 100644 index 00000000..fe213d42 --- /dev/null +++ b/buildSrc/src/main/groovy/tools.refinery.mwe2-conventions.gradle | |||
@@ -0,0 +1,16 @@ | |||
1 | plugins { | ||
2 | id 'eclipse' | ||
3 | id 'tools.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/tools.refinery.xtend-conventions.gradle b/buildSrc/src/main/groovy/tools.refinery.xtend-conventions.gradle new file mode 100644 index 00000000..98fc131c --- /dev/null +++ b/buildSrc/src/main/groovy/tools.refinery.xtend-conventions.gradle | |||
@@ -0,0 +1,37 @@ | |||
1 | plugins { | ||
2 | id 'org.sonarqube' | ||
3 | id 'org.xtext.xtend' | ||
4 | id 'tools.refinery.java-conventions' | ||
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/tools.refinery.xtext-conventions.gradle b/buildSrc/src/main/groovy/tools.refinery.xtext-conventions.gradle new file mode 100644 index 00000000..3fd2f9d6 --- /dev/null +++ b/buildSrc/src/main/groovy/tools.refinery.xtext-conventions.gradle | |||
@@ -0,0 +1,21 @@ | |||
1 | plugins { | ||
2 | id 'org.sonarqube' | ||
3 | id 'tools.refinery.java-conventions' | ||
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 | } | ||