1414 * limitations under the License.
1515 */
1616
17- apply plugin : ' maven'
17+ apply plugin : ' maven-publish '
1818apply plugin : ' signing'
1919
2020def isReleaseBuild () {
@@ -39,66 +39,64 @@ def getRepositoryPassword() {
3939 return hasProperty(' NEXUS_PASSWORD' ) ? NEXUS_PASSWORD : " "
4040}
4141
42- afterEvaluate { project ->
43- uploadArchives {
44- repositories {
45- mavenDeployer {
46- beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
47-
48- pom. groupId = GROUP
49- pom. artifactId = POM_ARTIFACT_ID
50- pom. version = VERSION_NAME
42+ task androidSourcesJar (type : Jar ) {
43+ archiveClassifier = ' sources'
44+ from android. sourceSets. main. java. srcDirs
45+ }
5146
52- repository(url : getReleaseRepositoryUrl()) {
53- authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
47+ publishing {
48+ publications {
49+ release(MavenPublication ) {
50+ groupId = GROUP
51+ artifactId = POM_ARTIFACT_ID
52+ version = VERSION_NAME
53+
54+ artifact tasks. androidSourcesJar
55+
56+ pom {
57+ name = POM_NAME
58+ packaging = POM_PACKAGING
59+ description = POM_DESCRIPTION
60+ url = POM_URL
61+
62+ scm {
63+ url = POM_SCM_URL
64+ connection = POM_SCM_CONNECTION
65+ developerConnection = POM_SCM_DEV_CONNECTION
5466 }
55- snapshotRepository(url : getSnapshotRepositoryUrl()) {
56- authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
57- }
58-
59- pom. project {
60- name POM_NAME
61- packaging POM_PACKAGING
62- description POM_DESCRIPTION
63- url POM_URL
6467
65- scm {
66- url POM_SCM_URL
67- connection POM_SCM_CONNECTION
68- developerConnection POM_SCM_DEV_CONNECTION
69- }
70-
71- licenses {
72- license {
73- name POM_LICENCE_NAME
74- url POM_LICENCE_URL
75- distribution POM_LICENCE_DIST
76- }
68+ licenses {
69+ license {
70+ name = POM_LICENCE_NAME
71+ url = POM_LICENCE_URL
72+ distribution = POM_LICENCE_DIST
7773 }
74+ }
7875
79- developers {
80- developer {
81- id POM_DEVELOPER_ID
82- name POM_DEVELOPER_NAME
83- }
76+ developers {
77+ developer {
78+ id = POM_DEVELOPER_ID
79+ name = POM_DEVELOPER_NAME
8480 }
8581 }
8682 }
8783 }
8884 }
89-
90- signing {
91- required { isReleaseBuild() && gradle. taskGraph. hasTask(" uploadArchives" ) }
92- sign configurations. archives
93- }
94-
95-
96- task androidSourcesJar(type : Jar ) {
97- archiveClassifier. set(" sources" )
98- from android. sourceSets. main. java. sourceFiles
85+
86+ repositories {
87+ maven {
88+ def releasesRepoUrl = getReleaseRepositoryUrl()
89+ def snapshotsRepoUrl = getSnapshotRepositoryUrl()
90+ url = isReleaseBuild() ? releasesRepoUrl : snapshotsRepoUrl
91+ credentials {
92+ username = getRepositoryUsername()
93+ password = getRepositoryPassword()
94+ }
95+ }
9996 }
97+ }
10098
101- artifacts {
102- archives androidSourcesJar
103- }
99+ signing {
100+ required { isReleaseBuild() && gradle . taskGraph . hasTask( " publish " ) }
101+ sign publishing . publications . release
104102}
0 commit comments