diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt index 12de136e..93511dff 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/BuildScript.kt @@ -4,6 +4,7 @@ import com.beust.kobalt.api.IClasspathDependency import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.annotation.Directive import com.beust.kobalt.internal.KobaltSettings +import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.dependency.FileDependency import org.eclipse.aether.repository.Proxy @@ -71,5 +72,15 @@ fun authRepo(init: HostConfig.() -> Unit) = HostConfig().apply { init() } @Directive fun glob(g: String) : IFileSpec.GlobSpec = IFileSpec.GlobSpec(g) +/** + * The location of the local Maven repository. + */ @Directive -fun localMaven() = file(Kobalt.INJECTOR.getInstance(KobaltSettings::class.java).localMavenRepo.path) +fun localMaven() : String { + var result = file(Kobalt.INJECTOR.getInstance(KobaltSettings::class.java).localMavenRepo.path) + val pluginInfo = Kobalt.INJECTOR.getInstance(PluginInfo::class.java) + pluginInfo.localMavenRepoPathInterceptors.forEach { + result = it.repoPath(result) + } + return result +} diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ILocalMavenRepoPathInterceptor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ILocalMavenRepoPathInterceptor.kt new file mode 100644 index 00000000..77896a68 --- /dev/null +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ILocalMavenRepoPathInterceptor.kt @@ -0,0 +1,8 @@ +package com.beust.kobalt.api + +/** + * Plug-ins that want to + */ +interface ILocalMavenRepoPathInterceptor : IInterceptor { + fun repoPath(currentPath: String) : String +} diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt index 087b3a59..9ba885a8 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/KobaltPluginXml.kt @@ -95,6 +95,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, val buildConfigContributors = arrayListOf() val mavenIdInterceptors = arrayListOf() val jvmFlagContributors = arrayListOf() + val localMavenRepoPathInterceptors = arrayListOf() // Note: intentionally repeating them here even though they are defined by our base class so // that this class always contains the full list of contributors and interceptors @@ -210,6 +211,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, if (this is ITestJvmFlagContributor) testJvmFlagContributors.add(this) if (this is ITestJvmFlagInterceptor) testJvmFlagInterceptors.add(this) if (this is IJvmFlagContributor) jvmFlagContributors.add(this) + if (this is ILocalMavenRepoPathInterceptor) localMavenRepoPathInterceptors.add(this) } } } @@ -223,7 +225,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, testSourceDirContributors, buildConfigFieldContributors, taskContributors, incrementalTaskContributors, assemblyContributors, incrementalAssemblyContributors, testJvmFlagInterceptors, - jvmFlagContributors + jvmFlagContributors, localMavenRepoPathInterceptors ).forEach { it.forEach { it.cleanUpActors() @@ -263,6 +265,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?, testJvmFlagContributors.addAll(pluginInfo.testJvmFlagContributors) testJvmFlagInterceptors.addAll(pluginInfo.testJvmFlagInterceptors) jvmFlagContributors.addAll(pluginInfo.jvmFlagContributors) + localMavenRepoPathInterceptors.addAll(pluginInfo.localMavenRepoPathInterceptors) } }