From d9a591ca2cbae15dff27a40b4075c48a251c60f3 Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Sun, 25 Apr 2021 04:35:30 +0500 Subject: [PATCH] Update config to only publish to Maven central (#525) * work towards removal of jcenter * Make autobahn publish-able * minor adjustments * reuse config --- Makefile | 13 +-- autobahn/build.gradle | 184 ++++++++++++++++++++---------------------- build.gradle | 5 +- 3 files changed, 93 insertions(+), 109 deletions(-) diff --git a/Makefile b/Makefile index f178e09b..002cbfe6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BUILD_DATE=$(shell date -u +"%Y-%m-%d") -AUTOBAHN_JAVA_VERSION='20.7.1' +AUTOBAHN_JAVA_VERSION='21.4.1' # git log --pretty=format:'%h' -n 1 AUTOBAHN_JAVA_VCS_REF='c48c8d1' @@ -74,16 +74,9 @@ build_android: publish_android: build_android sed -i 's/DEBUG = true/DEBUG = false/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java - AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew bintrayUpload -PbuildPlatform=android + AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew :autobahn:publishReleasePublicationToCentralRepository -PbuildPlatform=android sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java -publish_android_legacy: build_android - sed -i 's/DEBUG = true/DEBUG = false/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java - $(shell ./enable_old_androids.sh) - AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew bintrayUpload -PbuildPlatform=android -PbuildLegacy=true - sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java - - build_netty: docker run -it --rm \ -e AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} \ @@ -93,5 +86,5 @@ build_netty: publish_netty: sed -i 's/DEBUG = true/DEBUG = false/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java - AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew bintrayUpload -PbuildPlatform=netty + AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew :autobahn:publishReleasePublicationToCentralRepository -PbuildPlatform=netty sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java diff --git a/autobahn/build.gradle b/autobahn/build.gradle index 46e75e7f..a5810d0a 100644 --- a/autobahn/build.gradle +++ b/autobahn/build.gradle @@ -2,20 +2,22 @@ def IS_ANDROID = project.hasProperty('IS_ANDROID') ? project.IS_ANDROID: true def IS_NEXT = project.hasProperty('IS_NEXT') ? project.IS_NEXT: false def IS_NETTY = project.hasProperty('IS_NETTY') ? project.IS_NETTY: false def ARTIFACT_ANDROID = (project.hasProperty('BUILD_LEGACY') && project.BUILD_LEGACY) ? 'autobahn-android-legacy': 'autobahn-android' -def PUBLISH = project.hasProperty('PUBLISH') && project.PUBLISH apply plugin: IS_ANDROID ? 'com.android.library': 'java-library' +apply plugin: 'maven-publish' +apply plugin: 'signing' def ARTIFACT_JAVA = 'autobahn-java' def ARTIFACT_NEXT = 'autobahn' def groupID = 'io.crossbar.autobahn' -def gitUrl = 'https://github.com/crossbario/autobahn-java.git' def licenseName = 'MIT' def licenseUrl = 'https://opensource.org/licenses/MIT' def relVersion = System.getenv().containsKey('AUTOBAHN_BUILD_VERSION') ? System.getenv( - 'AUTOBAHN_BUILD_VERSION'): '18.3.1' + 'AUTOBAHN_BUILD_VERSION'): '21.4.1' def siteUrl = 'https://github.com/crossbario/autobahn-java' +def SONATYPE_USER = System.getenv().containsKey('SONATYPE_USER') ? System.getenv('SONATYPE_USER'): '' +def SONATYPE_PASS = System.getenv().containsKey('SONATYPE_PASS') ? System.getenv('SONATYPE_PASS'): '' dependencies { api 'com.fasterxml.jackson.core:jackson-core:2.12.3' @@ -40,6 +42,27 @@ dependencies { } } +// Create the pom configuration: +def pomConfig = { + // Set your license + licenses { + license { + name licenseName + url licenseUrl + } + } + developers { + developer { + id "crossbario" + name "Crossbar.io" + email "support@crossbario.com" + } + } + scm { + url siteUrl + } +} + if (IS_ANDROID) { android { compileSdkVersion 30 @@ -78,9 +101,8 @@ if (IS_ANDROID) { } } - task sourcesJar(type: Jar) { - classifier = 'sources' + archiveClassifier.set("sources") from android.sourceSets.main.java.srcDirs } @@ -90,112 +112,44 @@ if (IS_ANDROID) { classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile } + + task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier.set("javadoc") + from javadoc.destinationDir + } + + project.archivesBaseName = ARTIFACT_ANDROID + group = groupID + version = relVersion + afterEvaluate { javadoc.classpath += files(android.libraryVariants.collect { variant -> variant.javaCompile.classpath.files }) } - project.archivesBaseName = ARTIFACT_ANDROID - group = groupID - version = relVersion - if (PUBLISH) { - apply plugin: 'com.github.dcendents.android-maven' - - install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' - groupId groupID - artifactId ARTIFACT_ANDROID - - // Add your description here - name ARTIFACT_ANDROID - description 'WebSocket & WAMP for Android' - url siteUrl - - // Set your license - licenses { - license { - name licenseName - url licenseUrl - } - } - developers { - developer { - id "crossbario" - name "Crossbar.io" - email "support@crossbario.com" - } - } - scm { - url siteUrl - } - } + publishing { + repositories { + maven { + name 'central' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username SONATYPE_USER + password SONATYPE_PASS } } } } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } } else { - // Create the pom configuration: - def pomConfig = { - // Set your license - licenses { - license { - name licenseName - url licenseUrl - } - } - developers { - developer { - id "crossbario" - name "Crossbar.io" - email "support@crossbario.com" - } - } - scm { - url siteUrl - } - } task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' + archiveClassifier.set("sources") from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' + archiveClassifier.set("javadoc") from javadoc.destinationDir } - if (PUBLISH) { - apply plugin: 'maven-publish' - - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - - groupId groupID - artifactId IS_NEXT ? ARTIFACT_NEXT: ARTIFACT_JAVA - version relVersion - pom.withXml { - def root = asNode() - root.appendNode('description', 'WebSocket & WAMP for Java8+') - root.appendNode('name', 'Autobahn Java') - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - } - } - } - } - } if (IS_NEXT) { sourceSets { main { @@ -226,7 +180,45 @@ if (IS_ANDROID) { targetCompatibility = JavaVersion.VERSION_1_8 } -artifacts { - archives sourcesJar - archives javadocJar +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + if (IS_ANDROID) { + from components.release + artifactId ARTIFACT_ANDROID + } else { + from components.java + artifactId IS_NEXT ? ARTIFACT_NEXT: ARTIFACT_JAVA + } + + artifact sourcesJar + artifact javadocJar + + groupId groupID + version relVersion + pom.withXml { + def root = asNode() + root.appendNode('description', 'WebSocket & WAMP for Java8+') + root.appendNode('name', 'Autobahn Java') + root.appendNode('url', siteUrl) + root.children().last() + pomConfig + } + } + } + repositories { + maven { + name 'central' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username SONATYPE_USER + password SONATYPE_PASS + } + } + } + signing { + required true + sign publishing.publications.release + } + } } diff --git a/build.gradle b/build.gradle index 94c94cd1..23ca302c 100644 --- a/build.gradle +++ b/build.gradle @@ -20,24 +20,23 @@ project.ext { buildscript { repositories { + jcenter() google() mavenCentral() - jcenter() } // Android specific dependencies. if (project.properties.get('buildPlatform', 'android') == 'android') { dependencies { classpath 'com.android.tools.build:gradle:4.1.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } } } allprojects { repositories { + jcenter() google() mavenCentral() - jcenter() maven { url "https://dl.bintray.com/ethereum/maven/" } } }