Skip to content

Commit bc7c96a

Browse files
Adjustments for publishing artifacts to Maven Central
1 parent 85580ff commit bc7c96a

File tree

3 files changed

+72
-38
lines changed

3 files changed

+72
-38
lines changed

Makefile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ build-debug:
1111
$(GRADLE) assembleDebug
1212

1313
build-release:
14-
$(GRADLE) assembleRelease
14+
$(GRADLE) \
15+
-PsqlcipherAndroidVersion="$(SQLCIPHER_ANDROID_VERSION)" \
16+
assembleRelease
1517

1618
publish-snapshot-to-local-maven:
1719
@ $(collect-signing-info) \
@@ -22,18 +24,20 @@ publish-snapshot-to-local-maven:
2224
-Psigning.password="$$gpgPassword" \
2325
publishReleasePublicationToMavenLocal
2426

25-
publish-snapshot-to-local-nexus:
27+
publish-remote-release:
2628
@ $(collect-signing-info) \
2729
$(collect-nexus-info) \
2830
$(GRADLE) \
29-
-PpublishSnapshot=true \
30-
-Psigning.keyId="$$gpgKeyId" \
31-
-Psigning.secretKeyRingFile="$$gpgKeyRingFile" \
32-
-Psigning.password="$$gpgPassword" \
31+
-PpublishSnapshot=false \
32+
-PpublishLocal=false \
33+
-PdebugBuild=false \
34+
-PsigningKeyId="$$gpgKeyId" \
35+
-PsigningKeyRingFile="$$gpgKeyRingFile" \
36+
-PsigningKeyPassword="$$gpgPassword" \
3337
-PnexusUsername="$$nexusUsername" \
3438
-PnexusPassword="$$nexusPassword" \
35-
-PnexusStagingProfileId="$$nexusStagingProfileId" \
36-
publishAllPublicationsToLocalNexusRepository
39+
-PsqlcipherAndroidVersion="$(SQLCIPHER_ANDROID_VERSION)" \
40+
sqlcipher:publish
3741

3842
collect-signing-info := \
3943
read -p "Enter GPG signing key id:" gpgKeyId; \
@@ -42,6 +46,5 @@ collect-signing-info := \
4246
read -p "Enter GPG password:" gpgPassword; stty echo;
4347

4448
collect-nexus-info := \
45-
read -p "Enter Nexus username:" nexusUsername; stty -echo; \
46-
read -p "Enter Nexus password:" nexusPassword; stty echo; \
47-
read -p "Enter Nexus staging profile id:" nexusStagingProfileId;
49+
read -p "Enter Nexus username:" nexusUsername; \
50+
stty -echo; read -p "Enter Nexus password:" nexusPassword; stty echo;

build.gradle

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,6 @@ project.ext {
5656
nexusStagingProfileId = project.hasProperty('nexusStagingProfileId') ? "${nexusStagingProfileId}" : ""
5757
}
5858

59-
nexusPublishing {
60-
repositories {
61-
sonatype {
62-
nexusUrl = uri("https://oss.sonatype.org/")
63-
snapshotRepositoryUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
64-
username = "${rootProject.ext.nexusUsername}"
65-
password = "${rootProject.ext.nexusPassword}"
66-
stagingProfileId = "${rootProject.ext.nexusStagingProfileId}"
67-
}
68-
localNexus {
69-
useStaging = false
70-
nexusUrl = uri("http://localhost:8081/")
71-
snapshotRepositoryUrl = uri("http://localhost:8081/repository/maven-snapshots/")
72-
username = "${rootProject.ext.nexusUsername}"
73-
password = "${rootProject.ext.nexusPassword}"
74-
stagingProfileId = ""
75-
}
76-
}
77-
}
78-
7959
task generateReadMe {
8060
def readme = new File("README.md")
8161
def engine = new SimpleTemplateEngine()

sqlcipher/build.gradle

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'com.android.library'
2+
apply plugin: "maven-publish"
3+
apply plugin: "signing"
24

35
android {
46
compileSdkVersion 30
@@ -74,10 +76,44 @@ allprojects {
7476
}
7577
}
7678

79+
def isReleaseBuild() {
80+
return mavenVersionName.contains("SNAPSHOT") == false
81+
}
82+
83+
def getReleaseRepositoryUrl() {
84+
return hasProperty('mavenReleaseRepositoryUrl') ? mavenReleaseRepositoryUrl
85+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
86+
}
87+
88+
def getSnapshotRepositoryUrl() {
89+
if(hasProperty('mavenLocalRepositoryPrefix')) {
90+
return "${mavenLocalRepositoryPrefix}${buildDir}/${mavenSnapshotRepositoryUrl}"
91+
} else {
92+
return hasProperty('mavenSnapshotRepositoryUrl') ? mavenSnapshotRepositoryUrl
93+
: "https://oss.sonatype.org/content/repositories/snapshots/"
94+
}
95+
}
96+
97+
def getRepositoryUsername() {
98+
return hasProperty('nexusUsername') ? nexusUsername : ""
99+
}
100+
101+
def getRepositoryPassword() {
102+
return hasProperty('nexusPassword') ? nexusPassword : ""
103+
}
104+
105+
gradle.taskGraph.whenReady { taskGraph ->
106+
if (taskGraph.allTasks.any { it instanceof Sign }) {
107+
allprojects { ext."signing.keyId" = "${signingKeyId}" }
108+
allprojects { ext."signing.secretKeyRingFile" = "${signingKeyRingFile}" }
109+
allprojects { ext."signing.password" = "${signingKeyPassword}" }
110+
}
111+
}
112+
77113
afterEvaluate {
78114
publishing {
79115
publications {
80-
release(MavenPublication) {
116+
mavenJava(MavenPublication) {
81117
groupId = "net.zetetic"
82118
artifactId = "sqlcipher-android"
83119
version = "${rootProject.ext.mavenVersionName}"
@@ -109,18 +145,33 @@ afterEvaluate {
109145
}
110146
}
111147
}
148+
149+
repositories {
150+
maven {
151+
def repoUrl = isReleaseBuild()
152+
? getReleaseRepositoryUrl()
153+
: getSnapshotRepositoryUrl()
154+
url = repoUrl
155+
credentials {
156+
username = getRepositoryUsername()
157+
password = getRepositoryPassword()
158+
}
159+
}
160+
}
161+
112162
}
113163

114164
signing {
115-
sign publishing.publications
165+
required { isReleaseBuild() && gradle.taskGraph.hasTask("publish") }
166+
sign publishing.publications.mavenJava
167+
}
168+
169+
artifacts {
170+
archives androidSourcesJar
116171
}
117172
}
118173

119174
task androidSourcesJar(type: Jar) {
120175
archiveClassifier.set('sources')
121176
from android.sourceSets.main.java.srcDirs
122-
}
123-
124-
artifacts {
125-
archives androidSourcesJar
126-
}
177+
}

0 commit comments

Comments
 (0)