Skip to content

Commit

Permalink
Add failing ThirdPartyAuditIT which mocks file collision.
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Dec 24, 2024
1 parent f5f0ac0 commit 244719e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ public void setUp() throws Exception {
setupJarJdkClasspath(getProjectDir("thirdPartyAudit"));
}

public void testJarMetadataUnpackCollision() {
BuildResult result = getGradleRunner("thirdPartyAudit").withArguments(
":clean",
":empty",
"-s",
"-PcompileGroup=other.gradle:force-collision",
"-PcompileVersion=0.0.1"
).build();
}

public void testOpenSearchIgnored() {
BuildResult result = getGradleRunner("thirdPartyAudit").withArguments(
":clean",
Expand Down
36 changes: 35 additions & 1 deletion buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,45 @@ dependencies {
}
}

// Must configure a single task for these test jars to ensure they are unzipped to the same directory
tasks.register("force-collision", Jar) {
destinationDirectory = file("${buildDir}/testrepo/org/other/gradle/collision-test/0.0.1/")

doFirst {
def destDir = destinationDirectory.get().asFile
destDir.mkdirs()

// Create temporary directories for building the jars
def tempDir1 = new File(temporaryDir, "jar1")
def tempDir2 = new File(temporaryDir, "jar2") // Fixed typo here

// Setup first jar with LICENSE file
def metaInf1 = new File(tempDir1, "META-INF")
metaInf1.mkdirs()
new File(metaInf1, "LICENSE").text = "Test License Content"

// Setup second jar with LICENSE directory
def metaInf2 = new File(tempDir2, "META-INF/LICENSE")
metaInf2.mkdirs()
new File(metaInf2, "content.txt").text = "Test Content"

// Create the actual jar files
ant.jar(destfile: new File(destDir, "dummy-license-file.jar")) {
fileset(dir: tempDir1)
}

ant.jar(destfile: new File(destDir, "dummy-license-dir.jar")) {
fileset(dir: tempDir2)
}
}
}

tasks.register("jarhellJdk", Jar) {
destinationDirectory = file("${buildDir}/testrepo/org/other/gradle/jarhellJdk/0.0.1/")
archiveFileName = "jarhellJdk-0.0.1.jar"
from sourceSets.main.output
include "**/String.class"
into "java/lang"
}
build.dependsOn("jarhellJdk")

build.dependsOn("jarhellJdk", "force-collision")

0 comments on commit 244719e

Please sign in to comment.