|
| 1 | +package datadog.gradle.plugin.csi |
| 2 | + |
| 3 | +import org.gradle.api.file.ConfigurableFileCollection |
| 4 | +import org.gradle.api.file.DirectoryProperty |
| 5 | +import org.gradle.api.file.ProjectLayout |
| 6 | +import org.gradle.api.model.ObjectFactory |
| 7 | +import org.gradle.api.provider.ListProperty |
| 8 | +import org.gradle.api.provider.Property |
| 9 | +import org.gradle.jvm.toolchain.JavaLanguageVersion |
| 10 | +import org.gradle.kotlin.dsl.listProperty |
| 11 | +import org.gradle.kotlin.dsl.property |
| 12 | +import java.io.File |
| 13 | +import javax.inject.Inject |
| 14 | + |
| 15 | + |
| 16 | +/** |
| 17 | + * This extension allows to configure the Call Site Instrumenter plugin execution. |
| 18 | + */ |
| 19 | +abstract class CallSiteInstrumentationExtension @Inject constructor( |
| 20 | + objectFactory: ObjectFactory, |
| 21 | + layout: ProjectLayout |
| 22 | +) { |
| 23 | + companion object { |
| 24 | + const val CALL_SITE_CLASS_SUFFIX = "CallSite" |
| 25 | + const val CALL_SITE_CONSOLE_REPORTER = "CONSOLE" |
| 26 | + const val CALL_SITE_ERROR_CONSOLE_REPORTER = "ERROR_CONSOLE" |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * The location of the source code to generate call site ({@code <project>/src/main/java} by default). |
| 31 | + */ |
| 32 | + val srcFolder: DirectoryProperty = objectFactory.directoryProperty().convention( |
| 33 | + layout.projectDirectory.dir("src").dir("main").dir("java") |
| 34 | + ) |
| 35 | + |
| 36 | + /** |
| 37 | + * The location to generate call site source code ({@code <project>/build/generated/sources/csi} by default). |
| 38 | + */ |
| 39 | + val targetFolder: DirectoryProperty = objectFactory.directoryProperty().convention( |
| 40 | + layout.buildDirectory.dir("generated/sources/$CSI_SOURCE_SET") |
| 41 | + ) |
| 42 | + |
| 43 | + /** |
| 44 | + * The generated call site source file suffix (#CALL_SITE_CLASS_SUFFIX by default). |
| 45 | + */ |
| 46 | + val suffix: Property<String> = objectFactory.property<String>().convention(CALL_SITE_CLASS_SUFFIX) |
| 47 | + |
| 48 | + /** |
| 49 | + * The reporters to use after call site instrumenter run (only #CALL_SITE_CONSOLE_REPORTER and #CALL_SITE_ERROR_CONSOLE_REPORTER supported for now). |
| 50 | + */ |
| 51 | + val reporters: ListProperty<String> = objectFactory.listProperty<String>().convention( |
| 52 | + listOf( |
| 53 | + CALL_SITE_ERROR_CONSOLE_REPORTER |
| 54 | + ) |
| 55 | + ) |
| 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 | + val javaVersion: Property<JavaLanguageVersion> = |
| 66 | + objectFactory.property<JavaLanguageVersion>().convention(JavaLanguageVersion.current()) |
| 67 | + |
| 68 | + /** |
| 69 | + * The JVM arguments to run the call site instrumenter. |
| 70 | + */ |
| 71 | + val jvmArgs: ListProperty<String> = |
| 72 | + objectFactory.listProperty<String>().convention(listOf("-Xmx128m", "-Xms64m")) |
| 73 | + |
| 74 | + /** |
| 75 | + * The paths used to look for the call site instrumenter dependencies. |
| 76 | + * |
| 77 | + * The plugin includes by default **only** the `main` and `test` source sets, and their |
| 78 | + * related compilation classpath. As we don't want other test configurations by default. |
| 79 | + * |
| 80 | + * However, it's possible to contribute additional paths to look for dependencies. |
| 81 | + */ |
| 82 | + val additionalPaths: ConfigurableFileCollection = objectFactory.fileCollection() |
| 83 | +} |
0 commit comments