Skip to content

Commit a080697

Browse files
authored
Upgrade Gradle to 6.3 TNG#345
This upgrades Gradle to the current version. One notable change is the migration to use the Java-Library-Plugin instead of the Java-Plugin. Unfortunately the combination of IntelliJ 2020.1 and Gradle 6 does not work as well as it used to anymore. In particular IntelliJ cannot natively build this project anymore and without some explicit hack could also not run the tests with the IntelliJ test runner anymore. Thanks to this one hack (declaring a redundant dependency), it is now possible again to run tests with the IntelliJ test runner and only delegate the build to Gradle. Altogether this seemed to be a good enough compromise to us, since with the current Gradle version we can now compile Java 14.
2 parents 374e8d3 + 0fa7444 commit a080697

34 files changed

+325
-286
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: java
22

33
script:
4-
- ./gradlew --no-daemon --info -PallTests -PscanBuild clean build publishToMavenLocal runMavenTest
4+
- ./gradlew --no-daemon --scan --info -PallTests clean build publishToMavenLocal runMavenTest
55

66
jdk:
77
- openjdk11

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ framework.
1717
###### Gradle
1818

1919
```
20-
testCompile 'com.tngtech.archunit:archunit:0.13.1'
20+
testImplementation 'com.tngtech.archunit:archunit:0.13.1'
2121
```
2222

2323
###### Maven

archunit-example/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ ext.moduleName = 'com.tngtech.archunit.example'
1212

1313
proj.with {
1414
dependencies {
15-
compile dependency.jodaTime
16-
compile dependency.javaxAnnotationApi
17-
compile dependency.springBeans
18-
compile dependency.guice
19-
compile dependency.geronimoEjb
20-
compile dependency.geronimoJpa
15+
// `api` dependencies so we can access them within `archunit-integration-test`
16+
api dependency.jodaTime
17+
api dependency.javaxAnnotationApi
18+
api dependency.springBeans
19+
api dependency.guice
20+
api dependency.geronimoEjb
21+
api dependency.geronimoJpa
2122

22-
testCompile project(path: ':archunit')
23+
testImplementation project(path: ':archunit')
2324
}
2425
}
2526
}

archunit-example/example-junit4/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ext.moduleName = 'com.tngtech.archunit.example.junit4'
22

33
dependencies {
4-
testCompile project(path: ':archunit-junit4')
5-
testCompile project(path: ':archunit-example:example-plain')
4+
testImplementation project(path: ':archunit-junit4')
5+
testImplementation project(path: ':archunit-example:example-plain')
66

7-
testRuntime dependency.log4j_api
8-
testRuntime dependency.log4j_core
9-
testRuntime dependency.log4j_slf4j
7+
testRuntimeOnly dependency.log4j_api
8+
testRuntimeOnly dependency.log4j_core
9+
testRuntimeOnly dependency.log4j_slf4j
1010
}
1111

