@@ -65,16 +65,16 @@ apply from: "$rootDir/gradle/java.gradle"
6565
6666sourceSets {
6767 main_jetty904 {
68- java. srcDirs " ${ project. projectDir} /src/main/java_jetty904"
68+ java. srcDirs " ${ projectDir} /src/main/java_jetty904"
6969 }
7070 main_jetty93 {
71- java. srcDirs " ${ project. projectDir} /src/main/java_jetty93"
71+ java. srcDirs " ${ projectDir} /src/main/java_jetty93"
7272 }
7373 main_jetty9421 {
74- java. srcDirs " ${ project. projectDir} /src/main/java_jetty9421"
74+ java. srcDirs " ${ projectDir} /src/main/java_jetty9421"
7575 }
7676 main_jetty10 {
77- java. srcDirs " ${ project. projectDir} /src/main/java_jetty10"
77+ java. srcDirs " ${ projectDir} /src/main/java_jetty10"
7878 }
7979}
8080
@@ -85,22 +85,57 @@ jar {
8585 from sourceSets. main_jetty10. output
8686}
8787
88- [' main_jetty904' , ' main_jetty93' , ' main_jetty9421' , ' main_jetty10' ]. each { String sourceSet ->
89- tasks. named(" compile${ sourceSet.capitalize()} Java" , JavaCompile ) {
90- it. dependsOn tasks. named(' compileJava' )
91- // the instrumenters are in main, but helpers/advice in possibly other sourceSets
92- // The muzzle generator of references run as part of InstrumentJava needs access to
93- // these extra classes. The task dependencies for instrumentJava are added above
94- instrument. additionalClasspath. add(it. destinationDirectory)
88+ def mainSourceSet = sourceSets. named(SourceSet . MAIN_SOURCE_SET_NAME )
89+ def mainCompileOnlyConfiguration = mainSourceSet
90+ .map {configurations. named(it. compileOnlyConfigurationName). get() }
91+ sourceSets. configureEach { sourceSet ->
92+ if (sourceSet. name == SourceSet . MAIN_SOURCE_SET_NAME ) {
93+ return
9594 }
9695
96+ sourceSet. compileClasspath + = mainSourceSet. get(). output
97+
98+ def compileOnlyConfigurationName = sourceSet. compileOnlyConfigurationName
99+ configurations. configureEach {
100+ if (it. name == compileOnlyConfigurationName) {
101+ logger. debug(" Configuring $it . name to extend from main compileOnly" )
102+ it. extendsFrom(mainCompileOnlyConfiguration. get())
103+ }
104+ }
105+
106+ // def compileTask = sourceSet.getCompileTaskName("java")
107+ // tasks.named(compileTask, JavaCompile) {
108+ // it.dependsOn tasks.named('compileJava')
109+ // // the instrumenters are in main, but helpers/advice in possibly other sourceSets
110+ // // The muzzle generator of references run as part of InstrumentJava needs access to
111+ // // these extra classes. The task dependencies for instrumentJava are added above
112+ // instrument.additionalClasspath.add(it.destinationDirectory)
113+ // }
114+
97115 project. afterEvaluate {
98- tasks. named(" forbiddenApis${ sourceSet.capitalize()} " ) {
99- it. dependsOn(" compile${ sourceSet.capitalize()} Java" )
116+ tasks. named(" forbiddenApis${ sourceSet.name. capitalize()} " ) {
117+ it. dependsOn(" compile${ sourceSet.name. capitalize()} Java" )
100118 }
101119 }
102120}
103121
122+ // ['main_jetty904', 'main_jetty93', 'main_jetty9421', 'main_jetty10'].each { String sourceSet ->
123+ // tasks.named("compile${sourceSet.capitalize()}Java", JavaCompile) {
124+ // it.dependsOn tasks.named('compileJava')
125+ // // the instrumenters are in main, but helpers/advice in possibly other sourceSets
126+ // // The muzzle generator of references run as part of InstrumentJava needs access to
127+ // // these extra classes. The task dependencies for instrumentJava are added above
128+ // instrument.additionalClasspath.add(it.destinationDirectory)
129+ // }
130+ //
131+ // project.afterEvaluate {
132+ // tasks.named("forbiddenApis${sourceSet.capitalize()}") {
133+ // it.dependsOn("compile${sourceSet.capitalize()}Java")
134+ // }
135+ // }
136+ // }
137+
138+
104139tasks. named(' compileMain_jetty10Java' ). configure {
105140 setJavaVersion(it, 11 )
106141}
@@ -131,33 +166,33 @@ dependencies {
131166 // intermediation of the InstrumentPlugin, creating a circular
132167 // dependency (the instrument plugin needs all the sourceSets
133168 // compiled to properly generate References)
134- main_jetty904CompileOnly files(" $project . buildDir /classes/java/raw" )
169+ // main_jetty904CompileOnly files("$project.buildDir/classes/java/raw")
135170
136171 main_jetty93CompileOnly group : ' org.eclipse.jetty' , name : ' jetty-server' , version : ' 9.3.0.v20150612'
137172 main_jetty93CompileOnly project(' :internal-api' )
138173 main_jetty93CompileOnly project(' :dd-java-agent:agent-tooling' )
139174 main_jetty93CompileOnly project(' :dd-java-agent:agent-bootstrap' )
140- main_jetty93CompileOnly files(" $project . buildDir /classes/java/raw" ) {
141- builtBy = [' compileJava' ]
142- }
175+ // main_jetty93CompileOnly files("$project.buildDir/classes/java/raw") {
176+ // builtBy = ['compileJava']
177+ // }
143178
144179 main_jetty9421CompileOnly group : ' org.eclipse.jetty' , name : ' jetty-server' , version : ' 9.4.21.v20190926'
145180 main_jetty9421CompileOnly project(' :internal-api' )
146181 main_jetty9421CompileOnly project(' :dd-java-agent:agent-tooling' )
147182 main_jetty9421CompileOnly project(' :dd-java-agent:agent-bootstrap' )
148- main_jetty9421CompileOnly files(" $project . buildDir /classes/java/raw" ) {
149- builtBy = [' compileJava' ]
150- }
183+ // main_jetty9421CompileOnly files("$project.buildDir/classes/java/raw") {
184+ // builtBy = ['compileJava']
185+ // }
151186
152187 main_jetty10CompileOnly group : ' org.eclipse.jetty' , name : ' jetty-server' , version : ' 10.0.0'
153188
154189 main_jetty10CompileOnly project(' :internal-api' )
155190 main_jetty10CompileOnly project(' :dd-java-agent:agent-tooling' )
156191 main_jetty10CompileOnly project(' :dd-java-agent:agent-bootstrap' )
157192 main_jetty10Implementation project(' :dd-java-agent:instrumentation:jetty-common' )
158- main_jetty10CompileOnly files(" $project . buildDir /classes/java/raw" ) {
159- builtBy = [' compileJava' ]
160- }
193+ // main_jetty10CompileOnly files("$project.buildDir/classes/java/raw") {
194+ // builtBy = ['compileJava']
195+ // }
161196
162197 testFixturesImplementation(project(' :dd-java-agent:testing' )) {
163198 exclude group : ' org.eclipse.jetty' , module : ' jetty-server'
@@ -213,6 +248,8 @@ dependencies {
213248 latestDepTestImplementation project(' :dd-java-agent:instrumentation:jetty-appsec-9.3' )
214249 latestDepTestImplementation testFixtures(project(' :dd-java-agent:instrumentation:servlet:request-3' ))
215250}
216- configurations. getByName(' latestDepForkedTestRuntimeClasspath' ). resolutionStrategy {
217- force libs. slf4j
251+ configurations. named(' latestDepForkedTestRuntimeClasspath' ). configure {
252+ it. resolutionStrategy {
253+ force libs. slf4j
254+ }
218255}
0 commit comments