Skip to content

Commit d9a591c

Browse files
authored
Update config to only publish to Maven central (#525)
* work towards removal of jcenter * Make autobahn publish-able * minor adjustments * reuse config
1 parent b4f70eb commit d9a591c

File tree

3 files changed

+93
-109
lines changed

3 files changed

+93
-109
lines changed

Makefile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BUILD_DATE=$(shell date -u +"%Y-%m-%d")
2-
AUTOBAHN_JAVA_VERSION='20.7.1'
2+
AUTOBAHN_JAVA_VERSION='21.4.1'
33
# git log --pretty=format:'%h' -n 1
44
AUTOBAHN_JAVA_VCS_REF='c48c8d1'
55

@@ -74,16 +74,9 @@ build_android:
7474

7575
publish_android: build_android
7676
sed -i 's/DEBUG = true/DEBUG = false/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java
77-
AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew bintrayUpload -PbuildPlatform=android
77+
AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew :autobahn:publishReleasePublicationToCentralRepository -PbuildPlatform=android
7878
sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java
7979

80-
publish_android_legacy: build_android
81-
sed -i 's/DEBUG = true/DEBUG = false/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java
82-
$(shell ./enable_old_androids.sh)
83-
AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew bintrayUpload -PbuildPlatform=android -PbuildLegacy=true
84-
sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java
85-
86-
8780
build_netty:
8881
docker run -it --rm \
8982
-e AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} \
@@ -93,5 +86,5 @@ build_netty:
9386

9487
publish_netty:
9588
sed -i 's/DEBUG = true/DEBUG = false/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java
96-
AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew bintrayUpload -PbuildPlatform=netty
89+
AUTOBAHN_BUILD_VERSION=${AUTOBAHN_JAVA_VERSION} ./gradlew :autobahn:publishReleasePublicationToCentralRepository -PbuildPlatform=netty
9790
sed -i 's/DEBUG = false/DEBUG = true/g' autobahn/src/main/java/io/crossbar/autobahn/utils/Globals.java

autobahn/build.gradle

Lines changed: 88 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ def IS_ANDROID = project.hasProperty('IS_ANDROID') ? project.IS_ANDROID: true
22
def IS_NEXT = project.hasProperty('IS_NEXT') ? project.IS_NEXT: false
33
def IS_NETTY = project.hasProperty('IS_NETTY') ? project.IS_NETTY: false
44
def ARTIFACT_ANDROID = (project.hasProperty('BUILD_LEGACY') && project.BUILD_LEGACY) ? 'autobahn-android-legacy': 'autobahn-android'
5-
def PUBLISH = project.hasProperty('PUBLISH') && project.PUBLISH
65

76
apply plugin: IS_ANDROID ? 'com.android.library': 'java-library'
7+
apply plugin: 'maven-publish'
8+
apply plugin: 'signing'
89

910
def ARTIFACT_JAVA = 'autobahn-java'
1011
def ARTIFACT_NEXT = 'autobahn'
1112

1213
def groupID = 'io.crossbar.autobahn'
13-
def gitUrl = 'https://github.com/crossbario/autobahn-java.git'
1414
def licenseName = 'MIT'
1515
def licenseUrl = 'https://opensource.org/licenses/MIT'
1616
def relVersion = System.getenv().containsKey('AUTOBAHN_BUILD_VERSION') ? System.getenv(
17-
'AUTOBAHN_BUILD_VERSION'): '18.3.1'
17+
'AUTOBAHN_BUILD_VERSION'): '21.4.1'
1818
def siteUrl = 'https://github.com/crossbario/autobahn-java'
19+
def SONATYPE_USER = System.getenv().containsKey('SONATYPE_USER') ? System.getenv('SONATYPE_USER'): ''
20+
def SONATYPE_PASS = System.getenv().containsKey('SONATYPE_PASS') ? System.getenv('SONATYPE_PASS'): ''
1921

2022
dependencies {
2123
api 'com.fasterxml.jackson.core:jackson-core:2.12.3'
@@ -40,6 +42,27 @@ dependencies {
4042
}
4143
}
4244

