Skip to content

Commit e3b25eb

Browse files
committed
chore: Rework INSTRUMENT_PLUGIN_CLASSPATH_CONFIGURATION registration and configuration
1 parent dacb461 commit e3b25eb

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

buildSrc/src/main/groovy/InstrumentPlugin.groovy

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class InstrumentPlugin implements Plugin<Project> {
3737
@Override
3838
void apply(Project project) {
3939
InstrumentExtension extension = project.extensions.create('instrument', InstrumentExtension)
40+
project.configurations.register(INSTRUMENT_PLUGIN_CLASSPATH_CONFIGURATION)
4041

4142
project.pluginManager.withPlugin("java") { configurePostCompilationInstrumentation("java", project, extension) }
4243
project.pluginManager.withPlugin("kotlin") { configurePostCompilationInstrumentation("kotlin", project, extension) }
@@ -68,21 +69,12 @@ class InstrumentPlugin implements Plugin<Project> {
6869
// - compileKotlin,
6970
// - compileScala,
7071
// - compileGroovy,
71-
def compileTasks = project.tasks.withType(AbstractCompile).matching {
72+
project.tasks.withType(AbstractCompile).matching {
7273
it.name == compileTaskName && !it.source.isEmpty()
73-
}
74-
75-
// TODO eager config
76-
project.configurations.configureEach { config ->
77-
if (config.name == INSTRUMENT_PLUGIN_CLASSPATH_CONFIGURATION) {
78-
logger.info('[InstrumentPlugin] instrumentPluginClasspath configuration was created')
79-
compileTasks.configureEach {
80-
it.inputs.files(config)
81-
}
82-
}
83-
}
74+
}.configureEach {
75+
logger.info('[InstrumentPlugin] Applying instrumentPluginClasspath configuration as compile task input')
76+
it.inputs.files(project.configurations.named(INSTRUMENT_PLUGIN_CLASSPATH_CONFIGURATION))
8477

85-
compileTasks.configureEach {
8678
if (it.source.isEmpty()) {
8779
logger.debug("[InstrumentPlugin] Skipping $compileTaskName for source set $sourceSetName as it has no source files")
8880
return
@@ -192,8 +184,7 @@ abstract class InstrumentPostProcessingAction implements Action<AbstractCompile>
192184
workQueue().submit(InstrumentAction.class, parameters -> {
193185
parameters.buildStartedTime.set(invocationDetails.buildStartedTime)
194186
parameters.pluginClassPath.from(
195-
project.configurations.findByName(InstrumentPlugin.INSTRUMENT_PLUGIN_CLASSPATH_CONFIGURATION)
196-
?: project.files()
187+
project.configurations.named(InstrumentPlugin.INSTRUMENT_PLUGIN_CLASSPATH_CONFIGURATION)
197188
)
198189
parameters.plugins.set(postCompileAction.plugins)
199190
parameters.instrumentingClassPath.setFrom(postCompileAction.instrumentingClassPath)

dd-java-agent/instrumentation/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ subprojects { Project subProj ->
2323
)
2424
}
2525

26-
subProj.configurations.register("instrumentPluginClasspath") {
26+
subProj.configurations.named('instrumentPluginClasspath') {
2727
it.visible = false
2828
it.canBeConsumed = false
2929
it.canBeResolved = true
3030

31-
it.dependencies.add(subProj.dependencies.project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath'))
31+
it.dependencies.add(subProj.dependencies.project(
32+
path: ':dd-java-agent:agent-tooling',
33+
configuration: 'instrumentPluginClasspath'
34+
))
3235
}
3336
}
3437

0 commit comments

Comments
 (0)