diff --git a/example/kobalt/src/Build.kt b/example/kobalt/src/Build.kt index c833369..92c1a33 100644 --- a/example/kobalt/src/Build.kt +++ b/example/kobalt/src/Build.kt @@ -11,6 +11,8 @@ val pl = plugins(file("../kobaltBuild/libs/kobalt-maven-local-0.4.0-beta.jar")) val example = project { + //println(">>> LOCAL MAVEN REPO: " + localMaven()) + name = "example" group = "com.example" artifactId = name diff --git a/example/kobalt/wrapper/kobalt-wrapper.properties b/example/kobalt/wrapper/kobalt-wrapper.properties index f94d8df..a190289 100644 --- a/example/kobalt/wrapper/kobalt-wrapper.properties +++ b/example/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.861 \ No newline at end of file +kobalt.version=0.862 \ No newline at end of file diff --git a/example/kobaltw b/example/kobaltw index b27b3d8..c5186d5 100644 --- a/example/kobaltw +++ b/example/kobaltw @@ -1 +1,2 @@ -java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* +#!/usr/bin/env sh +java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $* diff --git a/example/local.properties b/example/local.properties new file mode 100644 index 0000000..fffcfac --- /dev/null +++ b/example/local.properties @@ -0,0 +1 @@ +maven-local-repo=K:/maven/repository diff --git a/kobalt-maven-local.ipr b/kobalt-maven-local.ipr index c4e7e35..2d77dad 100644 --- a/kobalt-maven-local.ipr +++ b/kobalt-maven-local.ipr @@ -413,6 +413,7 @@ + diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 7d3397a..f330d66 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -47,7 +47,7 @@ val p = project { } dependencies { - compile("com.beust:$kobaltDependency:0.861") + compile("com.beust:$kobaltDependency:0.862") compile("org.apache.maven:maven-settings-builder:3.3.9") } diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index f94d8df..a190289 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.861 \ No newline at end of file +kobalt.version=0.862 \ No newline at end of file diff --git a/kobaltw b/kobaltw index 3633f46..c5186d5 100644 --- a/kobaltw +++ b/kobaltw @@ -1,2 +1,2 @@ #!/usr/bin/env sh -java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* +java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $* diff --git a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/maven/local/MavenLocalPlugin.kt b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/maven/local/MavenLocalPlugin.kt index 8e4543a..0475559 100644 --- a/src/main/kotlin/net/thauvin/erik/kobalt/plugin/maven/local/MavenLocalPlugin.kt +++ b/src/main/kotlin/net/thauvin/erik/kobalt/plugin/maven/local/MavenLocalPlugin.kt @@ -33,24 +33,41 @@ package net.thauvin.erik.kobalt.plugin.maven.local import com.beust.kobalt.api.BasePlugin import com.beust.kobalt.api.ILocalMavenRepoPathInterceptor -import com.beust.kobalt.api.KobaltContext -import com.beust.kobalt.api.Project import com.beust.kobalt.misc.log +import com.beust.kobalt.misc.warn import org.apache.maven.settings.building.DefaultSettingsBuilderFactory import org.apache.maven.settings.building.DefaultSettingsBuildingRequest import java.io.File +import java.io.FileInputStream +import java.util.* public class MavenLocalPlugin : BasePlugin(), ILocalMavenRepoPathInterceptor { - var mavenLocalPath: String = "" + val MAVEN_LOCAL_REPO_PROPERTY = "maven-local-repo" + + var mavenLocalPath: String? = null override val name = "kobalt-maven-local" - override fun apply(project: Project, context: KobaltContext) { + init { val factory = DefaultSettingsBuilderFactory() val builder = factory.newInstance() val settings = DefaultSettingsBuildingRequest() + val localProps = Properties().apply { + FileInputStream("local.properties").use { fis -> load(fis) } + } + +// val sysProps = Properties() +// sysProps.putAll(System.getProperties()) +// if (localProps.isNotEmpty()) { +// if (localProps.containsKey(MAVEN_LOCAL_REPO_PROPERTY)) { +// sysProps.put(MAVEN_LOCAL_REPO_PROPERTY, localProps.getProperty(MAVEN_LOCAL_REPO_PROPERTY)) +// } +// } +// settings.systemProperties = sysProps + settings.systemProperties = System.getProperties() + settings.userSettingsFile = File(System.getProperty("user.home"), ".m2/settings.xml") val m2Home = System.getProperty("M2_HOME") @@ -60,12 +77,16 @@ public class MavenLocalPlugin : BasePlugin(), ILocalMavenRepoPathInterceptor { val result = builder.build(settings) mavenLocalPath = result.effectiveSettings.localRepository + + if (mavenLocalPath == null) { + warn("Unable to parse local maven settings.") + } } override fun repoPath(currentPath: String): String { - if (mavenLocalPath.isNotEmpty()) { - log(2, "Setting maven local repository path to: " + mavenLocalPath) - return mavenLocalPath + if (mavenLocalPath != null) { + log(2, "Setting Maven Local Repository path to: " + mavenLocalPath) + return mavenLocalPath.toString() } else { return currentPath }