Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,19 @@ abstract class BasePluginTest {
// Circular dependency with e.
addDependency(e)
}
val g =
jarModule("my", "g", "1.0") {
buildJar { insert("g.properties", "g") }
addDependency(pomModule("my", "pom-dep", "1.0"))
}
bomModule("my", "bom", "1.0") {
addDependency(a)
addDependency(b)
addDependency(c)
addDependency(d)
addDependency(e)
addDependency(f)
addDependency(g)
}
}
localRepo.publish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,29 @@ class FilteringTest : BasePluginTest() {
}
}

@Test
fun excludeNonJarTransitiveDependency() {
projectScript.appendText(
"""
|dependencies {
| implementation 'my:g:1.0'
|}
|$shadowJarTask {
| dependencies {
| exclude(dependency('my:pom-dep:.*'))
| }
|}
"""
.trimMargin()
)

runWithSuccess(shadowJarPath)

assertThat(outputShadowedJar).useAll {
containsOnly("g.properties", *entriesInAB, "META-INF/", "META-INF/MANIFEST.MF")
}
}

private fun commonAssertions() {
assertThat(outputShadowedJar).useAll {
containsOnly("c.properties", *entriesInAB, "META-INF/", "META-INF/MANIFEST.MF")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,40 @@ class R8MinimizationTest : BasePluginTest() {
assertThat(result.output).contains("R8 launcher JDK ${JavaVersion.current().majorVersion}")
}

@Test
fun passCustomR8Args() {
writeR8AppAndLibModules(
appShadowBlock =
"""
|minimize {
| r8 {
| // Disable shrinking to prove custom R8 args are passed through.
| args.add("--no-tree-shaking")
| }
|}
"""
.trimMargin()
)

runWithSuccess(appShadowJarPath)

assertThat(outputAppShadowedJar).useAll {
containsOnly(
"a/a.class",
"a/b.class",
"a/c.class",
"app/App.class",
"META-INF/MANIFEST.MF",
)
classLoader {
loadClass("app.App")
loadClass("a.a")
loadClass("a.b")
loadClass("a.c")
}
}
}

@Test
fun supportClasspathInR8() {
writeR8AppAndLibModules(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ class AppendableMavenRepository(val root: Path) {
return bomModule.coordinate
}

fun pomModule(
groupId: String,
artifactId: String,
version: String,
action: PomModule.() -> Unit = {},
): String {
val pomModule = PomModule(groupId, artifactId, version).also(action)
modules += pomModule
return pomModule.coordinate
}

fun publish() {
check(modules.isNotEmpty()) { "No modules to publish. Please add at least one module." }
val writer = MavenXpp3Writer()
Expand All @@ -68,6 +79,10 @@ class AppendableMavenRepository(val root: Path) {
dependencyManagement =
DependencyManagement().apply { dependencies = module.dependencies }
}
is PomModule -> {
packaging = "pom"
dependencies = module.dependencies
}
}
}

Expand Down Expand Up @@ -142,6 +157,9 @@ class AppendableMavenRepository(val root: Path) {

class BomModule(groupId: String, artifactId: String, version: String) :
Module(groupId, artifactId, version)

class PomModule(groupId: String, artifactId: String, version: String) :
Module(groupId, artifactId, version)
}

private val logger = Logging.getLogger(AppendableMavenRepository::class.java)
Expand Down