@@ -3,23 +3,18 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
33plugins {
44 id(" ai.java-conventions" )
55 id(" ai.shadow-conventions" )
6- id(" maven- publish" )
6+ id(" ai. publish-conventions " )
77}
88
99base.archivesName.set(" applicationinsights-agent" )
1010
11- java {
12- withJavadocJar()
13- withSourcesJar()
14- }
15-
1611// this configuration collects libs that will be placed in the bootstrap classloader
17- val bootstrapLibs: Configuration by configurations.creating {
12+ val bootstrapLibs by configurations.creating {
1813 isCanBeResolved = true
1914 isCanBeConsumed = false
2015}
2116// this configuration collects libs that will be placed in the agent classloader, isolated from the instrumented application code
22- val javaagentLibs: Configuration by configurations.creating {
17+ val javaagentLibs by configurations.creating {
2318 isCanBeResolved = true
2419 isCanBeConsumed = false
2520}
@@ -57,10 +52,6 @@ project(":agent:instrumentation").subprojects {
5752}
5853
5954tasks {
60- jar {
61- enabled = false
62- }
63-
6455 // building the final javaagent jar is done in 3 steps:
6556
6657 // 1. all distro-specific javaagent libs are relocated (by the ai.shadow-conventions plugin)
@@ -103,79 +94,46 @@ tasks {
10394 dependsOn(isolateJavaagentLibs)
10495 from(isolateJavaagentLibs.get().outputs)
10596
106- archiveClassifier.set(" all" )
107-
10897 duplicatesStrategy = DuplicatesStrategy .EXCLUDE
10998
99+ archiveClassifier.set(" " )
100+
110101 manifest {
102+ attributes(jar.get().manifest.attributes)
111103 attributes(
112- mapOf (
113- " Premain-Class" to " com.microsoft.applicationinsights.agent.Agent" ,
114- // Agent-Class is provided only for dynamic attach in the first line of main
115- // there are many problematic edge cases around dynamic attach any later than that
116- " Agent-Class" to " com.microsoft.applicationinsights.agent.Agent" ,
117- " Can-Redefine-Classes" to true ,
118- " Can-Retransform-Classes" to true
119- )
104+ " Agent-Class" to " com.microsoft.applicationinsights.agent.Agent" ,
105+ " Premain-Class" to " com.microsoft.applicationinsights.agent.Agent" ,
106+ " Can-Redefine-Classes" to true ,
107+ " Can-Retransform-Classes" to true
120108 )
121109 }
122110 }
123111
124- // a separate task to create a no-classifier jar that's exactly the same as the -all one
125- // because a no-classifier (main) jar is required by sonatype
126- val mainShadowJar by registering(Jar ::class ) {
127- archiveClassifier.set(" " )
128-
129- from(zipTree(shadowJar.get().archiveFile))
130-
131- manifest {
132- attributes(shadowJar.get().manifest.attributes)
133- }
112+ jar {
113+ // Empty jar that cannot be used for anything and isn't published.
114+ archiveClassifier.set(" dontuse" )
134115 }
135116
136117 assemble {
137- dependsOn(shadowJar, mainShadowJar )
118+ dependsOn(shadowJar)
138119 }
139120
140- val t = this
141- publishing {
142- publications {
143- register<MavenPublication >(" maven" ) {
144- artifactId = " applicationinsights-agent"
145- groupId = " com.microsoft.azure"
146- version = project.version.toString()
147-
148- artifact(shadowJar)
149- artifact(mainShadowJar)
150- artifact(t.named(" sourcesJar" ))
151- artifact(t.named(" javadocJar" ))
152-
153- pom {
154- name.set(" Microsoft Application Insights Java Agent" )
155- description.set(" Microsoft Application Insights Java Agent" )
156- url.set(" https://github.com/Microsoft/ApplicationInsights-Java" )
157- packaging = " jar"
158-
159- licenses {
160- license {
161- name.set(" MIT License" )
162- url.set(" http://www.opensource.org/licenses/mit-license.php" )
163- }
164- }
165-
166- developers {
167- developer {
168- id.set(" Microsoft" )
169- name.set(" Microsoft" )
170- }
171- }
172-
173- scm {
174- connection.set(" scm:git:git://github.com/Microsoft/ApplicationInsights-Java.git" )
175- url.set(" scm:git:https://github.com/Microsoft/ApplicationInsights-Java" )
176- }
177- }
178- }
121+ // Because we reconfigure publishing to only include the shadow jar, the Gradle metadata is not correct.
122+ // Since we are fully bundled and have no dependencies, Gradle metadata wouldn't provide any advantage over
123+ // the POM anyways so in practice we shouldn't be losing anything.
124+ withType<GenerateModuleMetadata >().configureEach {
125+ enabled = false
126+ }
127+ }
128+
129+ // Don't publish non-shadowed jar (shadowJar is in shadowRuntimeElements)
130+ with (components[" java" ] as AdhocComponentWithVariants ) {
131+ configurations.forEach {
132+ withVariantsFromConfiguration(configurations[" apiElements" ]) {
133+ skip()
134+ }
135+ withVariantsFromConfiguration(configurations[" runtimeElements" ]) {
136+ skip()
179137 }
180138 }
181139}
0 commit comments