Skip to content

Commit bded3bc

Browse files
chore: Move to using the Maven Publish DSL (#2815)
Co-authored-by: Tyler Roach <[email protected]>
1 parent 7636abe commit bded3bc

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ fun Project.configureAndroid() {
180180
)
181181
)
182182
}
183+
184+
publishing {
185+
singleVariant("release") {
186+
withSourcesJar()
187+
}
188+
}
183189
}
184190

185191
dependencies {

configuration/publishing.gradle

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,14 @@ def getRepositoryPassword() {
4242
}
4343

4444
afterEvaluate { project ->
45-
task androidSourcesJar(type: Jar) {
46-
classifier = 'sources'
47-
from android.sourceSets.main.java.source
48-
}
49-
50-
5145
publishing {
5246
publications {
5347
library(MavenPublication) {
5448
groupId POM_GROUP
5549
artifactId POM_ARTIFACT_ID
5650
version VERSION_NAME
5751

58-
artifact("${buildDir}/outputs/aar/${artifactId}-release.aar")
59-
if (project.getPlugins().hasPlugin('com.android.application') ||
60-
project.getPlugins().hasPlugin('com.android.library')) {
61-
artifact(androidSourcesJar)
62-
} else {
63-
artifact(sourcesJar)
64-
}
52+
from(components.named("release").get())
6553

6654
pom {
6755
name = POM_NAME
@@ -92,16 +80,12 @@ afterEvaluate { project ->
9280
}
9381

9482
withXml {
95-
def dependenciesNode = asNode().appendNode('dependencies')
96-
// Note that this only handles implementation
97-
// dependencies. In the future, may need to add api,
98-
// etc.
99-
configurations.implementation.allDependencies.each {
100-
def dependencyNode = dependenciesNode.appendNode('dependency')
101-
dependencyNode.appendNode('groupId', it.group)
102-
dependencyNode.appendNode('artifactId', it.name)
103-
dependencyNode.appendNode('version', it.version)
104-
}
83+
// Remove the scope information for all dependencies. This puts
84+
// everything at "compile" scope, which matches the way Amplify V2 has been
85+
// published historically. For v3 we should remove this and include the
86+
// scope information for our dependencies.
87+
def dependencies = asNode().get('dependencies').first()
88+
dependencies.each { it.remove(it.get('scope')) }
10589
}
10690
}
10791
}
@@ -128,4 +112,10 @@ afterEvaluate { project ->
128112
}
129113
sign publishing.publications.library
130114
}
115+
116+
// Turn off Gradle metadata. This is to maintain compatibility with the way Amplify V2 has
117+
// been published historically. For v3 we should remove this and publish the gradle metadata.
118+
tasks.withType(GenerateModuleMetadata).configureEach {
119+
enabled = false
120+
}
131121
}

0 commit comments

Comments
 (0)