Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ tasks {
disable("UnnecessarilyFullyQualified")

// TODO (trask) use animal sniffer
disable("Java7ApiChecker")
disable("Java8ApiChecker")
disable("AndroidJdkLibsChecker")

Expand Down Expand Up @@ -124,8 +123,8 @@ tasks {

disable("NonFinalStaticField")

// We get this warning in modules that compile for old java versions
disable("StringConcatToTextBlock")
// Requires adding compile dependency to JSpecify
disable("AddNullMarkedToPackageInfo")

if (testLatestDeps) {
// Some latest dep tests are compiled for java 17 although the base version uses an older
Expand Down
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ val DEPENDENCY_BOMS = listOf(

val autoServiceVersion = "1.1.1"
val autoValueVersion = "1.11.0"
val errorProneVersion = "2.37.0"
val errorProneVersion = "2.38.0"
val byteBuddyVersion = "1.17.5"
val asmVersion = "9.8"
val jmhVersion = "1.37"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ class GradleParserTest {
@Test
void testExtractMuzzleVersions_SinglePassBlock() {
String gradleBuildFileContent =
"muzzle {\n"
+ " pass {\n"
+ " group.set(\"org.elasticsearch.client\")\n"
+ " module.set(\"rest\")\n"
+ " versions.set(\"[5.0,6.4)\")\n"
+ " }\n"
+ "}";
"""
muzzle {
pass {
group.set("org.elasticsearch.client")
module.set("rest")
versions.set("[5.0,6.4)")
}
}""";
DependencyInfo info =
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT);
assertThat(info.versions().size()).isEqualTo(1);
Expand All @@ -33,7 +34,10 @@ void testExtractMuzzleVersions_SinglePassBlock() {
@Test
void testExtractLibraryVersion() {
String gradleBuildFileContent =
"dependencies {\n" + " library(\"org.apache.httpcomponents:httpclient:4.3\")\n" + "}";
"""
dependencies {
library("org.apache.httpcomponents:httpclient:4.3")
}""";
DependencyInfo info =
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.LIBRARY);
assertThat(info.versions().size()).isEqualTo(1);
Expand All @@ -44,11 +48,12 @@ void testExtractLibraryVersion() {
@Test
void testExtractLibraryUpperVersion() {
String gradleBuildFileContent =
"dependencies {\n"
+ " library(\"org.apache.httpcomponents:httpclient:4.3\")\n"
+ " testImplementation(project(\":instrumentation:apache-httpclient:apache-httpclient-4.3:testing\"))\n"
+ " latestDepTestLibrary(\"org.apache.httpcomponents:httpclient:4.+\") // see apache-httpclient-5.0 module\n"
+ "}";
"""
dependencies {
library("org.apache.httpcomponents:httpclient:4.3")
testImplementation(project(":instrumentation:apache-httpclient:apache-httpclient-4.3:testing"))
latestDepTestLibrary("org.apache.httpcomponents:httpclient:4.+") // see apache-httpclient-5.0 module
}""";

DependencyInfo info =
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.LIBRARY);
Expand Down Expand Up @@ -122,35 +127,37 @@ void testExtractMinimumJavaVersionIgnoredWithinIfCondition() {
@Test
void testExtractMuzzleVersions_MultiplePassBlocks() {
String gradleBuildFileContent =
"plugins {\n"
+ " id(\"otel.javaagent-instrumentation\")\n"
+ " id(\"otel.nullaway-conventions\")\n"
+ " id(\"otel.scala-conventions\")\n"
+ "}\n"
+ "\n"
+ "val zioVersion = \"2.0.0\"\n"
+ "val scalaVersion = \"2.12\"\n"
+ "\n"
+ "muzzle {\n"
+ " pass {\n"
+ " group.set(\"dev.zio\")\n"
+ " module.set(\"zio_2.12\")\n"
+ " versions.set(\"[$zioVersion,)\")\n"
+ " assertInverse.set(true)\n"
+ " }\n"
+ " pass {\n"
+ " group.set(\"dev.zio\")\n"
+ " module.set(\"zio_2.13\")\n"
+ " versions.set(\"[$zioVersion,)\")\n"
+ " assertInverse.set(true)\n"
+ " }\n"
+ " pass {\n"
+ " group.set(\"dev.zio\")\n"
+ " module.set(\"zio_3\")\n"
+ " versions.set(\"[$zioVersion,)\")\n"
+ " assertInverse.set(true)\n"
+ " }\n"
+ "}\n";
"""
plugins {
id("otel.javaagent-instrumentation")
id("otel.nullaway-conventions")
id("otel.scala-conventions")
}

val zioVersion = "2.0.0"
val scalaVersion = "2.12"

muzzle {
pass {
group.set("dev.zio")
module.set("zio_2.12")
versions.set("[$zioVersion,)")
assertInverse.set(true)
}
pass {
group.set("dev.zio")
module.set("zio_2.13")
versions.set("[$zioVersion,)")
assertInverse.set(true)
}
pass {
group.set("dev.zio")
module.set("zio_3")
versions.set("[$zioVersion,)")
assertInverse.set(true)
}
}
""";

DependencyInfo info =
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.JAVAAGENT);
Expand All @@ -162,23 +169,25 @@ void testExtractMuzzleVersions_MultiplePassBlocks() {
@Test
void testExtractLogbackLibrary() {
String gradleBuildFileContent =
"compileOnly(\"ch.qos.logback:logback-classic\") {\n"
+ " version {\n"
+ " // compiling against newer version than the earliest supported version (1.0.0) to support\n"
+ " // features added in 1.3.0\n"
+ " strictly(\"1.3.0\")\n"
+ " }\n"
+ "}\n"
+ "compileOnly(\"org.slf4j:slf4j-api\") {\n"
+ " version {\n"
+ " strictly(\"2.0.0\")\n"
+ " }\n"
+ "}\n"
+ "compileOnly(\"net.logstash.logback:logstash-logback-encoder\") {\n"
+ " version {\n"
+ " strictly(\"3.0\")\n"
+ " }\n"
+ "}\n";
"""
compileOnly("ch.qos.logback:logback-classic") {
version {
// compiling against newer version than the earliest supported version (1.0.0) to support
// features added in 1.3.0
strictly("1.3.0")
}
}
compileOnly("org.slf4j:slf4j-api") {
version {
strictly("2.0.0")
}
}
compileOnly("net.logstash.logback:logstash-logback-encoder") {
version {
strictly("3.0")
}
}
""";

DependencyInfo info =
GradleParser.parseGradleFile(gradleBuildFileContent, InstrumentationType.LIBRARY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,4 @@ public String process() {

@Override
public void stop() {}

public String getFail() {
return fail;
}

public void setFail(String fail) {
this.fail = fail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,4 @@ public Object readItem() {
public Serializable checkpointInfo() {
return null;
}

public String getStartStr() {
return startStr;
}

public void setStartStr(String startStr) {
this.startStr = startStr;
}

public String getEndStr() {
return endStr;
}

public void setEndStr(String endStr) {
this.endStr = endStr;
}

public int getStart() {
return start;
}

public void setStart(int start) {
this.start = start;
}

public int getEnd() {
return end;
}

public void setEnd(int end) {
this.end = end;
}
}
Loading