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,63 @@ 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- }
42+ task androidSourcesJar (type : Jar ) {
43+ archiveClassifier = ' sources'
44+ from android. sourceSets. main. java. srcDirs
45+ }
5846
59- pom. project {
60- name POM_NAME
61- packaging POM_PACKAGING
62- description POM_DESCRIPTION
63- url POM_URL
47+ afterEvaluate {
48+ publishing {
49+ publications {
50+ release(MavenPublication ) {
51+ from components. default
52+ groupId = GROUP
53+ artifactId = POM_ARTIFACT_ID
54+ version = VERSION_NAME
55+
56+ pom {
57+ name = POM_NAME
58+ packaging = POM_PACKAGING
59+ description = POM_DESCRIPTION
60+ url = POM_URL
6461
6562 scm {
66- url POM_SCM_URL
67- connection POM_SCM_CONNECTION
68- developerConnection POM_SCM_DEV_CONNECTION
63+ url = POM_SCM_URL
64+ connection = POM_SCM_CONNECTION
65+ developerConnection = POM_SCM_DEV_CONNECTION
6966 }
7067
7168 licenses {
7269 license {
73- name POM_LICENCE_NAME
74- url POM_LICENCE_URL
75- distribution POM_LICENCE_DIST
70+ name = POM_LICENCE_NAME
71+ url = POM_LICENCE_URL
72+ distribution = POM_LICENCE_DIST
7673 }
7774 }
7875
7976 developers {
8077 developer {
81- id POM_DEVELOPER_ID
82- name POM_DEVELOPER_NAME
78+ id = POM_DEVELOPER_ID
79+ name = POM_DEVELOPER_NAME
8380 }
8481 }
8582 }
8683 }
8784 }
85+ repositories {
86+ maven {
87+ def releasesRepoUrl = getReleaseRepositoryUrl()
88+ def snapshotsRepoUrl = getSnapshotRepositoryUrl()
89+ url = isReleaseBuild() ? releasesRepoUrl : snapshotsRepoUrl
90+ credentials {
91+ username = getRepositoryUsername()
92+ password = getRepositoryPassword()
93+ }
94+ }
95+ }
8896 }
89-
9097 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
98+ required { isReleaseBuild() && gradle. taskGraph. hasTask(" publish" ) }
99+ sign publishing. publications. release
103100 }
104101}
0 commit comments