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 19, 2024
1 parent 2b402ec commit 9332c51
Show file tree
Hide file tree
Showing 2 changed files with 44 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
35 changes: 34 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,44 @@ 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
def shareDir = new File(temporaryDir, "jar1")
shareDir.mkdirs()

def jarFile1 = new File(destDir, "dummy-license-file.jar")
def jarFile2 = new File(destDir, "dummy-license-dir.jar")

// dummy-license-file.jar unpacks a META-INF/LICENSE file
def metaInf1 = new File(shareDir, "META-INF")
metaInf1.mkdirs()
new File(metaInf1, "LICENSE").text = "Test License Content"

// dummy-license-dir.jar unpacks a META-INF/LICENSE/content.txt file
def licenseDir = new File(shareDir, "META-INF/LICENSE")
licenseDir.mkdirs()
new File(licenseDir, "content.txt").text = "Test Content"

ant.jar(destfile: jarFile1) {
fileset(dir: shareDir)
}

ant.jar(destfile: jarFile2) {
fileset(dir: shareDir)
}
}
}

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 9332c51

Please sign in to comment.