Skip to content

Commit 9332c51

Browse files
Add failing ThirdPartyAuditIT which mocks file collision.
Signed-off-by: Finn Carroll <[email protected]>
1 parent 2b402ec commit 9332c51

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

buildSrc/src/integTest/java/org/opensearch/gradle/precommit/ThirdPartyAuditTaskIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public void setUp() throws Exception {
4848
setupJarJdkClasspath(getProjectDir("thirdPartyAudit"));
4949
}
5050

51+
public void testJarMetadataUnpackCollision() {
52+
BuildResult result = getGradleRunner("thirdPartyAudit").withArguments(
53+
":clean",
54+
":empty",
55+
"-s",
56+
"-PcompileGroup=other.gradle:force-collision",
57+
"-PcompileVersion=0.0.1"
58+
).build();
59+
}
60+
5161
public void testOpenSearchIgnored() {
5262
BuildResult result = getGradleRunner("thirdPartyAudit").withArguments(
5363
":clean",

buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,44 @@ dependencies {
5151
}
5252
}
5353

54+
// Must configure a single task for these test jars to ensure they are unzipped to the same directory
55+
tasks.register("force-collision", Jar) {
56+
destinationDirectory = file("${buildDir}/testrepo/org/other/gradle/collision-test/0.0.1/")
57+
58+
doFirst {
59+
def destDir = destinationDirectory.get().asFile
60+
def shareDir = new File(temporaryDir, "jar1")
61+
shareDir.mkdirs()
62+
63+
def jarFile1 = new File(destDir, "dummy-license-file.jar")
64+
def jarFile2 = new File(destDir, "dummy-license-dir.jar")
65+
66+
// dummy-license-file.jar unpacks a META-INF/LICENSE file
67+
def metaInf1 = new File(shareDir, "META-INF")
68+
metaInf1.mkdirs()
69+
new File(metaInf1, "LICENSE").text = "Test License Content"
70+
71+
// dummy-license-dir.jar unpacks a META-INF/LICENSE/content.txt file
72+
def licenseDir = new File(shareDir, "META-INF/LICENSE")
73+
licenseDir.mkdirs()
74+
new File(licenseDir, "content.txt").text = "Test Content"
75+
76+
ant.jar(destfile: jarFile1) {
77+
fileset(dir: shareDir)
78+
}
79+
80+
ant.jar(destfile: jarFile2) {
81+
fileset(dir: shareDir)
82+
}
83+
}
84+
}
85+
5486
tasks.register("jarhellJdk", Jar) {
5587
destinationDirectory = file("${buildDir}/testrepo/org/other/gradle/jarhellJdk/0.0.1/")
5688
archiveFileName = "jarhellJdk-0.0.1.jar"
5789
from sourceSets.main.output
5890
include "**/String.class"
5991
into "java/lang"
6092
}
61-
build.dependsOn("jarhellJdk")
93+
94+
build.dependsOn("jarhellJdk", "force-collision")

0 commit comments

Comments
 (0)