45+
// Create the pom configuration:
46+
def pomConfig = {
47+
// Set your license
48+
licenses {
49+
license {
50+
name licenseName
51+
url licenseUrl
52+
}
53+
}
54+
developers {
55+
developer {
56+
id "crossbario"
57+
name "Crossbar.io"
58+
59+
}
60+
}
61+
scm {
62+
url siteUrl
63+
}
64+
}
65+
4366
if (IS_ANDROID) {
4467
android {
4568
compileSdkVersion 30
@@ -78,9 +101,8 @@ if (IS_ANDROID) {
78101
}
79102
}
80103

81-
82104
task sourcesJar(type: Jar) {
83-
classifier = 'sources'
105+
archiveClassifier.set("sources")
84106
from android.sourceSets.main.java.srcDirs
85107
}
86108

@@ -90,112 +112,44 @@ if (IS_ANDROID) {
90112
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
91113
classpath += configurations.compile
92114
}
115+
116+
task javadocJar(type: Jar, dependsOn: javadoc) {
117+
archiveClassifier.set("javadoc")
118+
from javadoc.destinationDir
119+
}
120+
121+
project.archivesBaseName = ARTIFACT_ANDROID
122+
group = groupID
123+
version = relVersion
124+
93125
afterEvaluate {
94126
javadoc.classpath += files(android.libraryVariants.collect { variant ->
95127
variant.javaCompile.classpath.files
96128
})
97129
}
98-
project.archivesBaseName = ARTIFACT_ANDROID
99-
group = groupID
100-
version = relVersion
101130

102-
if (PUBLISH) {
103-
apply plugin: 'com.github.dcendents.android-maven'
104-
105-
install {
106-
repositories.mavenInstaller {
107-
// This generates POM.xml with proper parameters
108-
pom {
109-
project {
110-
packaging 'aar'
111-
groupId groupID
112-
artifactId ARTIFACT_ANDROID
113-
114-
// Add your description here
115-
name ARTIFACT_ANDROID
116-
description 'WebSocket & WAMP for Android'
117-
url siteUrl
118-
119-
// Set your license
120-
licenses {
121-
license {
122-
name licenseName
123-
url licenseUrl
124-
}
125-
}
126-
developers {
127-
developer {
128-
id "crossbario"
129-
name "Crossbar.io"
130-
131-
}
132-
}
133-
scm {
134-
url siteUrl
135-
}
136-
}
131+
publishing {
132+
repositories {
133+
maven {
134+
name 'central'
135+
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
136+
credentials {
137+
username SONATYPE_USER
138+
password SONATYPE_PASS
137139
}
138140
}
139141
}
140142
}
141-
task javadocJar(type: Jar, dependsOn: javadoc) {
142-
classifier = 'javadoc'
143-
from javadoc.destinationDir
144-
}
145143
} else {
146-
// Create the pom configuration:
147-
def pomConfig = {
148-
// Set your license
149-
licenses {
150-
license {
151-
name licenseName
152-
url licenseUrl
153-
}
154-
}
155-
developers {
156-
developer {
157-
id "crossbario"
158-
name "Crossbar.io"
159-
160-
}
161-
}
162-
scm {
163-
url siteUrl
164-
}
165-
}
166144
task sourcesJar(type: Jar, dependsOn: classes) {
167-
classifier = 'sources'
145+
archiveClassifier.set("sources")
168146
from sourceSets.main.allSource
169147
}
170148
task javadocJar(type: Jar, dependsOn: javadoc) {
171-
classifier = 'javadoc'
149+
archiveClassifier.set("javadoc")
172150
from javadoc.destinationDir
173151
}
174152

175-
if (PUBLISH) {
176-
apply plugin: 'maven-publish'
177-
178-
publishing {
179-
publications {
180-
mavenJava(MavenPublication) {
181-
from components.java
182-
artifact sourcesJar
183-
artifact javadocJar
184-
185-
groupId groupID
186-
artifactId IS_NEXT ? ARTIFACT_NEXT: ARTIFACT_JAVA
187-
version relVersion
188-
pom.withXml {
189-
def root = asNode()
190-
root.appendNode('description', 'WebSocket & WAMP for Java8+')
191-
root.appendNode('name', 'Autobahn Java')
192-
root.appendNode('url', siteUrl)
193-
root.children().last() + pomConfig
194-
}
195-
}
196-
}
197-
}
198-
}
199153
if (IS_NEXT) {
200154
sourceSets {
201155
main {
@@ -226,7 +180,45 @@ if (IS_ANDROID) {
226180
targetCompatibility = JavaVersion.VERSION_1_8
227181
}
228182

229-
artifacts {
230-
archives sourcesJar
231-
archives javadocJar
183+
afterEvaluate {
184+
publishing {
185+
publications {
186+
release(MavenPublication) {
187+
if (IS_ANDROID) {
188+
from components.release
189+
artifactId ARTIFACT_ANDROID
190+
} else {
191+
from components.java
192+
artifactId IS_NEXT ? ARTIFACT_NEXT: ARTIFACT_JAVA
193+
}
194+
195+
artifact sourcesJar
196+
artifact javadocJar
197+
198+
groupId groupID
199+
version relVersion
200+
pom.withXml {
201+
def root = asNode()
202+
root.appendNode('description', 'WebSocket & WAMP for Java8+')
203+
root.appendNode('name', 'Autobahn Java')
204+
root.appendNode('url', siteUrl)
205+
root.children().last() + pomConfig
206+
}
207+
}
208+
}
209+
repositories {
210+
maven {
211+
name 'central'
212+
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
213+
credentials {
214+
username SONATYPE_USER
215+
password SONATYPE_PASS
216+
}
217+
}
218+
}
219+
signing {
220+
required true
221+
sign publishing.publications.release
222+
}
223+
}
232224
}

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@ project.ext {
2020

2121
buildscript {
2222
repositories {
23+
jcenter()
2324
google()
2425
mavenCentral()
25-
jcenter()
2626
}
2727
// Android specific dependencies.
2828
if (project.properties.get('buildPlatform', 'android') == 'android') {
2929
dependencies {
3030
classpath 'com.android.tools.build:gradle:4.1.3'
31-
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
3231
}
3332
}
3433
}
3534

3635
allprojects {
3736
repositories {
37+
jcenter()
3838
google()
3939
mavenCentral()
40-
jcenter()
4140
maven { url "https://dl.bintray.com/ethereum/maven/" }
4241
}
4342
}

0 commit comments

Comments
 (0)