File tree Expand file tree Collapse file tree 3 files changed +12
-19
lines changed
src/funcTest/kotlin/com/github/jengelman/gradle/plugins/shadow Expand file tree Collapse file tree 3 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ class ApplicationTest : BasePluginTest() {
77
77
val zip = path(" build/distributions/myapp-shadow-1.0.zip" )
78
78
assertThat(zip).exists()
79
79
80
- val entries = ZipFile (zip.toFile()).entries.toList().map { it.name }
80
+ val entries = ZipFile (zip.toFile()).use { it. entries } .toList().map { it.name }
81
81
assertThat(entries).containsAtLeast(
82
82
" myapp-shadow-1.0/lib/myapp-1.0-all.jar" ,
83
83
" myapp-shadow-1.0/lib/a-1.0.jar" ,
Original file line number Diff line number Diff line change @@ -36,9 +36,11 @@ import org.junit.jupiter.api.AfterEach
36
36
import org.junit.jupiter.api.BeforeAll
37
37
import org.junit.jupiter.api.BeforeEach
38
38
import org.junit.jupiter.api.TestInstance
39
+ import org.junit.jupiter.api.io.TempDir
39
40
40
41
@TestInstance(TestInstance .Lifecycle .PER_CLASS )
41
42
abstract class BasePluginTest {
43
+ @TempDir
42
44
lateinit var projectRoot: Path
43
45
lateinit var localRepo: AppendableMavenRepository
44
46
@@ -64,20 +66,12 @@ abstract class BasePluginTest {
64
66
65
67
@BeforeEach
66
68
open fun setup () {
67
- projectRoot = createTempDirectory()
68
-
69
69
projectScriptPath.writeText(getDefaultProjectBuildScript(withGroup = true , withVersion = true ))
70
70
settingsScriptPath.writeText(getDefaultSettingsBuildScript())
71
71
}
72
72
73
- @ExperimentalPathApi
74
73
@AfterEach
75
74
fun cleanup () {
76
- runCatching {
77
- // TODO: workaround for https://github.com/junit-team/junit5/issues/2811.
78
- projectRoot.deleteRecursively()
79
- }
80
-
81
75
println (projectScriptPath.readText())
82
76
}
83
77
Original file line number Diff line number Diff line change @@ -210,16 +210,15 @@ class RelocationTest : BasePluginTest() {
210
210
)
211
211
}
212
212
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
+ }
223
222
}
224
223
225
224
@Test
You can’t perform that action at this time.
0 commit comments