Skip to content

Commit

Permalink
Upgrade Gradle to 6.3 #345
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
codecholeric committed Apr 14, 2020
2 parents 374e8d3 + 0fa7444 commit a080697
Show file tree
Hide file tree
Showing 34 changed files with 325 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java

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

jdk:
- openjdk11
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ framework.
###### Gradle

```
testCompile 'com.tngtech.archunit:archunit:0.13.1'
testImplementation 'com.tngtech.archunit:archunit:0.13.1'
```

###### Maven
Expand Down
15 changes: 8 additions & 7 deletions archunit-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ ext.moduleName = 'com.tngtech.archunit.example'

proj.with {
dependencies {
compile dependency.jodaTime
compile dependency.javaxAnnotationApi
compile dependency.springBeans
compile dependency.guice
compile dependency.geronimoEjb
compile dependency.geronimoJpa
// `api` dependencies so we can access them within `archunit-integration-test`
api dependency.jodaTime
api dependency.javaxAnnotationApi
api dependency.springBeans
api dependency.guice
api dependency.geronimoEjb
api dependency.geronimoJpa

testCompile project(path: ':archunit')
testImplementation project(path: ':archunit')
}
}
}
10 changes: 5 additions & 5 deletions archunit-example/example-junit4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ext.moduleName = 'com.tngtech.archunit.example.junit4'

dependencies {
testCompile project(path: ':archunit-junit4')
testCompile project(path: ':archunit-example:example-plain')
testImplementation project(path: ':archunit-junit4')
testImplementation project(path: ':archunit-example:example-plain')

testRuntime dependency.log4j_api
testRuntime dependency.log4j_core
testRuntime dependency.log4j_slf4j
testRuntimeOnly dependency.log4j_api
testRuntimeOnly dependency.log4j_core
testRuntimeOnly dependency.log4j_slf4j
}

test {
Expand Down
10 changes: 5 additions & 5 deletions archunit-example/example-junit5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
testCompile project(path: ':archunit-junit5')
testCompile project(path: ':archunit-example:example-plain')
testImplementation project(path: ':archunit-junit5')
testImplementation project(path: ':archunit-example:example-plain')

testRuntime dependency.log4j_api
testRuntime dependency.log4j_core
testRuntime dependency.log4j_slf4j
testRuntimeOnly dependency.log4j_api
testRuntimeOnly dependency.log4j_core
testRuntimeOnly dependency.log4j_slf4j
}

