Skip to content

Commit 0caf5ac

Browse files
committed
Remove the workaround for projectRoot
1 parent c9933c5 commit 0caf5ac

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ApplicationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ApplicationTest : BasePluginTest() {
7777
val zip = path("build/distributions/myapp-shadow-1.0.zip")
7878
assertThat(zip).exists()
7979

80-
val entries = ZipFile(zip.toFile()).entries.toList().map { it.name }
80+
val entries = ZipFile(zip.toFile()).use { it.entries }.toList().map { it.name }
8181
assertThat(entries).containsAtLeast(
8282
"myapp-shadow-1.0/lib/myapp-1.0-all.jar",
8383
"myapp-shadow-1.0/lib/a-1.0.jar",

src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ import org.junit.jupiter.api.AfterEach
3636
import org.junit.jupiter.api.BeforeAll
3737
import org.junit.jupiter.api.BeforeEach
3838
import org.junit.jupiter.api.TestInstance
39+
import org.junit.jupiter.api.io.TempDir
3940

4041
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
4142
abstract class BasePluginTest {
43+
@TempDir
4244
lateinit var projectRoot: Path
4345
lateinit var localRepo: AppendableMavenRepository
4446

@@ -64,20 +66,12 @@ abstract class BasePluginTest {
6466

6567
@BeforeEach
6668
open fun setup() {
67-
projectRoot = createTempDirectory()
68-
6969
projectScriptPath.writeText(getDefaultProjectBuildScript(withGroup = true, withVersion = true))
7070
settingsScriptPath.writeText(getDefaultSettingsBuildScript())
7171
}
7272

73-
@ExperimentalPathApi
7473
@AfterEach
7574
fun cleanup() {
76-
runCatching {
77-
// TODO: workaround for https://github.com/junit-team/junit5/issues/2811.
78-
projectRoot.deleteRecursively()
79-
}
80-
8175
println(projectScriptPath.readText())
8276
}
8377

src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,15 @@ class RelocationTest : BasePluginTest() {
210210
)
211211
}
212212

213-
val classLoader = URLClassLoader(
214-
arrayOf(outputShadowJar.toUri().toURL()),
215-
ClassLoader.getSystemClassLoader().parent,
216-
)
217-
assertFailure {
218-
// check that the class can be loaded. If the file was not relocated properly, we should get a NoDefClassFound
219-
// Isolated class loader with only the JVM system jars and the output jar from the test project
220-
classLoader.loadClass("shadow.ShadowTest")
221-
fail("Should not reach here.")
222-
}.isInstanceOf(AssertionFailedError::class)
213+
val url = outputShadowJar.use { it.toUri().toURL() }
214+
URLClassLoader(arrayOf(url), ClassLoader.getSystemClassLoader().parent).use { classLoader ->
215+
assertFailure {
216+
// check that the class can be loaded. If the file was not relocated properly, we should get a NoDefClassFound
217+
// Isolated class loader with only the JVM system jars and the output jar from the test project
218+
classLoader.loadClass("shadow.ShadowTest")
219+
fail("Should not reach here.")
220+
}.isInstanceOf(AssertionFailedError::class)
221+
}
223222
}
224223

225224
@Test

0 commit comments

Comments
 (0)