Moved code from apply {} to init {}
This commit is contained in:
parent
ac373c53d1
commit
feebc92d57
9 changed files with 38 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.861
|
||||
kobalt.version=0.862
|
|
@ -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" $*
|
||||
|
|
1
example/local.properties
Normal file
1
example/local.properties
Normal file
|
@ -0,0 +1 @@
|
|||
maven-local-repo=K:/maven/repository
|
|
@ -413,6 +413,7 @@
|
|||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.861/kobalt/wrapper/kobalt-0.861.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.861/kobalt/wrapper/kobalt-0.861.jar!/" />
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-0.861/kobalt/wrapper/kobalt-0.861.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.861
|
||||
kobalt.version=0.862
|
2
kobaltw
2
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" $*
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue