Skip to content
Open
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
57 changes: 57 additions & 0 deletions products/feature-flagging/feature-flagging-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datadog.gradle.plugin.testJvmConstraints.TestJvmConstraintsExtension
import groovy.lang.Closure
import org.gradle.api.tasks.SourceSetContainer
import java.util.zip.ZipFile

plugins {
`java-library`
Expand Down Expand Up @@ -42,13 +44,19 @@ java {

dependencies {
api("dev.openfeature:sdk:1.20.1")
implementation(libs.moshi)
implementation(libs.slf4j)

compileOnly(project(":products:feature-flagging:feature-flagging-bootstrap"))
compileOnly(project(":products:feature-flagging:feature-flagging-config"))
compileOnly(project(":products:feature-flagging:feature-flagging-core"))
compileOnly(project(":products:feature-flagging:feature-flagging-http"))
compileOnly(project(":utils:config-utils"))
compileOnly("io.opentelemetry:opentelemetry-api:1.47.0")

testImplementation(project(":products:feature-flagging:feature-flagging-bootstrap"))
testImplementation(project(":products:feature-flagging:feature-flagging-core"))
testImplementation(project(":products:feature-flagging:feature-flagging-http"))
testImplementation(project(":utils:config-utils"))
testImplementation("io.opentelemetry:opentelemetry-api:1.47.0")
testImplementation(libs.bundles.junit5)
Expand Down Expand Up @@ -78,8 +86,57 @@ tasks.withType<Javadoc>().configureEach {
javadocTool = javaToolchains.javadocToolFor(java.toolchain)
}

val coreProject = project(":products:feature-flagging:feature-flagging-core")
val httpProject = project(":products:feature-flagging:feature-flagging-http")
val bootstrapProject = project(":products:feature-flagging:feature-flagging-bootstrap")

tasks.named<Jar>("jar") {
from(coreProject.extensions.getByType<SourceSetContainer>().named("main").map { it.output })
from(httpProject.extensions.getByType<SourceSetContainer>().named("main").map { it.output })
from(bootstrapProject.extensions.getByType<SourceSetContainer>().named("main").map { it.output }) {
include("datadog/trace/api/featureflag/ufc/v1/**")
}
Comment on lines +96 to +98

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A concern from Codex

This embeds the UFC model in dd-openfeature.jar, while the same classes are supplied by the agent on the bootstrap classloader. Standard parent-first delegation makes them identical at runtime, but a child-first application classloader could load this embedded copy and make gateway-provided ServerConfiguration objects type-incompatible with the provider’s evaluator. Do we support such classloaders? If so, can we add a child-first classloading test; otherwise, please document the parent-first delegation requirement.

}

tasks.withType<Test>().configureEach {
dependsOn(tasks.named("jar"))
systemProperty(
"dd.openfeature.test.jar",
tasks.named<Jar>("jar").get().archiveFile.get().asFile.absolutePath
)
}

// The dd-openfeature provider jar is not produced by the CI `build` job, so there is no reference
// artifact to compare against. Disable the release jar comparison gate registered by publish.gradle.
tasks.named("compareToReferenceJar") {
enabled = false
}

tasks.register("verifyDdOpenfeatureArtifact") {
dependsOn(tasks.named("jar"), tasks.named("generatePomFileForMavenPublication"))
doLast {
val providerJar = tasks.named<Jar>("jar").get().archiveFile.get().asFile
val requiredEntries = setOf(
"datadog/openfeature/internal/core/ConfigurationStore.class",
"datadog/openfeature/internal/core/FlagEvaluator.class",
"datadog/openfeature/internal/http/CdnConfigurationSource.class",
"datadog/openfeature/internal/http/HttpConfigurationOptions.class",
"datadog/trace/api/featureflag/ufc/v1/ServerConfiguration.class"
)
ZipFile(providerJar).use { zip ->
val entryNames = zip.entries().asSequence().map { it.name }.toSet()
val missing = requiredEntries - entryNames
check(missing.isEmpty()) {
"dd-openfeature is missing embedded standalone classes: $missing"
}
}

val pom = layout.buildDirectory.file("publications/maven/pom-default.xml").get().asFile
check(pom.isFile) { "Generated dd-openfeature Maven POM is missing" }
val pomText = pom.readText()
check(pomText.contains("<artifactId>sdk</artifactId>"))
check(pomText.contains("<artifactId>moshi</artifactId>"))
check(!pomText.contains("feature-flagging-core"))
check(!pomText.contains("feature-flagging-http"))
}
}
Loading
Loading