Initial commit.
This commit is contained in:
commit
ec2ca3184a
20 changed files with 770 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
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 org.apache.maven.settings.building.DefaultSettingsBuilderFactory
|
||||
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest
|
||||
import java.io.File
|
||||
|
||||
public class MavenLocalPlugin : BasePlugin(), ILocalMavenRepoPathInterceptor {
|
||||
var mavenLocalPath: String = ""
|
||||
|
||||
override val name = "kobalt-maven-local"
|
||||
|
||||
override fun apply(project: Project, context: KobaltContext) {
|
||||
val factory = DefaultSettingsBuilderFactory()
|
||||
val builder = factory.newInstance()
|
||||
val settings = DefaultSettingsBuildingRequest()
|
||||
|
||||
settings.systemProperties = System.getProperties()
|
||||
settings.userSettingsFile = File(System.getProperty("user.home"), ".m2/settings.xml")
|
||||
|
||||
val m2Home = System.getProperty("M2_HOME")
|
||||
if (m2Home != null) {
|
||||
settings.globalSettingsFile = File(m2Home, "conf/settings.xml")
|
||||
}
|
||||
|
||||
val result = builder.build(settings)
|
||||
mavenLocalPath = result.effectiveSettings.localRepository
|
||||
}
|
||||
|
||||
override fun repoPath(currentPath: String): String {
|
||||
if (mavenLocalPath.isNotEmpty()) {
|
||||
log(2, "Setting maven local repository path to: " + mavenLocalPath)
|
||||
return mavenLocalPath
|
||||
} else {
|
||||
return currentPath
|
||||
}
|
||||
}
|
||||
}
|
6
src/main/resources/META-INF/kobalt-plugin.xml
Normal file
6
src/main/resources/META-INF/kobalt-plugin.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<kobalt-plugin>
|
||||
<name>kobalt-maven-local</name>
|
||||
<plugin-actors>
|
||||
<class-name>net.thauvin.erik.kobalt.plugin.maven.local.MavenLocalPlugin</class-name>
|
||||
</plugin-actors>
|
||||
</kobalt-plugin>
|
8
src/test/kotlin/com/example/MainTest.kt
Normal file
8
src/test/kotlin/com/example/MainTest.kt
Normal file
|
@ -0,0 +1,8 @@
|
|||
package com.example
|
||||
|
||||
import org.testng.annotations.Test
|
||||
|
||||
class ExampleTest {
|
||||
@Test
|
||||
fun f() = println("Running test")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue