1717apply plugin : ' maven-publish'
1818apply plugin : ' signing'
1919
20+ Properties properties = new Properties ()
21+ properties. load(project. rootProject. file(' local.properties' ). newDataInputStream())
22+
2023def isReleaseBuild () {
2124 return libraryVersion. contains(" SNAPSHOT" ) == false
2225}
@@ -39,24 +42,15 @@ def getRepositoryPassword() {
3942 return hasProperty(' NEXUS_PASSWORD' ) ? NEXUS_PASSWORD : " "
4043}
4144
42- def keyID = System . getenv(' ORG_GRADLE_PROJECT_SIGNING_KEY_ID' )
43- def signing_password = System . getenv(' ORG_GRADLE_PROJECT_SIGNING_PASSWORD' )
44- def nexus_username = System . getenv(' ORG_GRADLE_PROJECT_NEXUS_USERNAME' )
45- def nexus_password = System . getenv(' ORG_GRADLE_PROJECT_NEXUS_PASSWORD' )
46-
47- println " Debug: Using GPG key ID: ${ keyID} "
45+ def keyID = properties. getProperty(" signing.keyId" )
46+ def signing_password = properties. getProperty(" signing.password" )
47+ def keyRingLocation = properties. getProperty(" signing.secretKeyRingFile" )
48+ def nexus_username = properties. getProperty(" NEXUS_USERNAME" )
49+ def nexus_password = properties. getProperty(" NEXUS_PASSWORD" )
4850
49- // Custom task to sign files with GPG
50- tasks. register(' signWithGPG' ) {
51- doLast {
52- def files = fileTree(dir : " ${ buildDir} /libs" , include : ' **/*.jar' )
53- files. each { file ->
54- exec {
55- commandLine ' gpg' , ' --batch' , ' --yes' , ' --passphrase' , signing_password, ' --local-user' , keyID, ' --sign' , file
56- }
57- }
58- }
59- }
51+ ext. " signing.keyId" = keyID
52+ ext. " signing.secretKeyRingFile" = keyRingLocation
53+ ext. " signing.password" = signing_password
6054
6155publishing {
6256 publications {
@@ -110,14 +104,13 @@ publishing {
110104 }
111105}
112106
113- // Disable the default signing
114107signing {
115- required { false }
108+ required { isReleaseBuild() }
109+ sign publishing. publications. release
116110}
117111
118112tasks. register(' uploadArchives' ) {
119113 dependsOn publishReleasePublicationToOSSRHRepository
120- dependsOn signWithGPG
121114}
122115
123116tasks. register(' androidSourcesJar' , Jar ) {
0 commit comments