@@ -35,38 +35,58 @@ tasks.register("latestDepTest")
3535
3636Project parent_project = project
3737subprojects { Project subProj ->
38- apply plugin : ' instrument'
39- apply plugin : ' muzzle'
40-
41- configurations {
42- instrumentPluginClasspath {
43- visible = false
44- canBeConsumed = false
45- canBeResolved = true
38+ subProj. pluginManager. withPlugin(" instrument" ) {
39+ // val kotlin = project.extensions.getByType(KotlinMultiplatformExtension::class.java)
40+ // target.extensions.configure<LibraryExtension> {
41+
42+ subProj. extensions. configure(InstrumentExtension ) {
43+ plugins = [
44+ ' datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin' ,
45+ ' datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin' ,
46+ ' datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin' ,
47+ ]
48+
49+ configurations {
50+ // TODO register or named
51+ instrumentPluginClasspath {
52+ visible = false
53+ canBeConsumed = false
54+ canBeResolved = true
55+ }
56+ }
57+
58+ dependencies {
59+ // TODO move to configuration configure, or maybe use addProvider
60+ instrumentPluginClasspath project(path : ' :dd-java-agent:agent-tooling' , configuration : ' instrumentPluginClasspath' )
61+ }
4662 }
4763 }
4864
49- instrument. plugins = [
50- ' datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin' ,
51- ' datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin' ,
52- ' datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin' ,
53- ]
65+ subProj. pluginManager. withPlugin(" muzzle" ) {
66+ // TODO named
67+ configurations. muzzleBootstrap {
68+ exclude group : ' org.snakeyaml' , module : ' snakeyaml-engine' // we vendor this in the agent jar
69+ }
70+ }
5471
5572 subProj. tasks. withType(Javadoc ). configureEach { enabled = false }
5673
74+ subprojects {
75+ apply plugin : ' instrument'
76+ apply plugin : ' muzzle'
77+ }
78+
5779 subProj. afterEvaluate {
5880 if (! plugins. hasPlugin(" java" )) {
5981 return
6082 }
6183 String jdkCompile = null
62- if (project. hasProperty(' minJavaVersionForTests' ) && project. getProperty (' minJavaVersionForTests' ) != JavaVersion . VERSION_1_8 ) {
63- def version = JavaVersion . toVersion(project. getProperty (' minJavaVersionForTests' ))
84+ if (project. hasProperty(' minJavaVersionForTests' ) && project. findProperty (' minJavaVersionForTests' ) != JavaVersion . VERSION_1_8 ) {
85+ def version = JavaVersion . toVersion(project. findProperty (' minJavaVersionForTests' ))
6486 def name = " java$version . majorVersion "
6587 jdkCompile = " main_${ name} Implementation"
6688 }
67- configurations. muzzleBootstrap {
68- exclude group : ' org.snakeyaml' , module : ' snakeyaml-engine' // we vendor this in the agent jar
69- }
89+
7090 dependencies {
7191 // Apply common dependencies for instrumentation.
7292 implementation project(' :dd-trace-api' )
@@ -92,8 +112,6 @@ subprojects { Project subProj ->
92112 testImplementation project(' :dd-java-agent:instrumentation-testing' )
93113 testAnnotationProcessor libs. autoservice. processor
94114 testCompileOnly libs. autoservice. annotation
95-
96- instrumentPluginClasspath project(path : ' :dd-java-agent:agent-tooling' , configuration : ' instrumentPluginClasspath' )
97115 }
98116
99117 subProj. tasks. withType(Test ). configureEach { subTask ->
@@ -105,7 +123,7 @@ subprojects { Project subProj ->
105123
106124 def path = subProj. getPath()
107125 subProj. plugins. withId(" java" ) {
108- if (! path. equals( ' :dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs' ) ) {
126+ if (path != ' :dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs' ) {
109127 // don't include the redis RequestImpl stub
110128 parent_project. dependencies {
111129 implementation project(path)
@@ -122,10 +140,8 @@ dependencies {
122140}
123141
124142if (project. gradle. startParameter. taskNames. any { it. endsWith(" generateMuzzleReport" ) }) {
125- apply plugin : ' muzzle'
126- task(" muzzleInstrumentationReport" ) {
127- dependsOn(project. getAllTasks(true ). values(). flatten(). findAll { it. name. endsWith(" generateMuzzleReport" ) })
128- finalizedBy(tasks. named(' mergeMuzzleReports' ))
143+ tasks. register(" muzzleInstrumentationReport" ) {
144+ dependsOn(providers. provider { subprojects. tasks. collect { it. named(" generateMuzzleReport" ) } })
129145 }
130146}
131147
@@ -141,44 +157,60 @@ tasks.named('shadowJar') {
141157 dependencies deps. excludeShared
142158}
143159
144- tasks. register(' generateInstrumenterIndex' , JavaExec ) {
160+ def generateInstrumenterIndex = tasks. register(' generateInstrumenterIndex' , JavaExec ) {
145161 // temporary config to add slf4j-simple so we get logging from instrumenters while indexing
146- def slf4jSimple = project. configurations. maybeCreate(' slf4j-simple' )
147- project. dependencies. add(' slf4j-simple' , " org.slf4j:slf4j-simple:${ libs.versions.slf4j.get()} " )
162+ def slf4jSimple = project. configurations. register(' slf4j-simple' ) {
163+ it. dependencies. add(project. dependencyFactory. create(" org.slf4j:slf4j-simple:${ libs.versions.slf4j.get()} " ))
164+ }
148165
149- def resourcesDir = " ${ sourceSets.main.output.resourcesDir} "
150- def indexFile = " ${ resourcesDir} /instrumenter.index"
166+ def destinationDir = project. layout. buildDirectory. dir(" generated/${ it.name} " )
151167
152- it. group = ' Build '
168+ it. group = LifecycleBasePlugin . BUILD_GROUP
153169 it. description = " Generate instrumenter.index"
154170 it. mainClass = ' datadog.trace.agent.tooling.InstrumenterIndex$IndexGenerator'
155- it. classpath = project. configurations. runtimeClasspath + slf4jSimple
171+ it. classpath = objects. fileCollection(). tap {
172+ it. from(project. configurations. named(" runtimeClasspath" ))
173+ it. from(slf4jSimple)
174+ }
156175 it. inputs. files(it. classpath)
157- it. outputs. files(indexFile)
158- it. args = [resourcesDir]
176+ it. outputs. dir(destinationDir)
177+ argumentProviders. add({
178+ [destinationDir. get()]
179+ })
159180
160181 dependsOn ' processResources'
161182}
183+ sourceSets. main. resources. srcDir(generateInstrumenterIndex)
162184
163- tasks. register(' generateKnownTypesIndex' , JavaExec ) {
185+
186+ def generateKnownTypesIndex = tasks. register(' generateKnownTypesIndex' , JavaExec ) {
164187 // temporary config to add slf4j-simple so we get logging from instrumenters while indexing
165- def slf4jSimple = project. configurations. maybeCreate(' slf4j-simple' )
166- project. dependencies. add(' slf4j-simple' , " org.slf4j:slf4j-simple:${ libs.versions.slf4j.get()} " )
188+ def slf4jSimple = project. configurations. register(' slf4j-simple' ) {
189+ it. dependencies. add(project. dependencyFactory. create(" org.slf4j:slf4j-simple:${ libs.versions.slf4j.get()} " ))
190+ }
167191
168- def resourcesDir = " ${ sourceSets.main.output.resourcesDir} "
169- def indexFile = " ${ resourcesDir} /known-types.index"
192+ def destinationDir = project. layout. buildDirectory. dir(" generated/${ it.name} " )
193+ // def resourcesDir = "${sourceSets.main.output.resourcesDir}"
194+ // def indexFile = "${resourcesDir}/known-types.index"
170195
171- it. group = ' Build '
196+ it. group = LifecycleBasePlugin . BUILD_GROUP
172197 it. description = " Generate known-types.index"
173198 it. mainClass = ' datadog.trace.agent.tooling.KnownTypesIndex$IndexGenerator'
174- it. classpath = project. configurations. runtimeClasspath + slf4jSimple
199+ it. classpath = objects. fileCollection(). tap {
200+ it. from(project. configurations. named(" runtimeClasspath" ))
201+ it. from(slf4jSimple)
202+ }
175203 it. inputs. files(it. classpath)
176- it. outputs. files(indexFile)
177- it. args = [resourcesDir]
204+ it. outputs. dir(destinationDir)
205+ argumentProviders. add({
206+ [destinationDir. get()]
207+ })
178208
179209 dependsOn ' processResources'
180210}
211+ sourceSets. main. resources. srcDir(generateKnownTypesIndex)
181212
182- tasks. named(" shadowJar" , ShadowJar ) {
183- dependsOn(' generateInstrumenterIndex' , ' generateKnownTypesIndex' )
184- }
213+
214+ // tasks.named("shadowJar", ShadowJar) {
215+ // dependsOn('generateInstrumenterIndex', 'generateKnownTypesIndex')
216+ // }
0 commit comments