From 18105fa81d0346bb4edfc862d570395a74b65152 Mon Sep 17 00:00:00 2001 From: Stefan Kapferer Date: Tue, 29 Oct 2019 10:43:05 +0100 Subject: [PATCH] Enable publication --- .travis.yml | 11 +++- build.gradle | 133 ++++++++++++++++++++++++++++++++++++++++++++- gradle.properties | 4 ++ secret-key.gpg.enc | Bin 0 -> 3824 bytes 4 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 secret-key.gpg.enc diff --git a/.travis.yml b/.travis.yml index 3fc5297..b534f9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,16 @@ jdk: install: "/bin/true" -script: ./gradlew clean build +script: + - | + if [[ $TRAVIS_TAG =~ ^v.* ]]; then + ./gradlew clean build publish -Prelease.useLastTag=true -Psigning.keyId=${GPG_KEY_ID} -Psigning.password=${GPG_KEY_PASSPHRASE} + else + ./gradlew clean build snapshot $(if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo "publish -Psigning.keyId=${GPG_KEY_ID} -Psigning.password=${GPG_KEY_PASSPHRASE}"; fi) + fi + +before_install: +- openssl aes-256-cbc -K $encrypted_6e99b2392185_key -iv $encrypted_6e99b2392185_iv -in secret-key.gpg.enc -out secret-key.gpg -d after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/build.gradle b/build.gradle index 1b24cdf..d004167 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,12 @@ plugins { id 'java' id 'jacoco' + id 'maven-publish' + id 'signing' + id 'nebula.release' version '13.0.0' } group 'org.contextmapper' -version '1.0.0-SNAPSHOT' sourceCompatibility = 1.8 @@ -12,6 +14,10 @@ repositories { mavenCentral() } +if (!project.hasProperty('signing.secretKeyRingFile')) { + project.ext.'signing.secretKeyRingFile' = "${rootDir}/secret-key.gpg" +} + dependencies { implementation 'org.reflections:reflections:0.9.11' implementation 'org.springframework.boot:spring-boot-autoconfigure:2.2.0.RELEASE' @@ -25,6 +31,119 @@ dependencies { testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion } +task sourcesJar(type: Jar) { + from sourceSets.main.allJava + archiveClassifier = 'sources' +} + +task javadocJar(type: Jar) { + from javadoc + archiveClassifier = 'javadoc' +} + +artifacts { + archives javadocJar, sourcesJar +} + +signing { + sign configurations.archives + required { gradle.taskGraph.hasTask("publishMavenJavaPublicationToMavenLocal") || gradle.taskGraph.hasTask("publishMavenJavaPublicationToMavenRepository") } +} + +publishing { + publications { + mavenJava(MavenPublication) { + customizePom(pom) + + artifactId = "${project.name}" + groupId = "${project.group}" + version = "${project.version}" + from components.java + artifact sourcesJar + artifact javadocJar + + pom.withXml { + def pomFile = file("${project.buildDir}/generated-pom.xml") + writeTo(pomFile) + def pomAscFile = signing.sign(pomFile).signatureFiles[0] + artifact(pomAscFile) { + classifier = null + extension = 'pom.asc' + } + } + + signArchives.signatures.each { signature -> + artifact(signature) { + def matcher = signature.file =~ /-(sources|javadoc)\.jar\.asc$/ + if (matcher.find()) { + classifier = matcher.group(1) + } else { + classifier = null + } + extension = signature.type + } + } + } + } + repositories { + maven { + def releasesRepoUrl = "${ossReleaseStagingRepository}" + def snapshotsRepoUrl = "${ossSnapshotRepository}" + url = project.version.toString().endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + + credentials { + username = System.getenv('OSSRH_USERNAME') + password = System.getenv('OSSRH_PASSWORD') + } + } + } +} + +def customizePom(pom) { + pom.withXml { + def root = asNode() + + // eliminate test-scoped dependencies + root.dependencies.removeAll { dep -> + dep.scope == "test" + } + + root.children().last() + { + resolveStrategy = Closure.DELEGATE_FIRST + + description 'A reverse engineering library to generate Context Mapper DSL (CML) models from existing source code.' + name 'Context Mapper DSL (CML) Discovery Library' + url 'https://github.com/ContextMapper/context-map-discovery' + organization { + name 'Context Mapper' + url 'https://contextmapper.org/' + } + issueManagement { + system 'GitHub' + url 'https://github.com/ContextMapper/context-map-discovery/issues' + } + licenses { + license { + name 'Apache License 2.0' + url 'https://github.com/ContextMapper/service-cutter-library/blob/master/LICENSE' + distribution 'repo' + } + } + scm { + url 'https://github.com/ContextMapper/context-map-discovery' + connection 'scm:git:git://github.com/ContextMapper/context-map-discovery.git' + developerConnection 'scm:git:ssh://git@github.com:ContextMapper/context-map-discovery.git' + } + developers { + developer { + name 'Stefan Kapferer' + email 'stefan@contextmapper.org' + } + } + } + } +} + test { useJUnitPlatform() } @@ -37,3 +156,15 @@ jacocoTestReport { } check.dependsOn jacocoTestReport + +model { + tasks.generatePomFileForMavenJavaPublication { + destination = file("$buildDir/generated-pom.xml") + } + tasks.publishMavenJavaPublicationToMavenLocal { + dependsOn project.tasks.signArchives + } + tasks.publishMavenJavaPublicationToMavenRepository { + dependsOn project.tasks.signArchives + } +} diff --git a/gradle.properties b/gradle.properties index e67abdf..77bc4eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,6 @@ +# Publication repos +ossSnapshotRepository=https://oss.sonatype.org/content/repositories/snapshots/ +ossReleaseStagingRepository=https://oss.sonatype.org/service/local/staging/deploy/maven2/ + # dependency versions jUnitVersion=5.5.2 diff --git a/secret-key.gpg.enc b/secret-key.gpg.enc new file mode 100644 index 0000000000000000000000000000000000000000..8c564c6702ca544d842c27b0df4d91075c124f63 GIT binary patch literal 3824 zcmV*b+f&Y+diQ^^-%v&KRa7f2Vy6#0>AAAD|Pnr@21sv~~HAFnw=?F0A4h}y~z;-A2 z*SBy2cOGuJwkN!g)Fytbz$+m%pG9}#sDl-sq3)gl_p_blX5(vOFe>UMV93Q<*KHWG*w?@x-6yQMD(8dXd-+%VBwP zmy~w_xO~s|iA**W=!!T{=#Iz)k%^FY5U*5Uyv+C*4u@ZcuP)M%5Bg!F^*J1?D z`4=XjnafZ##^>5Z!l_5%a{sV7VtsYoYC})|_ptJKVucRrsO-VfVL3I7&9#jBm){xs z-3gzt7hn#KDa&3x6ybkrnEf4cuZi|+ecI{|U1OF=^8~yI{zszmZhfD#9oYnIoq#ZS zM+GbgfrU2#FW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