Skip to content

Commit

Permalink
Migrate build to "maven-publish" plugin #284
Browse files Browse the repository at this point in the history
migrate to "maven-publish" plugin

* migrate project specific settings to use with new API
* get rid of deprecated "maven" plugin
* move referenced sources and javadoc tasks before publishing
* classifier are no longer generated so do not need to be removed
* TNG nexus stuff is no longer used, therefore removed
  • Loading branch information
codecholeric authored Feb 29, 2020
2 parents 472cc18 + 90572b6 commit e70742a
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 147 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 -PallTests -PscanBuild clean build install runMavenTest
- ./gradlew --no-daemon -PallTests -PscanBuild clean build publishToMavenLocal runMavenTest

jdk:
- openjdk11
Expand Down
11 changes: 9 additions & 2 deletions archunit-junit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ ext.configureJUnitArchive = { configureDependencies ->
delegate.with addCleanThirdPartyTask
compileJava.dependsOn project(':archunit-junit').finishArchive

install.repositories.mavenInstaller.pom.whenConfigured configureDependencies
uploadArchives.repositories.mavenDeployer.pom.whenConfigured configureDependencies
publishing{
publications{
mavenJava{
pom.withXml {
configureDependencies(asNode().dependencies.first()) // there is only one "dependencies" element
}
}
}
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions archunit-junit/junit4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ shadowJar {
}
}

def configureDependencies = { pom ->
pom.dependencies.removeAll {
it.scope != 'compile' || !(it.artifactId in ['archunit', 'archunit-junit5-api', 'archunit-junit5-engine-api', 'junit'])
def configureDependencies = { deps ->
deps.children().removeIf { dep ->
dep.scope.text() != 'compile' || !(dep.artifactId.text() in ['archunit', 'archunit-junit5-api', 'archunit-junit5-engine-api', 'junit'])
}
pom.dependencies.find { it.artifactId == 'archunit' }.classifier = null
}
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
8 changes: 5 additions & 3 deletions archunit-junit/junit5/aggregator/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apply plugin: 'java-library'

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

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile(project(":archunit-junit5-api"))
runtime(project(":archunit-junit5-engine"))
api(project(":archunit-junit5-api"))
implementation(project(":archunit-junit5-engine"))
}

shadowJar {
exclude '**'
exclude '**'
}
7 changes: 3 additions & 4 deletions archunit-junit/junit5/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ shadowJar {
}
}

def configureDependencies = { pom ->
pom.dependencies.removeAll {
it.scope != 'compile' || !(it.artifactId in ['archunit'])
def configureDependencies = { deps ->
deps.children().removeIf { dep ->
dep.scope.text() != 'compile' || !(dep.artifactId.text() in ['archunit'])
}
pom.dependencies.find { it.artifactId == 'archunit' }.classifier = null
}
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
8 changes: 5 additions & 3 deletions archunit-junit/junit5/engine-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ shadowJar {
}
}

def configureDependencies = { pom ->
// dependencies to archunit only cover annotations; we can skip those without breaking consumers to keep the dependency slim
pom.dependencies.removeAll { it.artifactId != 'junit-platform-engine' }
// dependencies to archunit only cover annotations; we can skip those without breaking consumers to keep the dependency slim
def configureDependencies = { deps ->
deps.children().removeIf{ dep ->
dep.artifactId.text() != 'junit-platform-engine'
}
}
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
7 changes: 3 additions & 4 deletions archunit-junit/junit5/engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ shadowJar {
}
}

def configureDependencies = { pom ->
pom.dependencies.removeAll {
it.scope != 'compile' || !(it.artifactId in ['archunit', 'archunit-junit5-api', 'archunit-junit5-engine-api'])
def configureDependencies = { deps ->
deps.children().removeIf { dep ->
dep.scope.text() != 'compile' || !(dep.artifactId.text() in ['archunit', 'archunit-junit5-api', 'archunit-junit5-engine-api'])
}
pom.dependencies.find { it.artifactId == 'archunit' }.classifier = null
}
this.with project(':archunit-junit').configureJUnitArchive(configureDependencies)
18 changes: 11 additions & 7 deletions archunit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies {
}
}

ext.repackagesAsm = true // Will cause the ASM License to be packaged -> license.gradle
shadowJar {
exclude 'META-INF/**'

Expand All @@ -30,13 +29,18 @@ shadowJar {
}

/* Besides SLF4J we'll shadow everything we need into the JAR to avoid conflicts with other libraries*/
def configureDependenciesAfterShadow = { pom ->
pom.dependencies.removeAll {
it.artifactId != 'slf4j-api' || it.scope != 'compile'
publishing{
publications{
mavenJava{
pom.withXml {
def deps = asNode().dependencies.first() // there is only one "dependencies" element
deps.children().removeIf { dep ->
dep.artifactId.text() != 'slf4j-api' || dep.scope.text() != 'compile'
}
}
}
}
}
install.repositories.mavenInstaller.pom.whenConfigured configureDependenciesAfterShadow
uploadArchives.repositories.mavenDeployer.pom.whenConfigured configureDependenciesAfterShadow

addTestJarTo this
configureSlowTestsFor this
Expand Down Expand Up @@ -91,4 +95,4 @@ idea {
sourceDirs -= jdk9TestDirs.collect { file(it) }
testSourceDirs += jdk9TestDirs.collect { file(it) }
}
}
}
4 changes: 1 addition & 3 deletions build-steps/archiving/archiving.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ buildscript {
}

subprojects {
ext.repackagesAsm = false

afterEvaluate {
tasks.withType(Jar) {
manifest {
Expand Down Expand Up @@ -47,4 +45,4 @@ productionProjects*.with {

task finishArchive(dependsOn: shadowJar) {}
build.dependsOn(finishArchive)
}
}
38 changes: 20 additions & 18 deletions build-steps/license/license.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,25 @@ task updateLicenses {
}

releaseProjects*.with {
def installer = install.repositories.mavenInstaller
def deployer = uploadArchives.repositories.mavenDeployer

[installer, deployer]*.pom*.whenConfigured {
project {
licenses {
license {
name app.license.name
url app.license.url
distribution 'repo'
}
if (repackagesAsm) {
def asmLicense = rootProject.file(asmLicenseFile).readLines() as Queue
license {
name asmLicense.poll().replaceAll(/^.*?: /, '')
url asmLicense.poll().replaceAll(/^.*?: /, '')
distribution 'repo'
ext.repackagesAsm = project.name == "archunit"
publishing {
publications {
mavenJava(MavenPublication) {
pom {
licenses {
license {
name = app.license.name
url = app.license.url
distribution = 'repo'
}
if (repackagesAsm) {
def asmLicense = rootProject.file(asmLicenseFile).readLines() as Queue
license {
name = asmLicense.poll().replaceAll(/^.*?: /, '')
url = asmLicense.poll().replaceAll(/^.*?: /, '')
distribution = 'repo'
}
}
}
}
}
Expand Down Expand Up @@ -138,4 +140,4 @@ releaseProjects*.with {
shadowJar.mustRunAfter updateLicenses
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def addMavenTest = { config ->

def executeRulesTask = tasks[executeRules]
releaseProjects*.with {
[install, uploadArchives].each { executeRulesTask.mustRunAfter it }
[publish, publishToMavenLocal].each { executeRulesTask.mustRunAfter it }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build-steps/release/expected/archunit-junit4.pom
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions build-steps/release/expected/archunit-junit5-api.pom
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
Expand Down Expand Up @@ -49,4 +49,4 @@
<scope>compile</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions build-steps/release/expected/archunit-junit5-engine.pom
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
Expand Down Expand Up @@ -62,4 +62,4 @@
<scope>compile</scope>
</dependency>
</dependencies>
</project>
</project>
5 changes: 3 additions & 2 deletions build-steps/release/expected/archunit-junit5.pom
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
Expand Down
5 changes: 3 additions & 2 deletions build-steps/release/expected/archunit.pom
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tngtech.archunit</groupId>
Expand Down Expand Up @@ -54,4 +54,5 @@
<scope>compile</scope>
</dependency>
</dependencies>
</project>
</project>

Loading

0 comments on commit e70742a

Please sign in to comment.