Skip to content

Commit 88732c5

Browse files
committed
chore: Move CSI plugin to it's own package
1 parent 39eef9c commit 88732c5

File tree

3 files changed

+71
-52
lines changed

3 files changed

+71
-52
lines changed

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ gradlePlugin {
2424
}
2525
create("call-site-instrumentation-plugin") {
2626
id = "call-site-instrumentation"
27-
implementationClass = "datadog.gradle.plugin.CallSiteInstrumentationPlugin"
27+
implementationClass = "datadog.gradle.plugin.csi.CallSiteInstrumentationPlugin"
2828
}
2929
create("tracer-version-plugin") {
3030
id = "datadog.tracer-version"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package datadog.gradle.plugin.csi
2+
3+
import org.gradle.api.file.DirectoryProperty
4+
import org.gradle.api.file.ProjectLayout
5+
import org.gradle.api.model.ObjectFactory
6+
import org.gradle.api.provider.ListProperty
7+
import org.gradle.api.provider.Property
8+
import org.gradle.jvm.toolchain.JavaLanguageVersion
9+
import java.io.File
10+
import javax.inject.Inject
11+
12+
13+
/**
14+
* This extension allows to configure the Call Site Instrumenter plugin execution.
15+
*/
16+
abstract class CallSiteInstrumentationExtension @Inject constructor(
17+
objectFactory: ObjectFactory,
18+
layout: ProjectLayout
19+
) {
20+
companion object {
21+
const val CALL_SITE_CLASS_SUFFIX = "CallSite"
22+
const val CALL_SITE_CONSOLE_REPORTER = "CONSOLE"
23+
const val CALL_SITE_ERROR_CONSOLE_REPORTER = "ERROR_CONSOLE"
24+
}
25+
26+
/**
27+
* The location of the source code to generate call site ({@code <project>/src/main/java} by default).
28+
*/
29+
val srcFolder: DirectoryProperty = objectFactory.directoryProperty().convention(
30+
layout.projectDirectory.dir("src").dir("main").dir("java")
31+
)
32+
33+
/**
34+
* The location to generate call site source code ({@code <project>/build/generated/sources/csi} by default).
35+
*/
36+
val targetFolder: DirectoryProperty = objectFactory.directoryProperty().convention(
37+
layout.buildDirectory.dir("generated${File.separatorChar}sources${File.separatorChar}csi")
38+
)
39+
40+
/**
41+
* The generated call site source file suffix (#CALL_SITE_CLASS_SUFFIX by default).
42+
*/
43+
val suffix: Property<String> = objectFactory.property(String::class.java).convention(CALL_SITE_CLASS_SUFFIX)
44+
45+
/**
46+
* The reporters to use after call site instrumenter run (only #CALL_SITE_CONSOLE_REPORTER and #CALL_SITE_ERROR_CONSOLE_REPORTER supported for now).
47+
*/
48+
val reporters: ListProperty<String> = objectFactory.listProperty(String::class.java).convention(
49+
listOf(
50+
CALL_SITE_ERROR_CONSOLE_REPORTER
51+
)
52+
)
53+
54+
/**
55+
* The location of the dd-trace-java project to look for the call site instrumenter (optional, current project root folder used if not set).
56+
*/
57+
abstract val rootFolder: Property<File>
58+
59+
/**
60+
* The JVM to use to run the call site instrumenter (optional, default JVM used if not set).
61+
*/
62+
abstract val javaVersion: Property<JavaLanguageVersion>
63+
64+
/**
65+
* The JVM arguments to run the call site instrumenter.
66+
*/
67+
val jvmArgs: ListProperty<String> =
68+
objectFactory.listProperty(String::class.java).convention(listOf("-Xmx128m", "-Xms64m"))
69+
}

buildSrc/src/main/kotlin/datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt renamed to buildSrc/src/main/kotlin/datadog/gradle/plugin/csi/CallSiteInstrumentationPlugin.kt

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
package datadog.gradle.plugin
1+
package datadog.gradle.plugin.csi
22

33
import org.gradle.api.GradleException
44
import org.gradle.api.JavaVersion
55
import org.gradle.api.Plugin
66
import org.gradle.api.Project
7-
import org.gradle.api.file.DirectoryProperty
8-
import org.gradle.api.file.ProjectLayout
9-
import org.gradle.api.model.ObjectFactory
107
import org.gradle.api.plugins.JavaPluginExtension
11-
import org.gradle.api.provider.ListProperty
12-
import org.gradle.api.provider.Property
138
import org.gradle.api.tasks.JavaExec
149
import org.gradle.api.tasks.SourceSet
1510
import org.gradle.api.tasks.SourceSetContainer
@@ -24,51 +19,6 @@ import java.nio.file.Paths
2419
import javax.inject.Inject
2520

2621
private const val CALL_SITE_INSTRUMENTER_MAIN_CLASS = "datadog.trace.plugin.csi.PluginApplication"
27-
private const val CALL_SITE_CLASS_SUFFIX = "CallSite"
28-
private const val CALL_SITE_CONSOLE_REPORTER = "CONSOLE"
29-
private const val CALL_SITE_ERROR_CONSOLE_REPORTER = "ERROR_CONSOLE"
30-
31-
/**
32-
* This extension allows to configure the Call Site Instrumenter plugin execution.
33-
*/
34-
abstract class CallSiteInstrumentationExtension @Inject constructor(objectFactory: ObjectFactory, layout: ProjectLayout) {
35-
/**
36-
* The location of the source code to generate call site ({@code <project>/src/main/java} by default).
37-
*/
38-
val srcFolder: DirectoryProperty = objectFactory.directoryProperty().convention(
39-
layout.projectDirectory.dir("src").dir("main").dir("java")
40-
)
41-
/**
42-
* The location to generate call site source code ({@code <project>/build/generated/sources/csi} by default).
43-
*/
44-
val targetFolder: DirectoryProperty = objectFactory.directoryProperty().convention(
45-
layout.buildDirectory.dir("generated${File.separatorChar}sources${File.separatorChar}csi")
46-
)
47-
/**
48-
* The generated call site source file suffix (#CALL_SITE_CLASS_SUFFIX by default).
49-
*/
50-
val suffix: Property<String> = objectFactory.property(String::class.java).convention(CALL_SITE_CLASS_SUFFIX)
51-
/**
52-
* The reporters to use after call site instrumenter run (only #CALL_SITE_CONSOLE_REPORTER and #CALL_SITE_ERROR_CONSOLE_REPORTER supported for now).
53-
*/
54-
val reporters: ListProperty<String> = objectFactory.listProperty(String::class.java).convention(listOf(
55-
CALL_SITE_ERROR_CONSOLE_REPORTER
56-
))
57-
/**
58-
* The location of the dd-trace-java project to look for the call site instrumenter (optional, current project root folder used if not set).
59-
*/
60-
abstract val rootFolder: Property<File>
61-
62-
/**
63-
* The JVM to use to run the call site instrumenter (optional, default JVM used if not set).
64-
*/
65-
abstract val javaVersion: Property<JavaLanguageVersion>
66-
67-
/**
68-
* The JVM arguments to run the call site instrumenter.
69-
*/
70-
val jvmArgs: ListProperty<String> = objectFactory.listProperty(String::class.java).convention(listOf("-Xmx128m", "-Xms64m"))
71-
}
7222

7323
abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
7424
@get:Inject

0 commit comments

Comments
 (0)