Enable excluding muzzle dependencies and exclude netty-tcnative
MODIFY
buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/muzzle/MuzzleDirective.java
buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/muzzle/MuzzleDirective.java
@@ -21,6 +21,7 @@ public abstract class MuzzleDirective {
getName().convention("");
getSkipVersions().convention(Collections.emptySet());
getAdditionalDependencies().convention(Collections.emptyList());
+ getExcludedDependencies().convention(Collections.emptyList());
getAssertPass().convention(false);
getAssertInverse().convention(false);
getCoreJdk().convention(false);
@@ -38,6 +39,8 @@ public abstract class MuzzleDirective {
public abstract ListProperty<String> getAdditionalDependencies();
+ public abstract ListProperty<String> getExcludedDependencies();
+
public abstract Property<Boolean> getAssertPass();
public abstract Property<Boolean> getAssertInverse();
@@ -58,6 +61,15 @@ public abstract class MuzzleDirective {
getAdditionalDependencies().add(compileString);
}
+ /**
+ * Adds transitive dependencies to exclude from the current muzzle test.
+ *
+ * @param excludeString A dependency in the gradle canonical form: '<group_id>:<artifact_id>'
+ */
+ public void excludeDependency(String excludeString) {
+ getExcludedDependencies().add(excludeString);
+ }
+
public void skip(String... version) {
getSkipVersions().addAll(version);
}

MODIFY
buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/muzzle/MuzzlePlugin.java
buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/muzzle/MuzzlePlugin.java
@@ -251,6 +251,10 @@ public class MuzzlePlugin implements Plugin<Project> {
// longer bundled with the JVM and have to be excluded for the muzzle tests to be able to run.
exclude(dep, "com.sun.jdmk", "jmxtools");
exclude(dep, "com.sun.jmx", "jmxri");
+ for (String excluded : muzzleDirective.getExcludedDependencies().get()) {
+ String[] parts = excluded.split(":");
+ exclude(dep, parts[0], parts[1]);
+ }
config.getDependencies().add(dep);
}
@@ -449,6 +453,7 @@ public class MuzzlePlugin implements Plugin<Project> {
inverseDirective.getModule().set(muzzleDirective.getModule());
inverseDirective.getVersions().set(version);
inverseDirective.getAssertPass().set(!muzzleDirective.getAssertPass().get());
+ inverseDirective.getExcludedDependencies().set(muzzleDirective.getExcludedDependencies());
inverseDirectives.add(inverseDirective);
}

MODIFY
instrumentation/netty/netty-3.8/javaagent/netty-3.8-javaagent.gradle
instrumentation/netty/netty-3.8/javaagent/netty-3.8-javaagent.gradle
@@ -11,8 +11,7 @@ muzzle {
group = "io.netty"
module = "netty-all"
versions = "[,]"
- // Could not find netty-tcnative-2.0.39.Final-${os.detected.classifier}.jar (io.netty:netty-tcnative:2.0.39.Final)
- skip("4.1.64.Final")
+ excludeDependency 'io.netty:netty-tcnative'
}
}

MODIFY
instrumentation/netty/netty-4.0/javaagent/netty-4.0-javaagent.gradle
instrumentation/netty/netty-4.0/javaagent/netty-4.0-javaagent.gradle
@@ -11,8 +11,7 @@ muzzle {
group = "io.netty"
module = "netty-all"
versions = "[4.0.0.Final,4.1.0.Final)"
- // Could not find netty-tcnative-2.0.39.Final-${os.detected.classifier}.jar (io.netty:netty-tcnative:2.0.39.Final)
- skip("4.1.64.Final")
+ excludeDependency 'io.netty:netty-tcnative'
assertInverse = true
}
fail {

MODIFY
instrumentation/netty/netty-4.1/javaagent/netty-4.1-javaagent.gradle
instrumentation/netty/netty-4.1/javaagent/netty-4.1-javaagent.gradle
@@ -11,8 +11,7 @@ muzzle {
group = "io.netty"
module = "netty-all"
versions = "[4.1.0.Final,5.0.0)"
- // Could not find netty-tcnative-2.0.39.Final-${os.detected.classifier}.jar (io.netty:netty-tcnative:2.0.39.Final)
- skip("4.1.64.Final")
+ excludeDependency 'io.netty:netty-tcnative'
assertInverse = true
}
fail {

Enable excluding muzzle dependencies and exclude netty-tcnative (#3169)

Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>