Skip to content

Commit ab0b038

Browse files
author
Dimitard
committed
chore(project): Migrate publishing to Maven Central
1 parent ddcd9de commit ab0b038

File tree

16 files changed

+173
-86
lines changed

16 files changed

+173
-86
lines changed

.gitlab-ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ tests:
6565
junit:
6666
- "*/build/test-results/test/TEST-*.xml"
6767

68-
upload-artifacts-bintray:
68+
upload-artifacts-mavenCentral:
6969
stage: deploy
7070
only:
7171
- tags
7272
tags:
7373
- java
7474
script:
75-
- ./gradlew install bintrayUpload
75+
- ./gradlew install publishReleasePublicationToSonatypeRepository
7676
dependencies: []
7777

binapi-client/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ ext {
1717
artifactId = 'binapi-client'
1818
}
1919

20-
apply from: rootProject.file('bintray.gradle')
20+
apply from: rootProject.file('publish-mavencentral.gradle')

bintray.gradle

-64
This file was deleted.

build.gradle

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
repositories {
2-
mavenCentral()
3-
}
4-
51
buildscript {
62

73
repositories {
8-
jcenter()
94
mavenCentral()
105
maven {
116
url "https://plugins.gradle.org/m2/"
127
}
138
}
149

1510
dependencies {
16-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
1711
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
1812
}
1913
}
2014

15+
plugins {
16+
id("io.github.gradle-nexus.publish-plugin") version '1.0.0'
17+
}
18+
19+
2120
allprojects {
2221
apply from: rootProject.file('dependencies.gradle')
23-
apply from: rootProject.file('publishing.gradle')
2422
}
2523

2624
subprojects { subProject ->
2725
repositories {
28-
jcenter()
2926
mavenCentral()
3027
}
3128

@@ -36,4 +33,6 @@ subprojects { subProject ->
3633

3734
subProject.apply from: rootProject.file('static-analysis.gradle')
3835
}
39-
}
36+
}
37+
38+
apply from: rootProject.file('nexus-publish.gradle')

composer-adapter-rxjava/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ ext {
1313
artifactId = 'composer-adapter-rxjava'
1414
}
1515

16-
apply from: rootProject.file('bintray.gradle')
16+
apply from: rootProject.file('publish-mavencentral.gradle')
1717

composer-annotations/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ dependencies {
2424
compileOnly project(':binapi-client')
2525
}
2626

27-
apply from: rootProject.file('bintray.gradle')
27+
apply from: rootProject.file('publish-mavencentral.gradle')

composer/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ ext {
1414
artifactId = 'composer'
1515
}
1616

17-
apply from: rootProject.file('bintray.gradle')
17+
apply from: rootProject.file('publish-mavencentral.gradle')

nexus-publish.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply from: rootProject.file('publishing.gradle')
2+
3+
group = getPublishProperty('groupId')
4+
5+
6+
def ossrhUsername, ossrhPassword, sonatypeStagingProfileId = ''
7+
8+
File secretPropsFile = project.rootProject.file('local.properties')
9+
if (secretPropsFile.exists()) {
10+
Properties properties = new Properties()
11+
properties.load(secretPropsFile.newDataInputStream())
12+
ossrhUsername = properties.getProperty("ossrhUsername")
13+
ossrhPassword = properties.getProperty("ossrhPassword")
14+
sonatypeStagingProfileId = properties.getProperty("sonatypeStagingProfileId")
15+
16+
} else {
17+
ossrhUsername = System.getenv('OSSRH_USERNAME')
18+
ossrhPassword = System.getenv('OSSRH_PASSWORD')
19+
sonatypeStagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID')
20+
}
21+
22+
nexusPublishing {
23+
repositories {
24+
sonatype {
25+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
26+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
27+
username = ossrhUsername
28+
password = ossrhPassword
29+
stagingProfileId = sonatypeStagingProfileId
30+
}
31+
}
32+
}

protocol/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ ext {
1414
artifactId = 'protocol'
1515
}
1616

17-
apply from: rootProject.file('bintray.gradle')
17+
apply from: rootProject.file('publish-mavencentral.gradle')

