Skip to content

Commit

Permalink
Update config to only publish to Maven central (#525)
Browse files Browse the repository at this point in the history
* work towards removal of jcenter

* Make autobahn publish-able

* minor adjustments

* reuse config
  • Loading branch information
om26er authored Apr 24, 2021
1 parent b4f70eb commit d9a591c
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 109 deletions.
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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} \
Expand All @@ -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
184 changes: 88 additions & 96 deletions autobahn/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 "[email protected]"
}
}
scm {
url siteUrl
}
}

if (IS_ANDROID) {
android {
compileSdkVersion 30
Expand Down Expand Up @@ -78,9 +101,8 @@ if (IS_ANDROID) {
}
}


task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier.set("sources")
from android.sourceSets.main.java.srcDirs
}

Expand All @@ -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 "[email protected]"
}
}
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 "[email protected]"
}
}
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 {
Expand Down Expand Up @@ -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
}
}
}
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
}
}

0 comments on commit d9a591c

Please sign in to comment.