-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
48 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...lin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.github.jengelman.gradle.plugins.shadow.transformers | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.exists | ||
import assertk.assertions.isEqualTo | ||
import kotlin.io.path.appendText | ||
import org.junit.jupiter.api.Test | ||
|
||
class ServiceFileTransformerTest : BaseTransformerTest() { | ||
|
||
@Test | ||
fun serviceResourceTransformer() { | ||
projectScriptPath.appendText( | ||
transform<ServiceFileTransformer>( | ||
shadowBlock = fromJar(buildJarOne(), buildJarTwo()), | ||
transformerBlock = """ | ||
exclude 'META-INF/services/com.acme.*' | ||
""".trimIndent(), | ||
), | ||
) | ||
|
||
run(shadowJarTask) | ||
|
||
assertThat(outputShadowJar).exists() | ||
|
||
val text1 = getJarFileContents(outputShadowJar, ENTRY_SERVICES_SHADE) | ||
assertThat(text1).isEqualTo(CONTENT_ONE_TWO) | ||
|
||
val text2 = getJarFileContents(outputShadowJar, ENTRY_SERVICES_FOO) | ||
assertThat(text2).isEqualTo("one") | ||
} | ||
|
||
@Test | ||
fun serviceResourceTransformerAlternatePath() { | ||
val one = buildJarOne { | ||
insert(ENTRY_FOO_SHADE, CONTENT_ONE) | ||
} | ||
val two = buildJarTwo { | ||
insert(ENTRY_FOO_SHADE, CONTENT_TWO) | ||
} | ||
projectScriptPath.appendText( | ||
transform<ServiceFileTransformer>( | ||
shadowBlock = fromJar(one, two), | ||
transformerBlock = """ | ||
path = "META-INF/foo" | ||
""".trimIndent(), | ||
), | ||
) | ||
|
||
run(shadowJarTask) | ||
|
||
assertThat(outputShadowJar).exists() | ||
|
||
val text = getJarFileContents(outputShadowJar, ENTRY_FOO_SHADE) | ||
assertThat(text).isEqualTo(CONTENT_ONE_TWO) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters