1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Introducing ILocalMavenRepoPathInterceptor.

This commit is contained in:
Cedric Beust 2016-07-19 21:45:44 -08:00
parent 19d18bce82
commit 2251a1254a
3 changed files with 24 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import com.beust.kobalt.api.IClasspathDependency
import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.annotation.Directive import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.internal.KobaltSettings import com.beust.kobalt.internal.KobaltSettings
import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.maven.dependency.FileDependency
import org.eclipse.aether.repository.Proxy import org.eclipse.aether.repository.Proxy
@ -71,5 +72,15 @@ fun authRepo(init: HostConfig.() -> Unit) = HostConfig().apply { init() }
@Directive @Directive
fun glob(g: String) : IFileSpec.GlobSpec = IFileSpec.GlobSpec(g) fun glob(g: String) : IFileSpec.GlobSpec = IFileSpec.GlobSpec(g)
/**
* The location of the local Maven repository.
*/
@Directive @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
}

View file

@ -0,0 +1,8 @@
package com.beust.kobalt.api
/**
* Plug-ins that want to
*/
interface ILocalMavenRepoPathInterceptor : IInterceptor {
fun repoPath(currentPath: String) : String
}

View file

@ -95,6 +95,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
val buildConfigContributors = arrayListOf<IBuildConfigContributor>() val buildConfigContributors = arrayListOf<IBuildConfigContributor>()
val mavenIdInterceptors = arrayListOf<IMavenIdInterceptor>() val mavenIdInterceptors = arrayListOf<IMavenIdInterceptor>()
val jvmFlagContributors = arrayListOf<IJvmFlagContributor>() val jvmFlagContributors = arrayListOf<IJvmFlagContributor>()
val localMavenRepoPathInterceptors = arrayListOf<ILocalMavenRepoPathInterceptor>()
// Note: intentionally repeating them here even though they are defined by our base class so // 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 // 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 ITestJvmFlagContributor) testJvmFlagContributors.add(this)
if (this is ITestJvmFlagInterceptor) testJvmFlagInterceptors.add(this) if (this is ITestJvmFlagInterceptor) testJvmFlagInterceptors.add(this)
if (this is IJvmFlagContributor) jvmFlagContributors.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, testSourceDirContributors, buildConfigFieldContributors,
taskContributors, incrementalTaskContributors, assemblyContributors, taskContributors, incrementalTaskContributors, assemblyContributors,
incrementalAssemblyContributors, testJvmFlagInterceptors, incrementalAssemblyContributors, testJvmFlagInterceptors,
jvmFlagContributors jvmFlagContributors, localMavenRepoPathInterceptors
).forEach { ).forEach {
it.forEach { it.forEach {
it.cleanUpActors() it.cleanUpActors()
@ -263,6 +265,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
testJvmFlagContributors.addAll(pluginInfo.testJvmFlagContributors) testJvmFlagContributors.addAll(pluginInfo.testJvmFlagContributors)
testJvmFlagInterceptors.addAll(pluginInfo.testJvmFlagInterceptors) testJvmFlagInterceptors.addAll(pluginInfo.testJvmFlagInterceptors)
jvmFlagContributors.addAll(pluginInfo.jvmFlagContributors) jvmFlagContributors.addAll(pluginInfo.jvmFlagContributors)
localMavenRepoPathInterceptors.addAll(pluginInfo.localMavenRepoPathInterceptors)
} }
} }