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,60 @@ 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
51-
52- repository(url : getReleaseRepositoryUrl()) {
53- authentication(userName : getRepositoryUsername(), password : getRepositoryPassword())
54- }
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
42+ afterEvaluate {
43+ publishing {
44+ publications {
45+ release(MavenPublication ) {
46+ from components. release
47+ groupId = GROUP
48+ artifactId = POM_ARTIFACT_ID
49+ version = VERSION_NAME
50+
51+ pom {
52+ name = POM_NAME
53+ packaging = POM_PACKAGING
54+ description = POM_DESCRIPTION
55+ url = POM_URL
6456
6557 scm {
66- url POM_SCM_URL
67- connection POM_SCM_CONNECTION
68- developerConnection POM_SCM_DEV_CONNECTION
58+ url = POM_SCM_URL
59+ connection = POM_SCM_CONNECTION
60+ developerConnection = POM_SCM_DEV_CONNECTION
6961 }
7062
7163 licenses {
7264 license {
73- name POM_LICENCE_NAME
74- url POM_LICENCE_URL
75- distribution POM_LICENCE_DIST
65+ name = POM_LICENCE_NAME
66+ url = POM_LICENCE_URL
67+ distribution = POM_LICENCE_DIST
7668 }
7769 }
7870
7971 developers {
8072 developer {
81- id POM_DEVELOPER_ID
82- name POM_DEVELOPER_NAME
73+ id = POM_DEVELOPER_ID
74+ name = POM_DEVELOPER_NAME
8375 }
8476 }
8577 }
8678 }
8779 }
80+
81+ repositories {
82+ maven {
83+ def releasesRepoUrl = getReleaseRepositoryUrl()
84+ def snapshotsRepoUrl = getSnapshotRepositoryUrl()
85+ url = isReleaseBuild() ? releasesRepoUrl : snapshotsRepoUrl
86+ credentials {
87+ username = getRepositoryUsername()
88+ password = getRepositoryPassword()
89+ }
90+ }
91+ }
8892 }
93+ }
8994
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
99- }
100-
101- artifacts {
102- archives androidSourcesJar
103- }
95+ signing {
96+ required { isReleaseBuild() && gradle. taskGraph. hasTask(" publish" ) }
97+ sign publishing. publications. release
10498}
0 commit comments