@@ -7,84 +7,27 @@ plugins {
7
7
id(" signing" )
8
8
}
9
9
10
- android {
11
- lint {
12
- warningsAsErrors = true
13
- // A newer version of androidx.appcompat:appcompat than 1.3.1 is available: 1.4.1 [GradleDependency]
14
- // we rely on dependabot for dependency updates
15
- disable.add(" GradleDependency" )
16
- }
10
+ android.lint {
11
+ warningsAsErrors = true
12
+ // A newer version of androidx.appcompat:appcompat than 1.3.1 is available: 1.4.1 [GradleDependency]
13
+ // we rely on dependabot for dependency updates
14
+ disable.add(" GradleDependency" )
17
15
}
18
16
19
- publishing {
20
- repositories {
21
- maven {
22
- val releasesRepoUrl = URI (" https://oss.sonatype.org/service/local/staging/deploy/maven2" )
23
- val snapshotsRepoUrl = URI (" https://oss.sonatype.org/content/repositories/snapshots/" )
24
- url = if (project.findProperty(" release" ) == " true" ) releasesRepoUrl else snapshotsRepoUrl
25
- credentials {
26
- username = findProperty(" mavenCentralUsername" ) as String?
27
- password = findProperty(" mavenCentralPassword" ) as String?
28
- }
29
- }
30
- }
31
- publications {
32
- register<MavenPublication >(" maven" ) {
33
- groupId = " com.splunk"
34
- artifactId = base.archivesName.get()
17
+ val isARelease = project.hasProperty(" release" ) && project.property(" release" ) == " true"
18
+ val variantToPublish = " release"
35
19
36
- afterEvaluate {
37
- pom.name.set(" ${project.extra[" pomName" ]} " )
38
- pom.description.set(project.description)
39
- }
40
-
41
- pom {
42
- url.set(" https://github.com/signalfx/splunk-otel-android" )
43
- licenses {
44
- license {
45
- name.set(" The Apache License, Version 2.0" )
46
- url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
47
- }
48
- }
49
- developers {
50
- developer {
51
- id.set(" splunk" )
52
- name.set(" Splunk Instrumentation Authors" )
53
-
54
- organization.set(" Splunk" )
55
- organizationUrl.set(" https://www.splunk.com" )
56
- }
57
- }
58
- scm {
59
- connection.set(" https://github.com/signalfx/splunk-otel-android.git" )
60
- developerConnection.set(" https://github.com/signalfx/splunk-otel-android.git" )
61
- url.set(" https://github.com/signalfx/splunk-otel-android" )
62
- }
63
- }
20
+ android.publishing {
21
+ singleVariant(variantToPublish) {
22
+ // Adding sources and javadoc artifacts only during a release.
23
+ if (isARelease) {
24
+ withJavadocJar()
25
+ withSourcesJar()
64
26
}
65
27
}
66
28
}
67
29
68
- if (project.findProperty(" release" ) == " true" ) {
69
- signing {
70
- useGpgCmd()
71
- val signingKey: String? by project
72
- val signingPassword: String? by project
73
- useInMemoryPgpKeys(signingKey, signingPassword)
74
- sign(publishing.publications[" maven" ])
75
- }
76
- }
77
-
78
- val sourcesJar by tasks.registering(Jar ::class ) {
79
-
80
- from(android.sourceSets.named(" main" ).get().java.srcDirs)
81
- archiveClassifier.set(" sources" )
82
- }
83
-
84
- project.afterEvaluate {
85
-
86
- // note: we need to declare this here in afterEvaluate because the android plugin doesn't
87
- // resolve dependencies early enough to make the libraryVariants hack work until here.
30
+ afterEvaluate {
88
31
val javadoc by tasks.registering(Javadoc ::class ) {
89
32
source = android.sourceSets.named(" main" ).get().java.getSourceFiles()
90
33
classpath + = project.files(android.bootClasspath)
@@ -100,21 +43,62 @@ project.afterEvaluate {
100
43
addBooleanOption(" Xdoclint:all,-missing" , true )
101
44
}
102
45
}
103
-
104
- val javadocJar by tasks.registering(Jar ::class ) {
105
- dependsOn(javadoc)
106
- archiveClassifier.set(" javadoc" )
107
- from(javadoc.get().destinationDir)
108
- }
109
-
110
- val component = project.components.findByName(" release" )
111
46
publishing {
47
+ repositories {
48
+ maven {
49
+ val releasesRepoUrl = URI (" https://oss.sonatype.org/service/local/staging/deploy/maven2" )
50
+ val snapshotsRepoUrl = URI (" https://oss.sonatype.org/content/repositories/snapshots/" )
51
+ url = if (project.findProperty(" release" ) == " true" ) releasesRepoUrl else snapshotsRepoUrl
52
+ credentials {
53
+ username = findProperty(" mavenCentralUsername" ) as String?
54
+ password = findProperty(" mavenCentralPassword" ) as String?
55
+ }
56
+ }
57
+ }
112
58
publications {
113
- named<MavenPublication >(" maven" ) {
114
- from(component)
115
- artifact(tasks.named<Jar >(" sourcesJar" ))
116
- artifact(javadocJar)
59
+ create<MavenPublication >(" maven" ) {
60
+ from(components.findByName(variantToPublish))
61
+ groupId = " com.splunk"
62
+ artifactId = base.archivesName.get()
63
+
64
+ afterEvaluate {
65
+ pom.name.set(" ${project.extra[" pomName" ]} " )
66
+ pom.description.set(project.description)
67
+ }
68
+
69
+ pom {
70
+ url.set(" https://github.com/signalfx/splunk-otel-android" )
71
+ licenses {
72
+ license {
73
+ name.set(" The Apache License, Version 2.0" )
74
+ url.set(" http://www.apache.org/licenses/LICENSE-2.0.txt" )
75
+ }
76
+ }
77
+ developers {
78
+ developer {
79
+ id.set(" splunk" )
80
+ name.set(" Splunk Instrumentation Authors" )
81
+
82
+ organization.set(" Splunk" )
83
+ organizationUrl.set(" https://www.splunk.com" )
84
+ }
85
+ }
86
+ scm {
87
+ connection.set(" https://github.com/signalfx/splunk-otel-android.git" )
88
+ developerConnection.set(" https://github.com/signalfx/splunk-otel-android.git" )
89
+ url.set(" https://github.com/signalfx/splunk-otel-android" )
90
+ }
91
+ }
117
92
}
118
93
}
119
94
}
95
+ if (isARelease && project.findProperty(" skipSigning" ) != " true" ) {
96
+ signing {
97
+ useGpgCmd()
98
+ val signingKey: String? by project
99
+ val signingPassword: String? by project
100
+ useInMemoryPgpKeys(signingKey, signingPassword)
101
+ sign(publishing.publications[" maven" ])
102
+ }
103
+ }
120
104
}
0 commit comments