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

Add support for native dependencies.

This commit is contained in:
Cedric Beust 2016-06-14 22:32:46 -08:00
parent 438e72038a
commit d8bbe547ae
8 changed files with 77 additions and 6 deletions

View file

@ -14,6 +14,7 @@ interface IDependencyHolder {
val compileProvidedDependencies : ArrayList<IClasspathDependency>
val compileRuntimeDependencies : ArrayList<IClasspathDependency>
val excludedDependencies : ArrayList<IClasspathDependency>
val nativeDependencies : ArrayList<IClasspathDependency>
@Directive
var dependencies: Dependencies?
@ -28,12 +29,13 @@ open class DependencyHolder : IDependencyHolder {
override val compileProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
override val compileRuntimeDependencies : ArrayList<IClasspathDependency> = arrayListOf()
override val excludedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
override val nativeDependencies : ArrayList<IClasspathDependency> = arrayListOf()
override var dependencies : Dependencies? = null
override fun dependencies(init: Dependencies.() -> Unit) : Dependencies {
dependencies = Dependencies(project, compileDependencies, compileProvidedDependencies,
compileRuntimeDependencies, excludedDependencies)
compileRuntimeDependencies, excludedDependencies, nativeDependencies)
dependencies!!.init()
return dependencies!!
}

View file

@ -0,0 +1,13 @@
package com.beust.kobalt.api
/**
* Plug-ins that add flags to the JVM used to run apps should implement this interface.
*/
interface IJvmFlagContributor : IContributor {
/**
* The list of JVM flags that will be added to the JVM when the app gets run. @param[currentFlags] is only here
* for convenience, in case you need to look at the current JVM flags before adding your own flags.
*/
fun jvmFlagsFor(project: Project, context: KobaltContext, currentFlags: List<String>) : List<String>
}

View file

@ -90,7 +90,7 @@ open class Project(
@Directive
fun dependenciesTest(init: Dependencies.() -> Unit) : Dependencies {
dependencies = Dependencies(this, testDependencies, testProvidedDependencies, compileRuntimeDependencies,
excludedDependencies)
excludedDependencies, nativeDependencies)
dependencies!!.init()
return dependencies!!
}
@ -138,7 +138,8 @@ class Dependencies(val project: Project,
val dependencies: ArrayList<IClasspathDependency>,
val providedDependencies: ArrayList<IClasspathDependency>,
val runtimeDependencies: ArrayList<IClasspathDependency>,
val excludedDependencies: ArrayList<IClasspathDependency>) {
val excludedDependencies: ArrayList<IClasspathDependency>,
val nativeDependencies: ArrayList<IClasspathDependency>) {
/**
* Add the dependencies to the given ArrayList and return a list of future jar files corresponding to
@ -164,6 +165,9 @@ class Dependencies(val project: Project,
@Directive
fun exclude(vararg dep: String) = addToDependencies(project, excludedDependencies, dep)
@Directive
fun native(vararg dep: String) = addToDependencies(project, nativeDependencies, dep)
}
class Scm(val connection: String, val developerConnection: String, val url: String)

View file

@ -93,6 +93,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
// Not documented yet
val buildConfigContributors = arrayListOf<IBuildConfigContributor>()
val mavenIdInterceptors = arrayListOf<IMavenIdInterceptor>()
val jvmFlagContributors = arrayListOf<IJvmFlagContributor>()
// 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
@ -206,6 +207,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
// Not documented yet
if (this is ITestJvmFlagContributor) testJvmFlagContributors.add(this)
if (this is ITestJvmFlagInterceptor) testJvmFlagInterceptors.add(this)
if (this is IJvmFlagContributor) jvmFlagContributors.add(this)
}
}
}
@ -218,7 +220,8 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
compilerContributors, docContributors, sourceDirContributors,
testSourceDirContributors, buildConfigFieldContributors,
taskContributors, assemblyContributors,
incrementalAssemblyContributors, testJvmFlagInterceptors
incrementalAssemblyContributors, testJvmFlagInterceptors,
jvmFlagContributors
).forEach {
it.forEach {
it.cleanUpActors()
@ -256,6 +259,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
incrementalAssemblyContributors.addAll(pluginInfo.incrementalAssemblyContributors)
testJvmFlagContributors.addAll(pluginInfo.testJvmFlagContributors)
testJvmFlagInterceptors.addAll(pluginInfo.testJvmFlagInterceptors)
jvmFlagContributors.addAll(pluginInfo.jvmFlagContributors)
}
}

View file

@ -65,6 +65,10 @@ class KFiles {
val TEST_CLASSES_DIR : String = "test-classes"
val NATIVES_DIR : String = "native"
fun nativeBuildDir(project: Project) = KFiles.joinDir(project.directory, project.buildDirectory, NATIVES_DIR)
fun generatedSourceDir(project: Project, variant: Variant, name: String) =
KFiles.joinDir(project.directory, project.buildDirectory, "generated", "source", name,
variant.toIntermediateDir())