@@ -2,20 +2,22 @@ def IS_ANDROID = project.hasProperty('IS_ANDROID') ? project.IS_ANDROID: true
22def IS_NEXT = project. hasProperty(' IS_NEXT' ) ? project. IS_NEXT : false
33def IS_NETTY = project. hasProperty(' IS_NETTY' ) ? project. IS_NETTY : false
44def ARTIFACT_ANDROID = (project. hasProperty(' BUILD_LEGACY' ) && project. BUILD_LEGACY ) ? ' autobahn-android-legacy' : ' autobahn-android'
5- def PUBLISH = project. hasProperty(' PUBLISH' ) && project. PUBLISH
65
76apply plugin : IS_ANDROID ? ' com.android.library' : ' java-library'
7+ apply plugin : ' maven-publish'
8+ apply plugin : ' signing'
89
910def ARTIFACT_JAVA = ' autobahn-java'
1011def ARTIFACT_NEXT = ' autobahn'
1112
1213def groupID = ' io.crossbar.autobahn'
13- def gitUrl = ' https://github.com/crossbario/autobahn-java.git'
1414def licenseName = ' MIT'
1515def licenseUrl = ' https://opensource.org/licenses/MIT'
1616def relVersion = System . getenv(). containsKey(' AUTOBAHN_BUILD_VERSION' ) ? System . getenv(
17- ' AUTOBAHN_BUILD_VERSION' ): ' 18.3 .1'
17+ ' AUTOBAHN_BUILD_VERSION' ): ' 21.4 .1'
1818def 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
2022dependencies {
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+
4366if (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}
0 commit comments