diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2021-07-31 17:28:31 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2021-07-31 17:28:31 +0200 |
commit | af0ac22364d2621f580eef10df4172240ab382f2 (patch) | |
tree | a007565c63bede54ace1fa7f862a3a38e2e90729 /gradle | |
parent | Add JMH benchmarks for model-data (diff) | |
download | refinery-af0ac22364d2621f580eef10df4172240ab382f2.tar.gz refinery-af0ac22364d2621f580eef10df4172240ab382f2.tar.zst refinery-af0ac22364d2621f580eef10df4172240ab382f2.zip |
Refactor Gradle configs
Diffstat (limited to 'gradle')
-rw-r--r-- | gradle/java-common.gradle | 25 | ||||
-rw-r--r-- | gradle/jmh.gradle | 28 | ||||
-rw-r--r-- | gradle/junit.gradle | 16 | ||||
-rw-r--r-- | gradle/xtend.gradle | 15 |
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 | ||
5 | apply plugin: 'java' | 5 | apply plugin: 'java' |
6 | apply plugin: 'org.xtext.xtend' | ||
7 | 6 | ||
8 | sourceCompatibility = '11' | 7 | sourceCompatibility = '11' |
9 | targetCompatibility = '11' | 8 | targetCompatibility = '11' |
10 | 9 | ||
11 | sourceSets { | ||
12 | main { | ||
13 | xtendOutputDir = 'src/main/xtend-gen' | ||
14 | } | ||
15 | test { | ||
16 | xtendOutputDir = 'src/test/xtend-gen' | ||
17 | } | ||
18 | } | ||
19 | |||
20 | configurations.all { | 10 | configurations.all { |
21 | exclude group: 'asm' | 11 | exclude group: 'asm' |
22 | } | 12 | } |
@@ -27,21 +17,6 @@ jar { | |||
27 | } | 17 | } |
28 | } | 18 | } |
29 | 19 | ||
30 | test { | ||
31 | useJUnitPlatform { | ||
32 | excludeTags 'slow' | ||
33 | } | ||
34 | } | ||
35 | |||
36 | task slowTest(type: Test) { | ||
37 | useJUnitPlatform() | ||
38 | } | ||
39 | |||
40 | clean.doLast { | ||
41 | delete 'src/main/xtend-gen' | ||
42 | delete 'src/test/xtend-gen' | ||
43 | } | ||
44 | |||
45 | apply plugin: 'eclipse' | 20 | apply plugin: 'eclipse' |
46 | 21 | ||
47 | eclipse { | 22 | eclipse { |
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 | ||
17 | dependencies { | 16 | dependencies { |
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 | ||
23 | clean.doLast { | ||
24 | delete 'src/jmh/xtend-gen' | ||
25 | } | ||
26 | |||
27 | task jmh(type: JavaExec, dependsOn: jmhClasses) { | 21 | task 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 | ||
32 | eclipse.classpath { | 26 | eclipse.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 @@ | |||
1 | dependencies { | ||
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 | |||
8 | test { | ||
9 | useJUnitPlatform { | ||
10 | excludeTags 'slow' | ||
11 | } | ||
12 | } | ||
13 | |||
14 | task 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 @@ | |||
1 | apply plugin: 'org.xtext.xtend' | ||
2 | |||
3 | sourceSets { | ||
4 | main { | ||
5 | xtendOutputDir = 'src/main/xtend-gen' | ||
6 | } | ||
7 | test { | ||
8 | xtendOutputDir = 'src/test/xtend-gen' | ||
9 | } | ||
10 | } | ||
11 | |||
12 | clean.doLast { | ||
13 | delete 'src/main/xtend-gen' | ||
14 | delete 'src/test/xtend-gen' | ||
15 | } | ||