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 @@ -9,7 +9,7 @@ import java.util.Properties
/**
* Provides functionality for reproducible serialization.
*/
internal class CleanProperties : Properties() {
internal class ReproducibleProperties : Properties() {
override fun store(writer: Writer, comments: String) {
throw UnsupportedOperationException("use writeWithoutComments()")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.jengelman.gradle.plugins.shadow.transformers

import com.github.jengelman.gradle.plugins.shadow.internal.CleanProperties
import com.github.jengelman.gradle.plugins.shadow.internal.ReproducibleProperties
import com.github.jengelman.gradle.plugins.shadow.internal.mapProperty
import com.github.jengelman.gradle.plugins.shadow.internal.property
import com.github.jengelman.gradle.plugins.shadow.internal.setProperty
Expand Down Expand Up @@ -108,7 +108,7 @@ public open class PropertiesFileTransformer @Inject constructor(
internal val conflicts: MutableMap<String, MutableMap<String, Int>> = mutableMapOf()

@get:Internal
internal val propertiesEntries = mutableMapOf<String, CleanProperties>()
internal val propertiesEntries = mutableMapOf<String, ReproducibleProperties>()

@get:Input
public open val paths: SetProperty<String> = objectFactory.setProperty()
Expand Down Expand Up @@ -149,7 +149,7 @@ public open class PropertiesFileTransformer @Inject constructor(
}

override fun transform(context: TransformerContext) {
val props = propertiesEntries.computeIfAbsent(context.path) { CleanProperties() }
val props = propertiesEntries.computeIfAbsent(context.path) { ReproducibleProperties() }
loadAndTransformKeys(context.inputStream) { key, value ->
if (props.containsKey(key)) {
when (MergeStrategy.from(mergeStrategyFor(context.path))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import java.nio.charset.StandardCharsets
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource

class CleanPropertiesTest {
class ReproduciblePropertiesTest {
@ParameterizedTest
@MethodSource("generalCharsetsProvider")
fun emptyProperties(charset: Charset) {
val output = CleanProperties().writeToString(charset)
val output = ReproducibleProperties().writeToString(charset)

assertThat(output).isEqualTo("")
}

@ParameterizedTest
@MethodSource("generalCharsetsProvider")
fun asciiProps(charset: Charset) {
val output = CleanProperties().also { props ->
val output = ReproducibleProperties().also { props ->
props["key"] = "value"
props["key2"] = "value2"
props["a"] = "b"
Expand Down Expand Up @@ -50,7 +50,7 @@ class CleanPropertiesTest {
@ParameterizedTest
@MethodSource("utfCharsetsProvider")
fun utfProps(charset: Charset) {
val output = CleanProperties().also { props ->
val output = ReproducibleProperties().also { props ->
props["äöüß"] = "aouss"
props["áèô"] = "aeo"
props["€²³"] = "x"
Expand Down Expand Up @@ -81,7 +81,7 @@ class CleanPropertiesTest {
StandardCharsets.UTF_16,
)

fun CleanProperties.writeToString(charset: Charset): String {
fun ReproducibleProperties.writeToString(charset: Charset): String {
return ByteArrayOutputStream().also { writeWithoutComments(charset, it) }
.toString(charset.name()).invariantEolString
}
Expand Down