From 07a147f1bd26a5bf24065be1c07bcd37f6bfc1b8 Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Sat, 24 Apr 2021 18:23:06 +0500 Subject: [PATCH 1/4] work towards removal of jcenter --- Makefile | 4 +- autobahn/build.gradle | 132 ++++++++++++++++++++++-------------------- build.gradle | 5 +- 3 files changed, 72 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index f178e09b..8da654d4 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.24' # git log --pretty=format:'%h' -n 1 AUTOBAHN_JAVA_VCS_REF='c48c8d1' @@ -93,5 +93,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 publish -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..20b54c40 100644 --- a/autobahn/build.gradle +++ b/autobahn/build.gradle @@ -5,6 +5,7 @@ def ARTIFACT_ANDROID = (project.hasProperty('BUILD_LEGACY') && project.BUILD_LEG def PUBLISH = project.hasProperty('PUBLISH') && project.PUBLISH apply plugin: IS_ANDROID ? 'com.android.library': 'java-library' +apply plugin: 'maven-publish' def ARTIFACT_JAVA = 'autobahn-java' def ARTIFACT_NEXT = 'autobahn' @@ -14,7 +15,7 @@ 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.24' def siteUrl = 'https://github.com/crossbario/autobahn-java' dependencies { @@ -76,11 +77,13 @@ if (IS_ANDROID) { exclude 'META-INF/license.txt' exclude 'META-INF/notice.txt' } + dexOptions { + javaMaxHeapSize "4g" + } } - task sourcesJar(type: Jar) { - classifier = 'sources' + archiveClassifier.set("sources") from android.sourceSets.main.java.srcDirs } @@ -95,52 +98,56 @@ if (IS_ANDROID) { variant.javaCompile.classpath.files }) } + + task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier.set("javadoc") + from javadoc.destinationDir + } + 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 - } - } + afterEvaluate { + publishing { + publications { + // Creates a Maven publication called "release". + release(MavenPublication) { + // Applies the component for the release build variant. + from components.release + + artifact sourcesJar + artifact javadocJar + + // You can then customize attributes of the publication as shown below. + groupId = groupID + artifactId = ARTIFACT_ANDROID + version = relVersion + + } + // Creates a Maven publication called “debug”. + debug(MavenPublication) { + // Applies the component for the debug build variant. + from components.debug + + artifact sourcesJar + artifact javadocJar + + groupId = groupID + artifactId = ARTIFACT_ANDROID + '-debug' + version = relVersion + } + } + } + repositories { + maven { + url 'https://repo1.maven.org/maven2' + credentials { + username "" + password "" } } } - } - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir } } else { // Create the pom configuration: @@ -164,38 +171,35 @@ if (IS_ANDROID) { } } 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 - } + 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 { 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/" } } } From 3c999a8ef4a42efcf7ec14ece98d5e6d783e931c Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Sun, 25 Apr 2021 01:32:58 +0500 Subject: [PATCH 2/4] Make autobahn publish-able --- autobahn/build.gradle | 61 +++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/autobahn/build.gradle b/autobahn/build.gradle index 20b54c40..44b86962 100644 --- a/autobahn/build.gradle +++ b/autobahn/build.gradle @@ -2,7 +2,6 @@ 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' @@ -11,12 +10,13 @@ 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'): '21.4.24' + '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' @@ -77,9 +77,6 @@ if (IS_ANDROID) { exclude 'META-INF/license.txt' exclude 'META-INF/notice.txt' } - dexOptions { - javaMaxHeapSize "4g" - } } task sourcesJar(type: Jar) { @@ -93,11 +90,6 @@ if (IS_ANDROID) { classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile } - afterEvaluate { - javadoc.classpath += files(android.libraryVariants.collect { variant -> - variant.javaCompile.classpath.files - }) - } task javadocJar(type: Jar, dependsOn: javadoc) { archiveClassifier.set("javadoc") @@ -109,6 +101,9 @@ if (IS_ANDROID) { version = relVersion afterEvaluate { + javadoc.classpath += files(android.libraryVariants.collect { variant -> + variant.javaCompile.classpath.files + }) publishing { publications { // Creates a Maven publication called "release". @@ -116,35 +111,28 @@ if (IS_ANDROID) { // Applies the component for the release build variant. from components.release - artifact sourcesJar - artifact javadocJar + artifacts { + archives javadocJar, sourcesJar + } // You can then customize attributes of the publication as shown below. groupId = groupID artifactId = ARTIFACT_ANDROID version = relVersion - - } - // Creates a Maven publication called “debug”. - debug(MavenPublication) { - // Applies the component for the debug build variant. - from components.debug - - artifact sourcesJar - artifact javadocJar - - groupId = groupID - artifactId = ARTIFACT_ANDROID + '-debug' - version = relVersion + ext.repo = 'central' } } } + } + + publishing { repositories { maven { - url 'https://repo1.maven.org/maven2' + name 'central' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' credentials { - username "" - password "" + username SONATYPE_USER + password SONATYPE_PASS } } } @@ -198,6 +186,16 @@ if (IS_ANDROID) { } } } + repositories { + maven { + name 'central' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username SONATYPE_USER + password SONATYPE_PASS + } + } + } } if (IS_NEXT) { @@ -229,8 +227,3 @@ if (IS_ANDROID) { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } - -artifacts { - archives sourcesJar - archives javadocJar -} From 264c01de034468acb73554753e3d3f6f8d2ee71b Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Sun, 25 Apr 2021 01:37:02 +0500 Subject: [PATCH 3/4] minor adjustments --- Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8da654d4..f76bf775 100644 --- a/Makefile +++ b/Makefile @@ -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 publish -PbuildPlatform=netty + AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew :autobahn:publishMavenJavaPublicationToCentralRepository -PbuildPlatform=netty sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java From db9c836c2657bd15f6925c6df8b90447e01fcf7b Mon Sep 17 00:00:00 2001 From: Omer Akram Date: Sun, 25 Apr 2021 04:28:21 +0500 Subject: [PATCH 4/4] reuse config --- Makefile | 4 +- autobahn/build.gradle | 135 ++++++++++++++++++++---------------------- 2 files changed, 67 insertions(+), 72 deletions(-) diff --git a/Makefile b/Makefile index f76bf775..002cbfe6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BUILD_DATE=$(shell date -u +"%Y-%m-%d") -AUTOBAHN_JAVA_VERSION='21.4.24' +AUTOBAHN_JAVA_VERSION='21.4.1' # git log --pretty=format:'%h' -n 1 AUTOBAHN_JAVA_VCS_REF='c48c8d1' @@ -86,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 :autobahn:publishMavenJavaPublicationToCentralRepository -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 44b86962..a5810d0a 100644 --- a/autobahn/build.gradle +++ b/autobahn/build.gradle @@ -5,6 +5,7 @@ def ARTIFACT_ANDROID = (project.hasProperty('BUILD_LEGACY') && project.BUILD_LEG 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' @@ -41,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 @@ -104,25 +126,6 @@ if (IS_ANDROID) { javadoc.classpath += files(android.libraryVariants.collect { variant -> variant.javaCompile.classpath.files }) - publishing { - publications { - // Creates a Maven publication called "release". - release(MavenPublication) { - // Applies the component for the release build variant. - from components.release - - artifacts { - archives javadocJar, sourcesJar - } - - // You can then customize attributes of the publication as shown below. - groupId = groupID - artifactId = ARTIFACT_ANDROID - version = relVersion - ext.repo = 'central' - } - } - } } publishing { @@ -138,26 +141,6 @@ if (IS_ANDROID) { } } } 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) { archiveClassifier.set("sources") from sourceSets.main.allSource @@ -167,37 +150,6 @@ if (IS_ANDROID) { from javadoc.destinationDir } - 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 - } - } - } - repositories { - maven { - name 'central' - url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' - credentials { - username SONATYPE_USER - password SONATYPE_PASS - } - } - } - } - if (IS_NEXT) { sourceSets { main { @@ -227,3 +179,46 @@ if (IS_ANDROID) { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + +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 + } + } +}