1212
test {

archunit-example/example-junit5/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ sourceCompatibility = JavaVersion.VERSION_1_8
44
targetCompatibility = JavaVersion.VERSION_1_8
55

66
dependencies {
7-
testCompile project(path: ':archunit-junit5')
8-
testCompile project(path: ':archunit-example:example-plain')
7+
testImplementation project(path: ':archunit-junit5')
8+
testImplementation project(path: ':archunit-example:example-plain')
99

10-
testRuntime dependency.log4j_api
11-
testRuntime dependency.log4j_core
12-
testRuntime dependency.log4j_slf4j
10+
testRuntimeOnly dependency.log4j_api
11+
testRuntimeOnly dependency.log4j_core
12+
testRuntimeOnly dependency.log4j_slf4j
1313
}
1414

1515
test {

archunit-example/example-plain/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
ext.moduleName = 'com.tngtech.archunit.example.plain'
22

33
dependencies {
4-
testCompile project(path: ':archunit')
4+
testImplementation project(path: ':archunit')
55

66
// we still use JUnit 4 as the test runner, but we don't use JUnit 4 support within this project
77
// so tests could well be run using TestNG, etc.
8-
testCompile dependency.junit4
8+
testImplementation dependency.junit4
99
}
1010

1111
test {

archunit-integration-test/build.gradle

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ sourceCompatibility = JavaVersion.VERSION_1_8
44
targetCompatibility = JavaVersion.VERSION_1_8
55

66
dependencies {
7-
testCompile dependency.junit5JupiterEngine
8-
testCompile dependency.junitPlatform
9-
testCompile dependency.assertj
10-
testCompile dependency.mockito
11-
testCompile dependency.guava
12-
testCompile dependency.log4j_api
13-
testCompile dependency.log4j_core
14-
testCompile dependency.log4j_slf4j
15-
testCompile project(path: ':archunit', configuration: 'tests')
16-
testCompile project(path: ':archunit-junit4')
17-
testCompile project(path: ':archunit-junit5-api')
18-
testCompile project(path: ':archunit-example:example-plain')
19-
testCompile project(path: ':archunit-example:example-plain', configuration: 'tests')
20-
testCompile project(path: ':archunit-example:example-junit4', configuration: 'tests')
21-
testCompile project(path: ':archunit-example:example-junit5', configuration: 'tests')
7+
testImplementation dependency.junit5JupiterEngine
8+
testImplementation dependency.junitPlatform
9+
testImplementation dependency.assertj
10+
testImplementation dependency.mockito
11+
testImplementation dependency.guava
12+
testImplementation dependency.log4j_api
13+
testImplementation dependency.log4j_core
14+
testImplementation dependency.log4j_slf4j
15+
testImplementation project(path: ':archunit', configuration: 'tests')
16+
testImplementation project(path: ':archunit-junit4')
17+
testImplementation project(path: ':archunit-junit5-api')
18+
testImplementation project(path: ':archunit-example:example-plain')
19+
testImplementation project(path: ':archunit-example:example-plain', configuration: 'tests')
20+
testImplementation project(path: ':archunit-example:example-junit4', configuration: 'tests')
21+
testImplementation project(path: ':archunit-example:example-junit5', configuration: 'tests')
2222

23-
testRuntime project(path: ':archunit-junit5-engine')
23+
testRuntimeOnly project(path: ':archunit-junit5-engine')
2424
}
2525

2626
test {

archunit-junit/build.gradle

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
ext.moduleName = 'com.tngtech.archunit.junit'
22

33
configurations {
4-
api
5-
compile.extendsFrom api
6-
testCompile.extendsFrom api
4+
archJunitApi
5+
api.extendsFrom archJunitApi
76
}
87

98
sourceSets {
10-
api {
9+
archJunitApi {
1110
java {
1211
srcDirs = ['src/api/java']
1312
}
14-
compileClasspath = configurations.api
13+
compileClasspath = configurations.archJunitApi
1514
}
1615
}
1716

1817
dependencies {
19-
compileOnly sourceSets.api.output
20-
testCompile sourceSets.api.output
18+
compileOnly sourceSets.archJunitApi.output
19+
testImplementation sourceSets.archJunitApi.output
2120
}
2221

2322
task apiJar(type: Jar) {
24-
archiveName = jar.archiveName.replace(project.name, "${project.name}-api")
25-
from sourceSets.api.output
23+
archiveFileName = jar.archiveFileName.get().replace(project.name, "${project.name}-api")
24+
from sourceSets.archJunitApi.output
2625
}
2726
build.dependsOn apiJar
2827

2928
artifacts {
30-
api apiJar
29+
archJunitApi apiJar
3130
}
3231

3332
dependencies {
34-
api project(path: ':archunit', configuration: 'shadow')
35-
compile project(path: ':archunit', configuration: 'shadow')
36-
compile dependency.guava
37-
compile dependency.slf4j
38-
39-
testCompile dependency.log4j_api
40-
testCompile dependency.log4j_core
41-
testCompile dependency.log4j_slf4j
42-
testCompile dependency.mockito
43-
testCompile dependency.assertj
44-
testCompile(dependency.assertj_guava) {
33+
archJunitApi project(path: ':archunit', configuration: 'shadow')
34+
implementation dependency.guava
35+
implementation dependency.slf4j
36+
37+
testImplementation dependency.log4j_api
38+
testImplementation dependency.log4j_core
39+
testImplementation dependency.log4j_slf4j
40+
testImplementation dependency.junit4
41+
testImplementation dependency.junit_dataprovider
42+
testImplementation dependency.mockito
43+
testImplementation dependency.assertj
44+
testImplementation(dependency.assertj_guava) {
4545
exclude module: 'assertj-core'
4646
exclude module: 'guava'
4747
}
48-
testCompile project(path: ':archunit', configuration: 'tests')
48+
testImplementation project(path: ':archunit', configuration: 'tests')
4949
}
5050

5151
addTestJarTo this
@@ -64,13 +64,14 @@ def addCleanThirdPartyTask = {
6464
tasks.create(name: 'removeDuplicateThirdParty', type: Jar, dependsOn: shadowJar) {
6565
exclude "${thirdPartyRelocationPackage.replace('.', '/')}/**"
6666

67-
File tempPath = tempJar(jar.archivePath)
68-
from zipTree(shadowJar.archivePath)
69-
archiveName tempPath.name
67+
File tempPath = tempJar(jar.archiveFile.get().getAsFile())
68+
File jarPath = shadowJar.archiveFile.get().getAsFile()
69+
from zipTree(jarPath)
70+
archiveFileName = tempPath.name
7071

7172
doLast {
72-
assert shadowJar.archivePath.delete()
73-
assert tempPath.renameTo(shadowJar.archivePath)
73+
assert jarPath.delete()
74+
assert tempPath.renameTo(jarPath)
7475
}
7576
}
7677
finishArchive.dependsOn removeDuplicateThirdParty

archunit-junit/junit4/build.gradle

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
ext.moduleName = 'com.tngtech.archunit.junit4'
22

33
dependencies {
4-
compile project(path: ':archunit', configuration: 'shadow')
5-
compile project(path: ':archunit-junit', configuration: 'api')
6-
compile project(path: ':archunit-junit', configuration: 'shadow')
7-
compile dependency.guava
8-
compile dependency.junit4
9-
compile dependency.slf4j
10-
11-
testCompile dependency.log4j_api
12-
testCompile dependency.log4j_core
13-
testCompile dependency.log4j_slf4j
14-
testCompile dependency.mockito
15-
testCompile dependency.assertj
16-
testCompile(dependency.assertj_guava) {
4+
api project(path: ':archunit', configuration: 'shadow')
5+
api project(path: ':archunit-junit', configuration: 'archJunitApi')
6+
api dependency.junit4
7+
implementation project(path: ':archunit-junit', configuration: 'shadow')
8+
implementation dependency.guava
9+
implementation dependency.slf4j
10+
11+
testImplementation dependency.log4j_api
12+
testImplementation dependency.log4j_core
13+
testImplementation dependency.log4j_slf4j
14+
testImplementation dependency.junit4
15+
testImplementation dependency.junit_dataprovider
16+
testImplementation dependency.mockito
17+
testImplementation dependency.assertj
18+
testImplementation(dependency.assertj_guava) {
1719
exclude module: 'assertj-core'
1820
exclude module: 'guava'
1921
}
20-
testCompile project(path: ':archunit', configuration: 'tests')
21-
testCompile project(path: ':archunit-junit', configuration: 'tests')
22+
testImplementation project(path: ':archunit', configuration: 'tests')
23+
testImplementation project(path: ':archunit-junit', configuration: 'tests')
24+
25+
// This is a hack for running tests with IntelliJ instead of delegating to Gradle,
26+
// because for some reason this dependency cannot be resolved otherwise only for archunit-junit4 :-(
27+
testRuntimeOnly dependency.asm
2228
}
2329

2430
javadoc {
25-
source(['api', 'main'].collect { project(':archunit-junit').sourceSets[it].allJava })
31+
source(['archJunitApi', 'main'].collect { project(':archunit-junit').sourceSets[it].allJava })
2632
}
2733
sourcesJar {
28-
['api', 'main'].each {
34+
['archJunitApi', 'main'].each {
2935
from project(':archunit-junit').sourceSets[it].allSource
3036
}
3137
}
@@ -48,4 +54,4 @@ def configureDependencies = { deps ->
4854
dep.scope.text() != 'compile' || !(dep.artifactId.text() in ['archunit', 'archunit-junit5-api', 'archunit-junit5-engine-api', 'junit'])
4955
}
5056
}
51-
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
57+
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)

archunit-junit/junit5/aggregator/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
apply plugin: 'java-library'
2-
31
ext.moduleName = 'com.tngtech.archunit.junit5'
42

53
sourceCompatibility = JavaVersion.VERSION_1_8

0 commit comments

Comments
 (0)