Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import groovy.lang.Closure

plugins {
`java-library`
}

muzzle {
pass {
group = "org.apache.httpcomponents"
module = "httpasyncclient"
versions = "[4.0,)"
assertInverse = true
}
}

apply(from = "$rootDir/gradle/java.gradle")

// Helper extension for custom method from Groovy DSL
fun addTestSuiteForDir(name: String, dirName: String) {
(project.extra["addTestSuiteForDir"] as? Closure<*>)?.call(name, dirName)
}

addTestSuiteForDir("latestDepTest", "test")
Comment on lines +18 to +23
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably Kotlin alternative should be something like:

plugins {
    id("org.unbroken-dome.test-sets") version "4.1.0"
}

testSets {
    create("latestDepTest") {
        dirName = "test"
    }
}

See: https://github.com/unbroken-dome/gradle-testsets-plugin
Here and other similar places.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AlexeyKuznetsov-DD That's an interesting plugin, but I'd rather hold until we have a discussion on conventions plugins.


dependencies {
compileOnly("org.apache.httpcomponents:httpasyncclient:4.0")

testImplementation("org.apache.httpcomponents:httpasyncclient:4.0")

// Kotlin accessors are not generated if not created by a plugin or explicitly declared
add("latestDepTestImplementation", "org.apache.httpcomponents:httpasyncclient:+")
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import groovy.lang.Closure

plugins {
`java-library`
}

muzzle {
fail {
group = "commons-httpclient"
module = "commons-httpclient"
versions = "[,4.0)"
skipVersions += "3.1-jenkins-1"
skipVersions += "2.0-final" // broken metadata on maven central
}
pass {
group = "org.apache.httpcomponents"
module = "httpclient"
versions = "[4.0,5)"
assertInverse = true
}
pass {
// We want to support the dropwizard clients too.
group = "io.dropwizard"
module = "dropwizard-client"
versions = "[,3)" // dropwizard-client 3+ uses httpclient5
}
}

apply(from = "$rootDir/gradle/java.gradle")

// Helper extensions for custom methods from Groovy DSL
fun addTestSuite(name: String) {
(project.extra["addTestSuite"] as? Closure<*>)?.call(name)
}
fun addTestSuiteForDir(name: String, dirName: String) {
(project.extra["addTestSuiteForDir"] as? Closure<*>)?.call(name, dirName)
}
fun addTestSuiteExtendingForDir(testSuiteName: String, parentSuiteName: String, dirName: String) {
(project.extra["addTestSuiteExtendingForDir"] as? Closure<*>)?.call(testSuiteName, parentSuiteName, dirName)
}
Comment on lines +31 to +40
Copy link
Contributor

Choose a reason for hiding this comment

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

note: Having these is actually why I'm holding off on migrating every build gradle to kotlin.

That doesn't mean it shouldn't happen there as now we have an example of some pain points.


Ideally, our test-suites.gradle script should be a convention plugin, that is applied as part of the declaration of the plugins { } block at the beginning of the build script.

[!NOTE] When Gradle parses the build scripts it processes the plugins {} block first, and can safely inject "accessors" to the classpath of this build script where the methods of the convention plugin are.
Gradle can't do that with script plugins.

E.g.g this comment // Kotlin accessors are not generated if not created by a plugin or explicitly declared is exactly about that.

=> Now as I'm mentioning convention plugins, the idea is to identify conventions and name them, for example instrumenqation projects could have a convention plugin datadog.instrumentation-project, and this plugin should:

  • apply other plugins as necessary,
  • configure them
  • add and extensions as needed (methods or configuration constructs)

Everything ./gradle/*.gradle should land in a convention plugin in some form.

Resources:

Note those link are referring to the 8.14.3, but script plugins are barely mentioned in Gradle 9, apart that they are not recommended, meaning it's likely Gradle will phase out these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see, thanks for all of the context!


addTestSuiteForDir("latestDepTest", "test")
addTestSuite("iastIntegrationTest")
addTestSuiteExtendingForDir("v41IastIntegrationTest", "iastIntegrationTest", "iastIntegrationTest")
addTestSuiteExtendingForDir("v42IastIntegrationTest", "iastIntegrationTest", "iastIntegrationTest")
addTestSuiteExtendingForDir("v43IastIntegrationTest", "iastIntegrationTest", "iastIntegrationTest")
addTestSuiteExtendingForDir("v44IastIntegrationTest", "iastIntegrationTest", "iastIntegrationTest")
addTestSuiteExtendingForDir("v45IastIntegrationTest", "iastIntegrationTest", "iastIntegrationTest")

dependencies {
compileOnly("org.apache.httpcomponents:httpclient:4.0")
testImplementation(project(":dd-java-agent:agent-iast:iast-test-fixtures"))
testImplementation("org.apache.httpcomponents:httpclient:4.0")
testImplementation(project(":dd-java-agent:instrumentation:apache-httpclient:apache-httpasyncclient-4.0"))
// to instrument the integration test
"iastIntegrationTestImplementation"(project(":dd-java-agent:agent-iast:iast-test-fixtures"))
"iastIntegrationTestImplementation"("org.apache.httpcomponents:httpclient:4.0")
"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:jetty:jetty-server:jetty-server-9.0"))
"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:apache-httpcore:apache-httpcore-4.0"))
"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:servlet"))
"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:java-lang"))
"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:java-net"))
"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:iast-instrumenter"))
Comment on lines +56 to +63
Copy link
Contributor

Choose a reason for hiding this comment

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

note: This code is an example of the kotlin's invoke operator:

Parentheses are translated to calls to invoke with appropriate number of arguments.

So

"iastIntegrationTestRuntimeOnly"(project(":dd-java-agent:instrumentation:iast-instrumenter"))

is actually :

"iastIntegrationTestRuntimeOnly".invoke(project(":dd-java-agent:instrumentation:iast-instrumenter"))

which is nice since it allows you to see the method, and access its definition and javadoc.

Also, note that since Strings doesn't have .invoke operators, it has to be an extension function on a String. On a personal note I think having the invoke operator on String (this is a Gradle API) is a bit scabrous, and I would prefer the more explicit way :

add("iastIntegrationTestRuntimeOnly", project(":dd-java-agent:instrumentation:iast-instrumenter"))


"v41IastIntegrationTestImplementation"("org.apache.httpcomponents:httpclient:4.1")
"v42IastIntegrationTestImplementation"("org.apache.httpcomponents:httpclient:4.2")
"v43IastIntegrationTestImplementation"("org.apache.httpcomponents:httpclient:4.3")
"v44IastIntegrationTestImplementation"("org.apache.httpcomponents:httpclient:4.4")
"v45IastIntegrationTestImplementation"("org.apache.httpcomponents:httpclient:4.5")

// Kotlin accessors are not generated if not created by a plugin or explicitly declared
add("latestDepTestImplementation", "org.apache.httpcomponents:httpclient:+")
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import groovy.lang.Closure

plugins {
`java-library`
}

muzzle {
pass {
group = "org.apache.httpcomponents.client5"
module = "httpclient5"
versions = "[5.0,)"
assertInverse = true
}
}

apply(from = "$rootDir/gradle/java.gradle")

// Helper extension for custom method from Groovy DSL
fun addTestSuiteForDir(name: String, dirName: String) {
(project.extra["addTestSuiteForDir"] as? Closure<*>)?.call(name, dirName)
}

addTestSuiteForDir("latestDepTest", "test")

dependencies {
compileOnly("org.apache.httpcomponents.client5:httpclient5:5.0")

testImplementation("org.apache.httpcomponents.client5:httpclient5:5.0")

// Kotlin accessors are not generated if not created by a plugin or explicitly declared
add("latestDepTestImplementation", "org.apache.httpcomponents.client5:httpclient5:+")
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import groovy.lang.Closure

plugins {
`java-library`
}

muzzle {
pass {
group = "org.apache.httpcomponents"
module = "httpcore"
versions = "[4.0,5)"
assertInverse = true
}
}

apply(from = "$rootDir/gradle/java.gradle")

// Helper extensions for custom methods from Groovy DSL
fun addTestSuiteForDir(name: String, dirName: String) {
(project.extra["addTestSuiteForDir"] as? Closure<*>)?.call(name, dirName)
}

addTestSuiteForDir("latestDepTest", "test")

dependencies {
compileOnly("org.apache.httpcomponents:httpcore:4.0")

testImplementation("org.apache.httpcomponents:httpcore:4.0")

// Kotlin accessors are not generated if not created by a plugin or explicitly declared
add("latestDepTestImplementation", "org.apache.httpcomponents:httpcore:+")
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import groovy.lang.Closure

plugins {
`java-library`
}

muzzle {
pass {
group = "org.apache.httpcomponents.core5"
module = "httpcore5"
versions = "[5.0,)"
assertInverse = true
}
}

apply(from = "$rootDir/gradle/java.gradle")

// Helper extensions for custom methods from Groovy DSL
fun addTestSuiteForDir(name: String, dirName: String) {
(project.extra["addTestSuiteForDir"] as? Closure<*>)?.call(name, dirName)
}

addTestSuiteForDir("latestDepTest", "test")

dependencies {
compileOnly("org.apache.httpcomponents.core5:httpcore5:5.0")

testImplementation("org.apache.httpcomponents.core5:httpcore5:5.0")

// Kotlin accessors are not generated if not created by a plugin or explicitly declared
add("latestDepTestImplementation", "org.apache.httpcomponents.core5:httpcore5:+")
}