Skip to content

Commit 70c34b6

Browse files
authored
Merge branch 'master' into sarahchen6/workflow-to-enforce-no-groovy
2 parents 9c781e1 + 2f04ccb commit 70c34b6

9 files changed

Lines changed: 248 additions & 207 deletions

File tree

.claude/skills/migrate-groovy-to-java/SKILL.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ description: migrate test groovy files to java
55

66
Migrate test Groovy files to Java using JUnit 5
77

8-
1. List all groovy files of the current gradle module
9-
2. convert groovy files to Java using Junit 5
10-
3. make sure the tests are still passing after migration
11-
4. remove groovy files
8+
1. List all Groovy files of the current Gradle module
9+
2. Convert Groovy files to Java using JUnit 5
10+
3. Make sure the tests are still passing after migration and that the test count has not changed
11+
4. Remove Groovy files
1212
5. Add the migrated module path(s) to `.github/g2j-migrated-modules.txt`
1313

14-
When converting groovy code to java code make sure that:
15-
- the Java code generated is compatible with JDK 8
16-
- when translating Spock test, favor using `@CsvSource` with `|` delimiters
17-
- when using a `@MethodSource`, use the test method name, and suffix it with `_arguments`
18-
- when converting tuples, create light dedicated structure instead to keep the typing system
14+
When converting Groovy code to Java code, make sure that:
15+
- The Java code generated is compatible with JDK 8
16+
- When translating Spock tests, favor using `@CsvSource` with `|` delimiters
17+
- When using `@MethodSource`, name the arguments method by appending `Arguments` using camelCase to the test method name (e.g. `testMethodArguments`)
18+
- Ensure parameterized test names are human-readable (i.e. no hashcodes); instead add a description string as the first `Arguments.of(...)` value or index the test case
19+
- When converting tuples, create a light dedicated structure instead to keep the typing system
1920
- Instead of checking a state and throwing an exception, use JUnit asserts
20-
- Do not wrap checked exception and throwing a Runtime exception, prefer adding a throws clause at method declaration
21+
- Do not wrap checked exceptions and throw a Runtime exception; prefer adding a throws clause at method declaration
2122
- Do not mark local variables `final`
23+
- Ensure variables are human-readable; avoid single-letter names and pre-define variables that are referenced multiple times
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package datadog.gradle.plugin.instrument
22

3+
import org.gradle.api.file.ConfigurableFileCollection
34
import org.gradle.api.file.DirectoryProperty
45
import org.gradle.api.provider.ListProperty
56

67
abstract class BuildTimeInstrumentationExtension {
78
abstract ListProperty<String> getPlugins()
89
abstract ListProperty<DirectoryProperty> getAdditionalClasspath()
10+
abstract ConfigurableFileCollection getIncludeClassDirectories()
911
}

buildSrc/src/main/groovy/datadog/gradle/plugin/instrument/BuildTimeInstrumentationPlugin.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class BuildTimeInstrumentationPlugin implements Plugin<Project> {
126126
it.inputs.property("javaVersion", javaVersion)
127127
it.inputs.property("plugins", extension.plugins)
128128
it.inputs.files(extension.additionalClasspath)
129+
it.inputs.files(extension.includeClassDirectories)
129130

130131
// Temporary location for raw (un-instrumented) classes
131132
DirectoryProperty tmpUninstrumentedClasses = project.objects.directoryProperty().value(
@@ -149,7 +150,8 @@ class BuildTimeInstrumentationPlugin implements Plugin<Project> {
149150
extension.plugins,
150151
instrumentingClassPath,
151152
it.destinationDirectory,
152-
tmpUninstrumentedClasses
153+
tmpUninstrumentedClasses,
154+
extension.includeClassDirectories
153155
)
154156
)
155157
logger.info("[BuildTimeInstrumentationPlugin] Configured post-compile instrumentation for $compileTaskName for source-set $sourceSetName")

buildSrc/src/main/groovy/datadog/gradle/plugin/instrument/InstrumentAction.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ abstract class InstrumentAction implements WorkAction<InstrumentWorkParameters>
4444
from(classesDirectory)
4545
into(tmpUninstrumentedDir)
4646
}
47+
// Merge any additional class directories (e.g. unpacked dependency JARs) to be processed
48+
parameters.includeClassDirectories.files.each { classesDir ->
49+
if (classesDir.exists()) {
50+
fileSystemOperations.copy {
51+
from(classesDir)
52+
into(tmpUninstrumentedDir)
53+
}
54+
}
55+
}
4756
fileSystemOperations.delete {
4857
delete(objects.fileTree().from(classesDirectory))
4958
}

buildSrc/src/main/groovy/datadog/gradle/plugin/instrument/InstrumentPostProcessingAction.groovy

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,33 @@ abstract class InstrumentPostProcessingAction implements Action<AbstractCompile>
3535
final FileCollection instrumentingClassPath
3636
final DirectoryProperty compilerOutputDirectory
3737
final DirectoryProperty tmpDirectory
38+
final FileCollection includeClassDirectories
3839

3940
@Inject
4041
InstrumentPostProcessingAction(
4142
String javaVersion,
4243
ListProperty<String> plugins,
4344
FileCollection instrumentingClassPath,
4445
DirectoryProperty compilerOutputDirectory,
45-
DirectoryProperty tmpDirectory
46+
DirectoryProperty tmpDirectory,
47+
FileCollection includeClassDirectories
4648
) {
4749
this.javaVersion = javaVersion == BuildTimeInstrumentationPlugin.DEFAULT_JAVA_VERSION ? JavaLanguageVersion.current() : JavaLanguageVersion.of(javaVersion)
4850
this.plugins = plugins
4951
this.instrumentingClassPath = instrumentingClassPath
5052
this.compilerOutputDirectory = compilerOutputDirectory
5153
this.tmpDirectory = tmpDirectory
54+
this.includeClassDirectories = includeClassDirectories
5255
}
5356

5457
@Override
5558
void execute(AbstractCompile task) {
5659
logger.info(
5760
"""
58-
[InstrumentPostProcessingAction] About to instrument classes
59-
javaVersion=${javaVersion},
60-
plugins=${plugins.get()},
61-
instrumentingClassPath=${instrumentingClassPath.files},
61+
[InstrumentPostProcessingAction] About to instrument classes
62+
javaVersion=${javaVersion},
63+
plugins=${plugins.get()},
64+
instrumentingClassPath=${instrumentingClassPath.files},
6265
rawClassesDirectory=${compilerOutputDirectory.get().asFile}
6366
""".stripIndent()
6467
)
@@ -72,6 +75,7 @@ abstract class InstrumentPostProcessingAction implements Action<AbstractCompile>
7275
parameters.instrumentingClassPath.setFrom(postCompileAction.instrumentingClassPath)
7376
parameters.compilerOutputDirectory.set(postCompileAction.compilerOutputDirectory)
7477
parameters.tmpDirectory.set(postCompileAction.tmpDirectory)
78+
parameters.includeClassDirectories.setFrom(postCompileAction.includeClassDirectories)
7579
})
7680
}
7781

buildSrc/src/main/groovy/datadog/gradle/plugin/instrument/InstrumentWorkParameters.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ interface InstrumentWorkParameters extends WorkParameters {
1414
ConfigurableFileCollection getInstrumentingClassPath()
1515
DirectoryProperty getCompilerOutputDirectory()
1616
DirectoryProperty getTmpDirectory()
17+
ConfigurableFileCollection getIncludeClassDirectories()
1718
}

components/json/src/test/groovy/datadog/json/JsonMapperTest.groovy

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)