diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt index cd4ba5fc..5f544674 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt @@ -12,14 +12,14 @@ open class SimpleDep(open val mavenId: MavenId) : UnversionedDep(mavenId.groupId val version: String get() = mavenId.version!! private fun toFile(version: Version, suffix: String): String { + val dir = toDirectory(version.version, false, trailingSlash = false) val list = - if (version.snapshotTimestamp != null) { - listOf(toDirectory(version.version, false), - artifactId + "-" + version.noSnapshotVersion + "-" + version.snapshotTimestamp + suffix) - } else { - listOf(toDirectory(version.version, false), artifactId + "-" + version.version + suffix) - } - return list.joinToString("/") + if (version.snapshotTimestamp != null) { + listOf(dir, artifactId + "-" + version.noSnapshotVersion + "-" + version.snapshotTimestamp + suffix) + } else { + listOf(dir, artifactId + "-" + version.version + suffix) + } + return list.joinToString("/").replace("//", "/") } fun toPomFile(v: String) = toFile(Version.of(v), ".pom") @@ -28,8 +28,6 @@ open class SimpleDep(open val mavenId: MavenId) : UnversionedDep(mavenId.groupId fun toJarFile(v: String = version) = toFile(Version.of(v), suffix) - fun toJarFile(v: Version) = toFile(v, suffix) - fun toPomFileName() = "$artifactId-$version.pom" fun toJarFile(r: RepoFinder.RepoResult) = toFile(r.snapshotVersion ?: r.version!!, suffix) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt index ed76b1d3..e573bdb7 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt @@ -19,13 +19,12 @@ open class UnversionedDep(open val groupId: String, open val artifactId: String) /** * Turn this dependency to a directory. If fileSystem is true, use the file system - * dependent path separator, otherwise, use '/' (used to create URL's). The returned - * string always ends with the path separator. + * dependent path separator, otherwise, use '/' (used to create URL's). */ - fun toDirectory(v: String, fileSystem: Boolean = true): String { + fun toDirectory(v: String, fileSystem: Boolean = true, trailingSlash: Boolean = true): String { val sep = if (fileSystem) File.separator else "/" val l = listOf(groupId.replace(".", sep), artifactId, v) val result = Strings.Companion.join(sep, l) - return if (result.endsWith(sep)) result else result + sep + return if (trailingSlash && ! result.endsWith(sep)) result + sep else result } }