aboutsummaryrefslogtreecommitdiffstats
path: root/gradle
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-07-31 17:28:31 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2021-07-31 17:28:31 +0200
commitaf0ac22364d2621f580eef10df4172240ab382f2 (patch)
treea007565c63bede54ace1fa7f862a3a38e2e90729 /gradle
parentAdd JMH benchmarks for model-data (diff)
downloadrefinery-af0ac22364d2621f580eef10df4172240ab382f2.tar.gz
refinery-af0ac22364d2621f580eef10df4172240ab382f2.tar.zst
refinery-af0ac22364d2621f580eef10df4172240ab382f2.zip
Refactor Gradle configs
Diffstat (limited to 'gradle')
-rw-r--r--gradle/java-common.gradle25
-rw-r--r--gradle/jmh.gradle28
-rw-r--r--gradle/junit.gradle16
-rw-r--r--gradle/xtend.gradle15
4 files changed, 48 insertions, 36 deletions
diff --git a/gradle/java-common.gradle b/gradle/java-common.gradle
index caae7d78..8f37e475 100644
--- a/gradle/java-common.gradle
+++ b/gradle/java-common.gradle
@@ -3,20 +3,10 @@ repositories {
3} 3}
4 4
5apply plugin: 'java' 5apply plugin: 'java'
6apply plugin: 'org.xtext.xtend'
7 6
8sourceCompatibility = '11' 7sourceCompatibility = '11'
9targetCompatibility = '11' 8targetCompatibility = '11'
10 9
11sourceSets {
12 main {
13 xtendOutputDir = 'src/main/xtend-gen'
14 }
15 test {
16 xtendOutputDir = 'src/test/xtend-gen'
17 }
18}
19
20configurations.all { 10configurations.all {
21 exclude group: 'asm' 11 exclude group: 'asm'
22} 12}
@@ -27,21 +17,6 @@ jar {
27 } 17 }
28} 18}
29 19
30test {
31 useJUnitPlatform {
32 excludeTags 'slow'
33 }
34}
35
36task slowTest(type: Test) {
37 useJUnitPlatform()
38}
39
40clean.doLast {
41 delete 'src/main/xtend-gen'
42 delete 'src/test/xtend-gen'
43}
44
45apply plugin: 'eclipse' 20apply plugin: 'eclipse'
46 21
47eclipse { 22eclipse {
diff --git a/gradle/jmh.gradle b/gradle/jmh.gradle
index ea88f3e3..9d4d8329 100644
--- a/gradle/jmh.gradle
+++ b/gradle/jmh.gradle
@@ -10,31 +10,37 @@ sourceSets {
10 resources.srcDirs = ['src/jmh/resources'] 10 resources.srcDirs = ['src/jmh/resources']
11 compileClasspath += sourceSets.main.runtimeClasspath 11 compileClasspath += sourceSets.main.runtimeClasspath
12 compileClasspath += sourceSets.test.runtimeClasspath 12 compileClasspath += sourceSets.test.runtimeClasspath
13 xtendOutputDir = 'src/jmh/xtend-gen'
14 } 13 }
15} 14}
16 15
17dependencies { 16dependencies {
18 jmhRuntime "org.openjdk.jmh:jmh-core:${jmhVersion}" 17 jmhCompile "org.openjdk.jmh:jmh-core:${jmhVersion}"
19 jmhCompile "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}"
20 jmhAnnotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}" 18 jmhAnnotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}"
21} 19}
22 20
23clean.doLast {
24 delete 'src/jmh/xtend-gen'
25}
26
27task jmh(type: JavaExec, dependsOn: jmhClasses) { 21task jmh(type: JavaExec, dependsOn: jmhClasses) {
28 main = 'org.openjdk.jmh.Main' 22 main = 'org.openjdk.jmh.Main'
29 classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath 23 classpath = sourceSets.jmh.compileClasspath + sourceSets.jmh.runtimeClasspath
30} 24}
31 25
32eclipse.classpath { 26eclipse.classpath {
33 plusConfigurations += [configurations.jmh] 27 plusConfigurations += [configurations.jmhCompile, configurations.jmhRuntime]
34 28
35 // Allow test helper classes to be used in benchmarks from Eclipse.
36 file.whenMerged { classpath -> 29 file.whenMerged { classpath ->
37 def jmhClasspathEntry = classpath.entries.find { entry -> entry.path == 'src/jmh/java' } 30 for (entry in classpath.entries) {
38 jmhClasspathEntry.entryAttributes['test'] = true 31 // Workaround from https://github.com/gradle/gradle/issues/4802#issuecomment-407902081
32 if (entry in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) {
33 def usedBy = (entry.entryAttributes['gradle_used_by_scope'] ?: '').split(',')
34 if (usedBy == ['jmh']) {
35 // Allow test helper classes to be used in benchmarks from Eclipse
36 // and do not expose JMH dependencies to the main source code.
37 entry.entryAttributes['test'] = true
38 } else if ((usedBy.contains('main') || usedBy.contains('test')) && !usedBy.contains('jmh')) {
39 // main and test sources are also used by jmh sources.
40 usedBy += 'jmh'
41 entry.entryAttributes['gradle_used_by_scope'] = usedBy.join(',')
42 }
43 }
44 }
39 } 45 }
40} 46}
diff --git a/gradle/junit.gradle b/gradle/junit.gradle
new file mode 100644
index 00000000..b36b30b4
--- /dev/null
+++ b/gradle/junit.gradle
@@ -0,0 +1,16 @@
1dependencies {
2 testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
3 testRuntime "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
4 testCompile "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
5 testCompile "org.hamcrest:hamcrest:${hamcrestVersion}"
6}
7
8test {
9 useJUnitPlatform {
10 excludeTags 'slow'
11 }
12}
13
14task slowTest(type: Test) {
15 useJUnitPlatform()
16}
diff --git a/gradle/xtend.gradle b/gradle/xtend.gradle
new file mode 100644
index 00000000..855dc624
--- /dev/null
+++ b/gradle/xtend.gradle
@@ -0,0 +1,15 @@
1apply plugin: 'org.xtext.xtend'
2
3sourceSets {
4 main {
5 xtendOutputDir = 'src/main/xtend-gen'
6 }
7 test {
8 xtendOutputDir = 'src/test/xtend-gen'
9 }
10}
11
12clean.doLast {
13 delete 'src/main/xtend-gen'
14 delete 'src/test/xtend-gen'
15}