From 9d4d9dce5fb0d52932d21e0f8404d89a9335938e Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 12 Dec 2015 01:06:18 +0400 Subject: [PATCH] Local metadata is called maven-metadata-local.xml. --- src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt | 7 +++++-- src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt | 4 ---- src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt b/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt index d79eab24..6d50105a 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt @@ -2,6 +2,7 @@ package com.beust.kobalt.maven import com.beust.kobalt.HostConfig import com.beust.kobalt.api.Kobalt +import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.Strings import com.beust.kobalt.misc.log @@ -78,7 +79,8 @@ public class RepoFinder @Inject constructor(val executors: KobaltExecutors) { if (! mavenId.hasVersion) { val ud = UnversionedDep(groupId, artifactId) - val foundVersion = findCorrectVersionRelease(ud.toMetadataXmlPath(false), repoUrl) + val isLocal = repoUrl.startsWith(FileDependency.PREFIX_FILE) + val foundVersion = findCorrectVersionRelease(ud.toMetadataXmlPath(false, isLocal), repoUrl) if (foundVersion != null) { return RepoResult(repo, true, foundVersion) } else { @@ -88,7 +90,8 @@ public class RepoFinder @Inject constructor(val executors: KobaltExecutors) { val version = mavenId.version if (version!!.contains("SNAPSHOT")) { val dep = SimpleDep(mavenId) - val snapshotVersion = findSnapshotVersion(dep.toMetadataXmlPath(false), repoUrl) + val isLocal = repoUrl.startsWith(FileDependency.PREFIX_FILE) + val snapshotVersion = findSnapshotVersion(dep.toMetadataXmlPath(false, isLocal), repoUrl) if (snapshotVersion != null) { return RepoResult(repo, true, version, true /* hasJar, potential bug here */, snapshotVersion) diff --git a/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt b/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt index 9f1c7c71..50e6120b 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/SimpleDep.kt @@ -11,10 +11,6 @@ open public class SimpleDep(open val mavenId: MavenId) : UnversionedDep(mavenId. val version: String get() = mavenId.version!! - override public fun toMetadataXmlPath(fileSystem: Boolean): String { - return toDirectory(version, fileSystem) + "maven-metadata.xml" - } - private fun toFile(v: String, s: String, suffix: String) : String { val fv = if (v.contains("SNAPSHOT")) v.replace("SNAPSHOT", "") else v val result = Strings.join("/", arrayListOf(toDirectory(v, false) + diff --git a/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt b/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt index a8e58b00..2e3f0c79 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/UnversionedDep.kt @@ -8,8 +8,8 @@ import java.io.File * eventually resolve to the latest version of the artifact. */ open public class UnversionedDep(open val groupId: String, open val artifactId: String) { - open public fun toMetadataXmlPath(fileSystem: Boolean = true): String { - return toDirectory("", fileSystem) + "maven-metadata.xml" + open public fun toMetadataXmlPath(fileSystem: Boolean = true, isLocal: Boolean): String { + return toDirectory("", fileSystem) + if (isLocal) "maven-metadata-local.xml" else "maven-metadata.xml" } /**