diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenFileRepository.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenFileRepository.groovy new file mode 100644 index 000000000..18e4331da --- /dev/null +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenFileRepository.groovy @@ -0,0 +1,14 @@ +package com.github.jengelman.gradle.plugins.shadow.util + +import com.github.jengelman.gradle.plugins.shadow.util.repo.maven.MavenFileRepository +import groovy.transform.InheritConstructors + +@InheritConstructors +class AppendableMavenFileRepository extends MavenFileRepository { + + @Override + AppendableMavenFileModule module(String groupId, String artifactId, String version = '1.0') { + def artifactDir = rootDir.resolve("${groupId.replace('.', '/')}/$artifactId/$version") + return new AppendableMavenFileModule(artifactDir, groupId, artifactId, version as String) + } +} diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileModule.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileModule.groovy new file mode 100644 index 000000000..80d482224 --- /dev/null +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileModule.groovy @@ -0,0 +1,46 @@ +package com.github.jengelman.gradle.plugins.shadow.util.repo.maven + +import org.jetbrains.annotations.NotNull + +class MavenFileModule extends AbstractMavenModule { + private boolean uniqueSnapshots = true + + MavenFileModule(File moduleDir, String groupId, String artifactId, String version) { + super(moduleDir, groupId, artifactId, version) + } + + @Override + boolean getUniqueSnapshots() { + return uniqueSnapshots + } + + @Override + String getMetaDataFileContent() { + """ + + + $groupId + $artifactId + $version + + + ${timestampFormat.format(publishTimestamp)} + $publishCount + + ${updateFormat.format(publishTimestamp)} + + + """.stripIndent() + } + + @Override + protected void onPublish(@NotNull File file) { + sha1File(file) + md5File(file) + } + + @Override + protected boolean publishesMetaDataFile() { + uniqueSnapshots && version.endsWith("-SNAPSHOT") + } +} diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileRepository.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileRepository.groovy new file mode 100644 index 000000000..fdff3a8ed --- /dev/null +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileRepository.groovy @@ -0,0 +1,23 @@ +package com.github.jengelman.gradle.plugins.shadow.util.repo.maven + +/** + * A fixture for dealing with file Maven repositories. + */ +class MavenFileRepository implements MavenRepository { + final File rootDir + + MavenFileRepository(File rootDir) { + this.rootDir = rootDir + } + + @Override + URI getUri() { + return rootDir.toURI() + } + + @Override + MavenFileModule module(String groupId, String artifactId, String version = '1.0') { + def artifactDir = rootDir.resolve("${groupId.replace('.', '/')}/$artifactId/$version") + return new MavenFileModule(artifactDir, groupId, artifactId, version as String) + } +} diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenFileRepository.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenFileRepository.kt deleted file mode 100644 index b0441362b..000000000 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/AppendableMavenFileRepository.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.github.jengelman.gradle.plugins.shadow.util - -import com.github.jengelman.gradle.plugins.shadow.util.repo.maven.MavenFileRepository -import java.io.File - -class AppendableMavenFileRepository(rootDir: File) : MavenFileRepository(rootDir) { - - override fun module(groupId: String, artifactId: String, version: String): AppendableMavenFileModule { - val artifactDir = rootDir.resolve("${groupId.replace('.', '/')}/$artifactId/$version") - return AppendableMavenFileModule(artifactDir, groupId, artifactId, version) - } -} diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileModule.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileModule.kt deleted file mode 100644 index 81b23ec0e..000000000 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileModule.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.github.jengelman.gradle.plugins.shadow.util.repo.maven - -import java.io.File -import org.intellij.lang.annotations.Language -import org.jetbrains.annotations.NotNull - -class MavenFileModule( - moduleDir: File, - groupId: String, - artifactId: String, - version: String, -) : AbstractMavenModule(moduleDir, groupId, artifactId, version) { - - override fun getUniqueSnapshots(): Boolean = uniqueSnapshots - - @Language("XML") - override fun getMetaDataFileContent(): String { - return """ - - - $groupId - $artifactId - $version - - - ${timestampFormat.format(publishTimestamp)} - $publishCount - - ${updateFormat.format(publishTimestamp)} - - - """.trimIndent() - } - - override fun onPublish(@NotNull file: File) { - sha1File(file) - md5File(file) - } - - override fun publishesMetaDataFile(): Boolean { - return uniqueSnapshots && version.endsWith("-SNAPSHOT") - } -} diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileRepository.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileRepository.kt deleted file mode 100644 index 026ebd8de..000000000 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/repo/maven/MavenFileRepository.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.jengelman.gradle.plugins.shadow.util.repo.maven - -import java.io.File -import java.net.URI - -/** - * A fixture for dealing with file Maven repositories. - */ -abstract class MavenFileRepository(val rootDir: File) : MavenRepository { - - override val uri: URI = rootDir.toURI() - - override fun module(groupId: String, artifactId: String): MavenModule { - return module(groupId, artifactId, "1.0") - } - - override fun module(groupId: String, artifactId: String, version: String): MavenModule { - val artifactDir = rootDir.resolve("${groupId.replace('.', '/')}/$artifactId/$version") - return MavenFileModule(artifactDir, groupId, artifactId, version) - } -}