diff --git a/build-steps/build-steps.gradle b/build-steps/build-steps.gradle index b795743118..65b23703bc 100644 --- a/build-steps/build-steps.gradle +++ b/build-steps/build-steps.gradle @@ -2,9 +2,10 @@ def utilsPath = { "build-steps/${it}" } apply from: utilsPath('archiving/archiving.gradle') apply from: utilsPath('codequality/spotbugs.gradle') -apply from: utilsPath('publish/publish.gradle') +apply from: utilsPath('release/publish.gradle') apply from: utilsPath('license/license.gradle') apply from: utilsPath('maven-integration-test/maven-integration-test.gradle') apply from: utilsPath('build-scan/build-scan.gradle') apply from: utilsPath('ci/ci-config.gradle') +apply from: utilsPath('release/check-uploaded-artifacts.gradle') apply from: utilsPath('release/release.gradle') \ No newline at end of file diff --git a/build-steps/release/check-uploaded-artifacts.gradle b/build-steps/release/check-uploaded-artifacts.gradle new file mode 100644 index 0000000000..5dcca382a4 --- /dev/null +++ b/build-steps/release/check-uploaded-artifacts.gradle @@ -0,0 +1,111 @@ +import java.nio.file.Files +import java.time.LocalDateTime +import java.util.jar.JarFile +import java.util.jar.Manifest + +File scriptRoot = currentScriptRootOf this +def rootUrl = { + if (!project.hasProperty('tngRepoId')) { + throw new IllegalArgumentException( + 'You must pass the repo id (see Sonatype Repository Manager -> comtngtech-${repoId}) as parameter, e.g. -P tngRepoId=1162') + } + "https://oss.sonatype.org/service/local/repositories/comtngtech-${tngRepoId}/content/com/tngtech/archunit" +} + +def createArtifactUrl = { String artifactId -> + "${rootUrl()}/${artifactId}/${version}/${artifactId}-${version}" +} + +def getUploadedFile = { String artifactId, String ending, String suffix -> + def fullEnding = (!suffix.isEmpty() ? "-${suffix}" : '') + ".${ending}" + File result = Files.createTempFile(artifactId, fullEnding).toFile() + result.bytes = new URL("${createArtifactUrl(artifactId)}${fullEnding}").bytes + result +} + +def getUploadedFileText = { String artifactId, String ending -> + new URL("${createArtifactUrl(artifactId)}.${ending}").text.stripIndent() +} + +def getExpectedFile = { String artifactId, String ending -> + new File(scriptRoot, "expected/${artifactId}.${ending}").text.replace('${archunit.version}', version).stripIndent() +} + +def checkPom = { String artifactId -> + println "Verifying correct POM of ${artifactId}" + + String actual = getUploadedFileText(artifactId, 'pom') + String expected = getExpectedFile(artifactId, 'pom') + if (actual.replaceAll("\\s", "") != expected.replaceAll("\\s", "")) { + throw new AssertionError("""POM of artifact '${artifactId}' does not match: +-------- +Actual: +${actual} +-------- +Expected: +${expected} +-------- +""") + } +} + +def checkManifest = { String artifactId, Manifest manifest -> + println "Verifying correct Manifest of ${artifactId}" + + def checkAttributes = { expected -> + expected.each { key, value -> + assert manifest.mainAttributes.getValue(key) == value + } + } + checkAttributes([ + 'Specification-Title' : "ArchUnit - Module '${artifactId}'", + 'Specification-Version' : version, + 'Specification-Vendor' : 'TNG Technology Consulting GmbH', + 'Implementation-Title' : "com.tngtech.${artifactId.replace('-', '.')}", + 'Implementation-Version': version, + 'Implementation-Vendor' : 'TNG Technology Consulting GmbH', + 'Issue-Tracker' : 'https://github.com/TNG/ArchUnit/issues', + 'Documentation-URL' : 'https://github.com/TNG/ArchUnit', + 'Copyright' : "${LocalDateTime.now().year} TNG Technology Consulting GmbH", + 'License' : 'The Apache Software License, Version 2.0', + 'Automatic-Module-Name' : "com.tngtech.${artifactId.replaceFirst('-', '.').replaceFirst('-', '.').replace('-', '')}" + ]) +} + +def checkThirdParty = { JarFile jarFile -> + assert jarFile.getEntry('com/tngtech/archunit/thirdparty/org/objectweb/asm/ClassVisitor.class') != null: 'ASM is missing from 3rd party' + assert jarFile.getEntry('com/tngtech/archunit/thirdparty/org/objectweb/asm/asm.license') != null: 'ASM license is missing from 3rd party' + assert jarFile.getEntry('com/tngtech/archunit/thirdparty/com/google/common/collect/ImmutableSet.class') != null: 'Guava is missing from 3rd party' +} + +def checkNoThirdParty = { JarFile jarFile -> + assert jarFile.getEntry('com/tngtech/archunit/thirdparty') == null: 'There exists a third party folder' +} + +def checkSourcesExist = { String artifactId -> + assert getUploadedFile(artifactId, 'jar', 'sources') != null +} + +def checkJavadocExists = { String artifactId -> + assert getUploadedFile(artifactId, 'jar', 'javadoc') != null +} + +task checkUploadedArtifacts { + doLast { + releaseProjects.each { Project project -> + checkPom(project.name) + checkSourcesExist(project.name) + checkJavadocExists(project.name) + + JarFile jarFile = new JarFile(getUploadedFile(project.name, 'jar', '')) + checkManifest(project.name, jarFile.manifest) + if (project.repackagesAsm) { + println "Artifact ${project.name} is configured to repackage 3rd party libs -> checking existence of 3rd party package..." + checkThirdParty(jarFile) + } else { + println "Artifact ${project.name} is configured to not repackage 3rd party libs -> checking absense of 3rd party package..." + checkNoThirdParty(jarFile) + } + } + } +} \ No newline at end of file diff --git a/build-steps/release/expected/archunit-junit4.pom b/build-steps/release/expected/archunit-junit4.pom new file mode 100644 index 0000000000..ff7373dfac --- /dev/null +++ b/build-steps/release/expected/archunit-junit4.pom @@ -0,0 +1,48 @@ + + + 4.0.0 + com.tngtech.archunit + archunit-junit4 + ${archunit.version} + ArchUnit + A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit-junit4' + https://github.com/TNG/ArchUnit + + TNG Technology Consulting GmbH + https://www.tngtech.com/ + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + codecholeric + Peter Gafert + peter.gafert@tngtech.com + + + + scm:git@github.com:TNG/ArchUnit.git + scm:git@github.com:TNG/ArchUnit.git + https://github.com/TNG/ArchUnit + + + + com.tngtech.archunit + archunit + ${archunit.version} + compile + + + junit + junit + 4.12 + compile + + + \ No newline at end of file diff --git a/build-steps/release/expected/archunit-junit5-api.pom b/build-steps/release/expected/archunit-junit5-api.pom new file mode 100644 index 0000000000..273c6a8aec --- /dev/null +++ b/build-steps/release/expected/archunit-junit5-api.pom @@ -0,0 +1,42 @@ + + + 4.0.0 + com.tngtech.archunit + archunit-junit5-api + ${archunit.version} + ArchUnit + A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit-junit5-api' + https://github.com/TNG/ArchUnit + + TNG Technology Consulting GmbH + https://www.tngtech.com/ + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + codecholeric + Peter Gafert + peter.gafert@tngtech.com + + + + scm:git@github.com:TNG/ArchUnit.git + scm:git@github.com:TNG/ArchUnit.git + https://github.com/TNG/ArchUnit + + + + com.tngtech.archunit + archunit + ${archunit.version} + compile + + + \ No newline at end of file diff --git a/build-steps/release/expected/archunit-junit5-engine-api.pom b/build-steps/release/expected/archunit-junit5-engine-api.pom new file mode 100644 index 0000000000..6e425b7662 --- /dev/null +++ b/build-steps/release/expected/archunit-junit5-engine-api.pom @@ -0,0 +1,43 @@ + + + 4.0.0 + com.tngtech.archunit + archunit-junit5-engine-api + ${archunit.version} + ArchUnit + A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit-junit5-engine-api' + + https://github.com/TNG/ArchUnit + + TNG Technology Consulting GmbH + https://www.tngtech.com/ + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + codecholeric + Peter Gafert + peter.gafert@tngtech.com + + + + scm:git@github.com:TNG/ArchUnit.git + scm:git@github.com:TNG/ArchUnit.git + https://github.com/TNG/ArchUnit + + + + org.junit.platform + junit-platform-engine + 1.5.1 + compile + + + \ No newline at end of file diff --git a/build-steps/release/expected/archunit-junit5-engine.pom b/build-steps/release/expected/archunit-junit5-engine.pom new file mode 100644 index 0000000000..df4c41b2af --- /dev/null +++ b/build-steps/release/expected/archunit-junit5-engine.pom @@ -0,0 +1,55 @@ + + + 4.0.0 + com.tngtech.archunit + archunit-junit5-engine + ${archunit.version} + ArchUnit + A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit-junit5-engine' + + https://github.com/TNG/ArchUnit + + TNG Technology Consulting GmbH + https://www.tngtech.com/ + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + codecholeric + Peter Gafert + peter.gafert@tngtech.com + + + + scm:git@github.com:TNG/ArchUnit.git + scm:git@github.com:TNG/ArchUnit.git + https://github.com/TNG/ArchUnit + + + + com.tngtech.archunit + archunit + ${archunit.version} + compile + + + com.tngtech.archunit + archunit-junit5-api + ${archunit.version} + compile + + + com.tngtech.archunit + archunit-junit5-engine-api + ${archunit.version} + compile + + + \ No newline at end of file diff --git a/build-steps/release/expected/archunit.pom b/build-steps/release/expected/archunit.pom new file mode 100644 index 0000000000..8a7d177449 --- /dev/null +++ b/build-steps/release/expected/archunit.pom @@ -0,0 +1,47 @@ + + + 4.0.0 + com.tngtech.archunit + archunit + ${archunit.version} + ArchUnit + A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit' + https://github.com/TNG/ArchUnit + + TNG Technology Consulting GmbH + https://www.tngtech.com/ + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + BSD + http://asm.ow2.io/license.html + repo + + + + + codecholeric + Peter Gafert + peter.gafert@tngtech.com + + + + scm:git@github.com:TNG/ArchUnit.git + scm:git@github.com:TNG/ArchUnit.git + https://github.com/TNG/ArchUnit + + + + org.slf4j + slf4j-api + 1.7.25 + compile + + + \ No newline at end of file diff --git a/build-steps/publish/publish.gradle b/build-steps/release/publish.gradle similarity index 100% rename from build-steps/publish/publish.gradle rename to build-steps/release/publish.gradle