publish-mavencentral.gradle

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
apply from: rootProject.file('publishing.gradle')
4+
5+
if (project.hasProperty("android")) { // Android libraries
6+
7+
tasks.register('sourcesJar', Jar) {
8+
archiveClassifier.convention('sources')
9+
archiveClassifier.set('sources')
10+
from android.sourceSets.main.java.srcDirs
11+
}
12+
13+
tasks.register('javadoc', Javadoc) {
14+
failOnError = true
15+
source = android.sourceSets.main.java.srcDirs
16+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
17+
}
18+
} else { // Java libraries
19+
tasks.register('sourcesJar', Jar) {
20+
dependsOn classes
21+
archiveClassifier.convention('sources')
22+
archiveClassifier.set('sources')
23+
from sourceSets.main.allSource
24+
}
25+
}
26+
27+
tasks.register('javadocJar', Jar) {
28+
if (project.hasProperty("android")) {
29+
dependsOn "javadoc"
30+
from javadoc.destinationDir
31+
}
32+
archiveClassifier.convention('javadoc')
33+
archiveClassifier.set('javadoc')
34+
}
35+
36+
artifacts {
37+
archives javadocJar
38+
archives sourcesJar
39+
}
40+
41+
group = project.getPublishProperty('groupId')
42+
version = project.getPublishProperty('versionName')
43+
44+
ext["signing.keyId"] = ''
45+
ext["signing.password"] = ''
46+
ext["signing.secretKeyRingFile"] = ''
47+
48+
49+
File secretPropsFile = project.rootProject.file('local.properties')
50+
if (secretPropsFile.exists()) {
51+
Properties p = new Properties()
52+
p.load(new FileInputStream(secretPropsFile))
53+
p.each { name, value ->
54+
ext[name] = value
55+
}
56+
} else {
57+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
58+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
59+
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
60+
}
61+
62+
afterEvaluate {
63+
publishing {
64+
publications {
65+
release(MavenPublication) {
66+
67+
groupId = getPublishProperty('groupId')
68+
version = getPublishProperty('versionName')
69+
if (project.plugins.findPlugin("com.android.library")) {
70+
javadoc.classpath += files(android.libraryVariants.collect { variant ->
71+
variant.javaCompile.classpath.files
72+
})
73+
from components.release
74+
} else {
75+
from components.java
76+
}
77+
78+
artifact sourcesJar
79+
artifact javadocJar
80+
81+
pom {
82+
name = getPublishProperty('libraryName')
83+
description = getPublishProperty('description')
84+
url = getPublishProperty('siteUrl')
85+
license {
86+
name = getPublishProperty('licenseName')
87+
url = getPublishProperty('licenseUrl')
88+
}
89+
developer {
90+
name = getPublishProperty('developerName')
91+
email = getPublishProperty('developerEmail')
92+
organization = getPublishProperty('developerName')
93+
organizationUrl = getPublishProperty('developerUrl')
94+
}
95+
scm {
96+
connection = getPublishProperty('scmUrl')
97+
developerConnection = getPublishProperty('scmUrl')
98+
url = getPublishProperty('siteUrl')
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
106+
signing {
107+
sign publishing.publications
108+
}

publishing.gradle

+13-1
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,28 @@ ext {
2323
groupId = "com.pcloud.pcloud-networking-java"
2424
description = "A Network Stack for pCloud's API written in Java"
2525
siteUrl = 'https://github.com/pCloud/pcloud-networking-java'
26-
vcsUrl = 'https://github.com/pCloud/pcloud-networking-java'
26+
scmUrl = 'https://github.com/pCloud/pcloud-networking-java.git'
2727

2828
developerId = 'android-pcloud'
2929
developerName = 'pCloud AG'
3030
developerEmail = '[email protected]'
31+
developerUrl = 'https://www.pcloud.com'
3132

3233
licenseName = 'The Apache License v2.0'
3334
licenseUrl = 'https://github.com/pCloud/pcloud-networking-java/LICENSE'
3435
allLicenses = ["Apache-2.0"]
3536
}
3637

38+
ext.getPublishProperty = { String valueName ->
39+
String value = null
40+
if (project.ext.has(valueName)) {
41+
value = project.ext.get(valueName)
42+
} else if (rootProject.ext.has(valueName)) {
43+
value = rootProject.ext.get(valueName)
44+
}
45+
46+
return value
47+
}
48+
3749
version = ext.versionName
3850
group = ext.groupId

serialization-adapter-timestamp/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ ext {
99
artifactId = 'serialization-adapter-timestamp'
1010
}
1111

12-
apply from: rootProject.file('bintray.gradle')
12+
apply from: rootProject.file('publish-mavencentral.gradle')

serialization-annotations/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ ext {
44
artifactId = 'serialization-annotations'
55
}
66

7-
apply from: rootProject.file('bintray.gradle')
7+
apply from: rootProject.file('publish-mavencentral.gradle')

serialization/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ findbugs {
1919
reportLevel 'medium'
2020
}
2121

22-
apply from: rootProject.file('bintray.gradle')
22+
apply from: rootProject.file('publish-mavencentral.gradle')

utils-io/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ findbugs {
1515
reportLevel 'medium'
1616
}
1717

18-
apply from: rootProject.file('bintray.gradle')
18+
apply from: rootProject.file('publish-mavencentral.gradle')

utils-reflection/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ tasks.withType(FindBugs) {
1212
enabled false
1313
}
1414

15-
apply from: rootProject.file('bintray.gradle')
15+
apply from: rootProject.file('publish-mavencentral.gradle')

0 commit comments

Comments
 (0)