test {
Expand Down
4 changes: 2 additions & 2 deletions archunit-example/example-plain/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ext.moduleName = 'com.tngtech.archunit.example.plain'

dependencies {
testCompile project(path: ':archunit')
testImplementation project(path: ':archunit')

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

test {
Expand Down
32 changes: 16 additions & 16 deletions archunit-integration-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
testCompile dependency.junit5JupiterEngine
testCompile dependency.junitPlatform
testCompile dependency.assertj
testCompile dependency.mockito
testCompile dependency.guava
testCompile dependency.log4j_api
testCompile dependency.log4j_core
testCompile dependency.log4j_slf4j
testCompile project(path: ':archunit', configuration: 'tests')
testCompile project(path: ':archunit-junit4')
testCompile project(path: ':archunit-junit5-api')
testCompile project(path: ':archunit-example:example-plain')
testCompile project(path: ':archunit-example:example-plain', configuration: 'tests')
testCompile project(path: ':archunit-example:example-junit4', configuration: 'tests')
testCompile project(path: ':archunit-example:example-junit5', configuration: 'tests')
testImplementation dependency.junit5JupiterEngine
testImplementation dependency.junitPlatform
testImplementation dependency.assertj
testImplementation dependency.mockito
testImplementation dependency.guava
testImplementation dependency.log4j_api
testImplementation dependency.log4j_core
testImplementation dependency.log4j_slf4j
testImplementation project(path: ':archunit', configuration: 'tests')
testImplementation project(path: ':archunit-junit4')
testImplementation project(path: ':archunit-junit5-api')
testImplementation project(path: ':archunit-example:example-plain')
testImplementation project(path: ':archunit-example:example-plain', configuration: 'tests')
testImplementation project(path: ':archunit-example:example-junit4', configuration: 'tests')
testImplementation project(path: ':archunit-example:example-junit5', configuration: 'tests')

testRuntime project(path: ':archunit-junit5-engine')
testRuntimeOnly project(path: ':archunit-junit5-engine')
}

test {
Expand Down
55 changes: 28 additions & 27 deletions archunit-junit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
ext.moduleName = 'com.tngtech.archunit.junit'

configurations {
api
compile.extendsFrom api
testCompile.extendsFrom api
archJunitApi
api.extendsFrom archJunitApi
}

sourceSets {
api {
archJunitApi {
java {
srcDirs = ['src/api/java']
}
compileClasspath = configurations.api
compileClasspath = configurations.archJunitApi
}
}

dependencies {
compileOnly sourceSets.api.output
testCompile sourceSets.api.output
compileOnly sourceSets.archJunitApi.output
testImplementation sourceSets.archJunitApi.output
}

task apiJar(type: Jar) {
archiveName = jar.archiveName.replace(project.name, "${project.name}-api")
from sourceSets.api.output
archiveFileName = jar.archiveFileName.get().replace(project.name, "${project.name}-api")
from sourceSets.archJunitApi.output
}
build.dependsOn apiJar

artifacts {
api apiJar
archJunitApi apiJar
}

dependencies {
api project(path: ':archunit', configuration: 'shadow')
compile project(path: ':archunit', configuration: 'shadow')
compile dependency.guava
compile dependency.slf4j

testCompile dependency.log4j_api
testCompile dependency.log4j_core
testCompile dependency.log4j_slf4j
testCompile dependency.mockito
testCompile dependency.assertj
testCompile(dependency.assertj_guava) {
archJunitApi project(path: ':archunit', configuration: 'shadow')
implementation dependency.guava
implementation dependency.slf4j

testImplementation dependency.log4j_api
testImplementation dependency.log4j_core
testImplementation dependency.log4j_slf4j
testImplementation dependency.junit4
testImplementation dependency.junit_dataprovider
testImplementation dependency.mockito
testImplementation dependency.assertj
testImplementation(dependency.assertj_guava) {
exclude module: 'assertj-core'
exclude module: 'guava'
}
testCompile project(path: ':archunit', configuration: 'tests')
testImplementation project(path: ':archunit', configuration: 'tests')
}

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

File tempPath = tempJar(jar.archivePath)
from zipTree(shadowJar.archivePath)
archiveName tempPath.name
File tempPath = tempJar(jar.archiveFile.get().getAsFile())
File jarPath = shadowJar.archiveFile.get().getAsFile()
from zipTree(jarPath)
archiveFileName = tempPath.name

doLast {
assert shadowJar.archivePath.delete()
assert tempPath.renameTo(shadowJar.archivePath)
assert jarPath.delete()
assert tempPath.renameTo(jarPath)
}
}
finishArchive.dependsOn removeDuplicateThirdParty
Expand Down
42 changes: 24 additions & 18 deletions archunit-junit/junit4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
ext.moduleName = 'com.tngtech.archunit.junit4'

dependencies {
compile project(path: ':archunit', configuration: 'shadow')
compile project(path: ':archunit-junit', configuration: 'api')
compile project(path: ':archunit-junit', configuration: 'shadow')
compile dependency.guava
compile dependency.junit4
compile dependency.slf4j

testCompile dependency.log4j_api
testCompile dependency.log4j_core
testCompile dependency.log4j_slf4j
testCompile dependency.mockito
testCompile dependency.assertj
testCompile(dependency.assertj_guava) {
api project(path: ':archunit', configuration: 'shadow')
api project(path: ':archunit-junit', configuration: 'archJunitApi')
api dependency.junit4
implementation project(path: ':archunit-junit', configuration: 'shadow')
implementation dependency.guava
implementation dependency.slf4j

testImplementation dependency.log4j_api
testImplementation dependency.log4j_core
testImplementation dependency.log4j_slf4j
testImplementation dependency.junit4
testImplementation dependency.junit_dataprovider
testImplementation dependency.mockito
testImplementation dependency.assertj
testImplementation(dependency.assertj_guava) {
exclude module: 'assertj-core'
exclude module: 'guava'
}
testCompile project(path: ':archunit', configuration: 'tests')
testCompile project(path: ':archunit-junit', configuration: 'tests')
testImplementation project(path: ':archunit', configuration: 'tests')
testImplementation project(path: ':archunit-junit', configuration: 'tests')

// This is a hack for running tests with IntelliJ instead of delegating to Gradle,
// because for some reason this dependency cannot be resolved otherwise only for archunit-junit4 :-(
testRuntimeOnly dependency.asm
}

javadoc {
source(['api', 'main'].collect { project(':archunit-junit').sourceSets[it].allJava })
source(['archJunitApi', 'main'].collect { project(':archunit-junit').sourceSets[it].allJava })
}
sourcesJar {
['api', 'main'].each {
['archJunitApi', 'main'].each {
from project(':archunit-junit').sourceSets[it].allSource
}
}
Expand All @@ -48,4 +54,4 @@ def configureDependencies = { deps ->
dep.scope.text() != 'compile' || !(dep.artifactId.text() in ['archunit', 'archunit-junit5-api', 'archunit-junit5-engine-api', 'junit'])
}
}
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
2 changes: 0 additions & 2 deletions archunit-junit/junit5/aggregator/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
apply plugin: 'java-library'

ext.moduleName = 'com.tngtech.archunit.junit5'

sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down
10 changes: 5 additions & 5 deletions archunit-junit/junit5/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile project(path: ':archunit')
compile project(path: ':archunit-junit', configuration: 'api')
compile dependency.junitPlatformCommons
api project(path: ':archunit')
api project(path: ':archunit-junit', configuration: 'archJunitApi')
api dependency.junitPlatformCommons
}

javadoc {
source(project(':archunit-junit').sourceSets.api.allJava)
source(project(':archunit-junit').sourceSets.archJunitApi.allJava)
}
sourcesJar {
from project(':archunit-junit').sourceSets.api.allSource
from project(':archunit-junit').sourceSets.archJunitApi.allSource
}

shadowJar {
Expand Down
24 changes: 12 additions & 12 deletions archunit-junit/junit5/engine-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile project(path: ':archunit')
compile dependency.guava
compile dependency.slf4j
compile dependency.junitPlatformEngine

testCompile project(path: ':archunit-junit5-api')
testCompile project(path: ':archunit', configuration: 'tests')
testCompile dependency.assertj
testCompile dependency.mockito
testCompile dependency.junit5JupiterApi

testRuntime dependency.junit5JupiterEngine
api dependency.junitPlatformEngine
implementation project(path: ':archunit')
implementation dependency.guava
implementation dependency.slf4j

testImplementation project(path: ':archunit-junit5-api')
testImplementation project(path: ':archunit', configuration: 'tests')
testImplementation dependency.assertj
testImplementation dependency.mockito
testImplementation dependency.junit5JupiterApi

testRuntimeOnly dependency.junit5JupiterEngine
}

compileJava.dependsOn project(':archunit-junit5-api').finishArchive
Expand Down
28 changes: 14 additions & 14 deletions archunit-junit/junit5/engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile project(path: ':archunit')
compile project(path: ':archunit-junit')
compile project(path: ':archunit-junit5-api')
compile project(path: ':archunit-junit5-engine-api')
compile dependency.guava
compile dependency.slf4j

testCompile project(path: ':archunit', configuration: 'tests')
testCompile dependency.assertj
testCompile dependency.mockito
testCompile dependency.junit5JupiterApi

testRuntime dependency.junit5JupiterEngine
api project(path: ':archunit')
api project(path: ':archunit-junit5-api')
api project(path: ':archunit-junit5-engine-api')
implementation project(path: ':archunit-junit')
implementation dependency.guava
implementation dependency.slf4j

testImplementation project(path: ':archunit', configuration: 'tests')
testImplementation dependency.assertj
testImplementation dependency.mockito
testImplementation dependency.junit5JupiterApi

testRuntimeOnly dependency.junit5JupiterEngine
}

compileJava.dependsOn project(':archunit-junit5-api').finishArchive
Expand All @@ -42,7 +42,7 @@ shadowJar {

dependencies {
exclude(dependency {
def isApi = it.configuration == 'api'
def isApi = it.configuration == 'archJunitApi'
def isUnwantedDependency = it.name != dependency.guava && it.moduleName != 'archunit-junit'
isUnwantedDependency || isApi
})
Expand Down

0 comments on commit a080697

Please sign in to comment.