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,68 @@ 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+ // For AGP 8.x, we directly specify the artifacts
52+ artifact bundleReleaseAar
53+ artifact androidSourcesJar
54+
55+ groupId = GROUP
56+ artifactId = POM_ARTIFACT_ID
57+ version = VERSION_NAME
58+
59+ pom {
60+ name = POM_NAME
61+ packaging = POM_PACKAGING
62+ description = POM_DESCRIPTION
63+ url = POM_URL
6464
6565 scm {
66- url POM_SCM_URL
67- connection POM_SCM_CONNECTION
68- developerConnection POM_SCM_DEV_CONNECTION
66+ url = POM_SCM_URL
67+ connection = POM_SCM_CONNECTION
68+ developerConnection = POM_SCM_DEV_CONNECTION
6969 }
7070
7171 licenses {
7272 license {
73- name POM_LICENCE_NAME
74- url POM_LICENCE_URL
75- distribution POM_LICENCE_DIST
73+ name = POM_LICENCE_NAME
74+ url = POM_LICENCE_URL
75+ distribution = POM_LICENCE_DIST
7676 }
7777 }
7878
7979 developers {
8080 developer {
81- id POM_DEVELOPER_ID
82- name POM_DEVELOPER_NAME
81+ id = POM_DEVELOPER_ID
82+ name = POM_DEVELOPER_NAME
8383 }
8484 }
8585 }
8686 }
8787 }
88+
89+ repositories {
90+ maven {
91+ def releasesRepoUrl = getReleaseRepositoryUrl()
92+ def snapshotsRepoUrl = getSnapshotRepositoryUrl()
93+ url = isReleaseBuild() ? releasesRepoUrl : snapshotsRepoUrl
94+ credentials {
95+ username = getRepositoryUsername()
96+ password = getRepositoryPassword()
97+ }
98+ }
99+ }
88100 }
89-
101+
90102 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+ required { isReleaseBuild() && gradle. taskGraph. hasTask(" publish" ) }
104+ sign publishing. publications. release
103105 }
104106}
0 commit comments