|
1 | | -@SuppressWarnings(["GroovyUnusedDeclaration", "GrMethodMayBeStatic"]) |
2 | | -def isReleaseBuild() { |
3 | | - return !VERSION_NAME.contains("SNAPSHOT") |
4 | | -} |
| 1 | +apply plugin: 'maven-publish' |
| 2 | +apply plugin: 'signing' |
| 3 | + |
| 4 | +ext["signing.keyId"] = project.hasProperty('sonatype.gpg.key') ? project.property('sonatype.gpg.key') : System.getenv('SONATYPE_GPG_KEY') |
| 5 | +ext["signing.password"] = project.hasProperty('sonatype.gpg.password') ? project.property('sonatype.gpg.password') : System.getenv('SONATYPE_GPG_PASS') |
| 6 | +ext["signing.secretKeyRingFile"] = project.hasProperty('sonatype.gpg.secretKeyRingFile') ? project.property('sonatype.gpg.secretKeyRingFile') : System.getenv('SONATYPE_GPG_FILE') |
5 | 7 |
|
6 | 8 | @SuppressWarnings("GroovyUnusedDeclaration") |
7 | 9 | def getRepositoryUsername() { |
@@ -13,12 +15,7 @@ def getRepositoryPassword() { |
13 | 15 | return project.hasProperty('NEXUS_PASSWORD') ? project.property('NEXUS_PASSWORD') : System.getenv('NEXUS_PASSWORD') |
14 | 16 | } |
15 | 17 |
|
16 | | -apply plugin: "com.jfrog.bintray" |
17 | | - |
18 | 18 | afterEvaluate { project -> |
19 | | - apply plugin: 'maven-publish' |
20 | | - apply plugin: 'com.github.dcendents.android-maven' |
21 | | - |
22 | 19 | if (JavaVersion.current().isJava8Compatible()) { |
23 | 20 | allprojects { |
24 | 21 | tasks.withType(Javadoc) { |
@@ -43,60 +40,6 @@ afterEvaluate { project -> |
43 | 40 | from android.sourceSets.main.java.source |
44 | 41 | } |
45 | 42 |
|
46 | | - bintray { |
47 | | - dryRun = false |
48 | | - publish = true |
49 | | - override = true |
50 | | - user = project.hasProperty('bintray.user') ? project.property('bintray.user') : System.getenv('BINTRAY_USER') |
51 | | - key = project.hasProperty('bintray.apikey') ? project.property('bintray.apikey') : System.getenv('BINTRAY_API_KEY') |
52 | | - def gpgkey = project.hasProperty('bintray.gpg.key') ? project.property('bintray.gpg.key') : System.getenv('BINTRAY_GPG_KEY') |
53 | | - def gpgpass = project.hasProperty('bintray.gpg.password') ? project.property('bintray.gpg.password') : System.getenv('BINTRAY_GPG_PASS') |
54 | | - def versionName = project.release.versionName |
55 | | - |
56 | | - publications('release') |
57 | | - |
58 | | - pkg { |
59 | | - publish = true |
60 | | - |
61 | | - repo = "maven" |
62 | | - name = GROUP + ":" + POM_ARTIFACT_ID //the name (= identifier) on bintray |
63 | | - desc = POM_DESCRIPTION |
64 | | - |
65 | | - websiteUrl = POM_URL |
66 | | - issueTrackerUrl = POM_SCM_URL_ISSUES |
67 | | - vcsUrl = POM_SCM_URL |
68 | | - |
69 | | - githubRepo = POM_GITHUB_REPO |
70 | | - githubReleaseNotesFile = POM_GITHUB_README |
71 | | - |
72 | | - publicDownloadNumbers = true |
73 | | - licenses = ["Apache-2.0"] |
74 | | - version { |
75 | | - name = versionName |
76 | | - vcsTag = versionName |
77 | | - released = new Date() |
78 | | - |
79 | | - mavenCentralSync { |
80 | | - sync = true |
81 | | - user = getRepositoryUsername() |
82 | | - password = getRepositoryPassword() |
83 | | - close = '0' |
84 | | - } |
85 | | - gpg { |
86 | | - sign = true |
87 | | - passphrase = gpgpass |
88 | | - } |
89 | | - } |
90 | | - } |
91 | | - } |
92 | | - |
93 | | - ext.addDependency = { dependencyNode, group, name, version -> |
94 | | - dependencyNode.appendNode('groupId', group) |
95 | | - dependencyNode.appendNode('artifactId', name) |
96 | | - dependencyNode.appendNode('version', version) |
97 | | - dependencyNode.appendNode('scope', "compile") |
98 | | - } |
99 | | - |
100 | 43 | def pomConfig = { |
101 | 44 | licenses { |
102 | 45 | license { |
@@ -122,32 +65,40 @@ afterEvaluate { project -> |
122 | 65 | publishing { |
123 | 66 | publications { |
124 | 67 | release(MavenPublication) { |
| 68 | + from components.release |
| 69 | + |
125 | 70 | groupId GROUP |
126 | 71 | artifactId POM_ARTIFACT_ID |
127 | | - version project.release.versionName |
128 | | - artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") |
| 72 | + version android.defaultConfig.versionName |
| 73 | + |
129 | 74 | artifact androidSourcesJar |
130 | 75 | artifact androidJavadocsJar |
131 | 76 |
|
132 | 77 | pom.withXml { |
133 | 78 | asNode().appendNode('name', POM_NAME) |
134 | 79 | asNode().appendNode('description', POM_DESCRIPTION) |
135 | 80 | asNode().appendNode('url', POM_SCM_URL) |
136 | | - def dependenciesNode = asNode().appendNode('dependencies') |
137 | | - configurations.implementation.allDependencies.each { |
138 | | - // Ensure dependencies such as fileTree are not included. |
139 | | - if (it.name != 'unspecified') { |
140 | | - def dependencyNode = dependenciesNode.appendNode('dependency') |
141 | | - if (it.version != "unspecified") { |
142 | | - addDependency(dependencyNode, it.group, it.name, it.version) |
143 | | - } else { |
144 | | - addDependency(dependencyNode, it.getDependencyProject().findProperty("GROUP"), it.getDependencyProject().findProperty("POM_ARTIFACT_ID"), project.release.versionName) |
145 | | - } |
146 | | - } |
147 | | - } |
148 | 81 | asNode().children().last() + pomConfig |
149 | 82 | } |
150 | 83 | } |
151 | 84 | } |
| 85 | + |
| 86 | + repositories { |
| 87 | + maven { |
| 88 | + name = "sonatype" |
| 89 | + def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" |
| 90 | + def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" |
| 91 | + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl |
| 92 | + |
| 93 | + credentials { |
| 94 | + username getRepositoryUsername() |
| 95 | + password getRepositoryPassword() |
| 96 | + } |
| 97 | + } |
| 98 | + } |
152 | 99 | } |
| 100 | +} |
| 101 | + |
| 102 | +signing { |
| 103 | + sign publishing.publications |
153 | 104 | } |