Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0ebc011
chore: Move CSI plugin to it's own package
bric3 Nov 14, 2025
6cedb81
chore: Tweak some API to use kotlin friendly functions
bric3 Nov 14, 2025
8ebb511
fix: Restrict default CSI classpath to main and test, compile and run…
bric3 Nov 14, 2025
aa35af4
chore: arg name rename
bric3 Nov 14, 2025
d472a9e
fix: Include the main source set output
bric3 Nov 16, 2025
e1ec9b5
fix: Always make sure java plugin is applied
bric3 Nov 17, 2025
f11ea17
chore: Make csi plugin not running in project.afterEvaluate
bric3 Nov 17, 2025
b0b8121
fix: Incorrect URLClassLoader initialization when url is a directory
bric3 Nov 17, 2025
79c9526
fix: Make depends on instrument task
bric3 Nov 17, 2025
6a373c9
chore: Refactor additional configurations to a `ConfigurableFileColle…
bric3 Nov 17, 2025
9bddc7f
fix: extension property should not be queried at configuration time
bric3 Nov 17, 2025
207d849
style: Reformat
bric3 Nov 17, 2025
eda1af3
fix: call site plugin still has to add entries to classpath after jvm…
bric3 Nov 19, 2025
c189714
chore: code tweaks
bric3 Nov 19, 2025
f2f5205
fix: generateCallSite was missing a few input properties for up-date …
bric3 Nov 19, 2025
3aebe10
fix: csi plugin was patching test compile and test task classpath
bric3 Nov 19, 2025
b5ef0ba
fix: unnecessary targetFolder directory creation and unnecessary tran…
bric3 Nov 19, 2025
dea2a7c
chore: Readability of CallSiteUtils::toURL
bric3 Nov 19, 2025
5c32a8c
typo: inout property type
bric3 Nov 20, 2025
c84d247
fix: Exclude Kotlin compiler daemon files
bric3 Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ mise*.local.toml
.config/mise*.toml
# asdf
.tool-versions

# Exclude kotlin build files
.kotlin
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gradlePlugin {
}
create("call-site-instrumentation-plugin") {
id = "call-site-instrumentation"
implementationClass = "datadog.gradle.plugin.CallSiteInstrumentationPlugin"
implementationClass = "datadog.gradle.plugin.csi.CallSiteInstrumentationPlugin"
}
create("tracer-version-plugin") {
id = "datadog.tracer-version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -47,7 +48,20 @@ public static String repeat(final char value, int count) {

public static URL toURL(final Path path) {
try {
return path.toUri().toURL();
URL url = path.toUri().toURL();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

// URLClassLoader interprets URLs ending with '/' as directories. If the trailing '/' is
// missing, a directory URL is treated as a JAR. If the path does yet exist on disk
// assumes that paths not ending with ".jar" are directories.
boolean shouldAddSlash =
Files.exists(path) ? Files.isDirectory(path) : !path.toString().endsWith(".jar");

if (shouldAddSlash) {
String urlString = url.toString();
if (!urlString.endsWith("/")) {
url = new URL(urlString + "/");
}
}
return url;
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
Expand Down

This file was deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted from datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt‎

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package datadog.gradle.plugin.csi

import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.ProjectLayout
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.listProperty
import org.gradle.kotlin.dsl.property
import java.io.File
import javax.inject.Inject


/**
* This extension allows to configure the Call Site Instrumenter plugin execution.
*/
abstract class CallSiteInstrumentationExtension @Inject constructor(
objectFactory: ObjectFactory,
layout: ProjectLayout
) {
companion object {
const val CALL_SITE_CLASS_SUFFIX = "CallSite"
const val CALL_SITE_CONSOLE_REPORTER = "CONSOLE"
const val CALL_SITE_ERROR_CONSOLE_REPORTER = "ERROR_CONSOLE"
}

/**
* The location of the source code to generate call site ({@code <project>/src/main/java} by default).
*/
val srcFolder: DirectoryProperty = objectFactory.directoryProperty().convention(
layout.projectDirectory.dir("src").dir("main").dir("java")
)

/**
* The location to generate call site source code ({@code <project>/build/generated/sources/csi} by default).
*/
val targetFolder: DirectoryProperty = objectFactory.directoryProperty().convention(
layout.buildDirectory.dir("generated/sources/$CSI_SOURCE_SET")
)

/**
* The generated call site source file suffix (#CALL_SITE_CLASS_SUFFIX by default).
*/
val suffix: Property<String> = objectFactory.property<String>().convention(CALL_SITE_CLASS_SUFFIX)

/**
* The reporters to use after call site instrumenter run (only #CALL_SITE_CONSOLE_REPORTER and #CALL_SITE_ERROR_CONSOLE_REPORTER supported for now).
*/
val reporters: ListProperty<String> = objectFactory.listProperty<String>().convention(
listOf(
CALL_SITE_ERROR_CONSOLE_REPORTER
)
)

/**
* The location of the dd-trace-java project to look for the call site instrumenter (optional, current project root folder used if not set).
*/
abstract val rootFolder: Property<File>

/**
* The JVM to use to run the call site instrumenter (optional, default JVM used if not set).
*/
val javaVersion: Property<JavaLanguageVersion> =
objectFactory.property<JavaLanguageVersion>().convention(JavaLanguageVersion.current())

/**
* The JVM arguments to run the call site instrumenter.
*/
val jvmArgs: ListProperty<String> =
objectFactory.listProperty<String>().convention(listOf("-Xmx128m", "-Xms64m"))

/**
* The paths used to look for the call site instrumenter dependencies.
*
* The plugin includes by default **only** the `main` and `test` source sets, and their
* related compilation classpath. As we don't want other test configurations by default.
*
* However, it's possible to contribute additional paths to look for dependencies.
*/
val additionalPaths: ConfigurableFileCollection = objectFactory.fileCollection()
Comment on lines +74 to +82
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Before the csi plugin consumed all test configurations, which forced to resolved all jvm test suites configurations. Now that the csi plugin is now restricted to the standard main and test, a way is needed to provide additional paths to the call site instrumenter generator.

}
Loading