mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
Add provided dependencies.
This commit is contained in:
parent
d8e8cb8b41
commit
9f3a1f6f3b
3 changed files with 28 additions and 12 deletions
|
@ -64,21 +64,23 @@ open public class Project(
|
|||
|
||||
@Directive
|
||||
public fun dependencies(init: Dependencies.() -> Unit) : Dependencies {
|
||||
dependencies = Dependencies(this, compileDependencies)
|
||||
dependencies = Dependencies(this, compileDependencies, compileProvidedDependencies)
|
||||
dependencies!!.init()
|
||||
return dependencies!!
|
||||
}
|
||||
|
||||
public val compileDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val compileDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val compileProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
|
||||
@Directive
|
||||
public fun dependenciesTest(init: Dependencies.() -> Unit) : Dependencies {
|
||||
dependencies = Dependencies(this, testDependencies)
|
||||
dependencies = Dependencies(this, testDependencies, testProvidedDependencies)
|
||||
dependencies!!.init()
|
||||
return dependencies!!
|
||||
}
|
||||
|
||||
public val testDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val testDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val testProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
}
|
||||
|
||||
public class Sources(val project: Project, val sources: ArrayList<String>) {
|
||||
|
@ -88,10 +90,16 @@ public class Sources(val project: Project, val sources: ArrayList<String>) {
|
|||
}
|
||||
}
|
||||
|
||||
public class Dependencies(val project: Project, val dependencies: ArrayList<IClasspathDependency>) {
|
||||
public class Dependencies(val project: Project, val dependencies: ArrayList<IClasspathDependency>,
|
||||
val providedDependencies: ArrayList<IClasspathDependency>) {
|
||||
@Directive
|
||||
fun compile(vararg dep: String) {
|
||||
dep.forEach { dependencies.add(MavenDependency.create(it)) }
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun provided(vararg dep: String) {
|
||||
dep.forEach { providedDependencies.add(MavenDependency.create(it))}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,16 +37,24 @@ abstract public class JvmCompilerPlugin @Inject constructor(
|
|||
log(1, "${project.name}: ${s}")
|
||||
}
|
||||
|
||||
fun calculateClasspath(dependencies : List<IClasspathDependency>): List<IClasspathDependency> {
|
||||
return dependencyManager.transitiveClosure(dependencies)
|
||||
fun calculateClasspath(vararg allDependencies : List<IClasspathDependency>): List<IClasspathDependency> {
|
||||
var result = arrayListOf<IClasspathDependency>()
|
||||
allDependencies.forEach { dependencies ->
|
||||
result.addAll(dependencyManager.transitiveClosure(dependencies))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
protected fun testDependencies(project: Project) : List<IClasspathDependency> {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
result.add(FileDependency(makeOutputDir(project).getAbsolutePath()))
|
||||
result.add(FileDependency(makeOutputTestDir(project).getAbsolutePath()))
|
||||
result.addAll(calculateClasspath(project.compileDependencies))
|
||||
result.addAll(calculateClasspath(project.testDependencies))
|
||||
result.add(FileDependency(makeOutputDir(project).absolutePath))
|
||||
result.add(FileDependency(makeOutputTestDir(project).absolutePath))
|
||||
with(project) {
|
||||
arrayListOf(compileDependencies, compileProvidedDependencies, testDependencies,
|
||||
testProvidedDependencies).forEach {
|
||||
result.addAll(calculateClasspath(it))
|
||||
}
|
||||
}
|
||||
return dependencyManager.reorderDependencies(result)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class KotlinPlugin @Inject constructor(
|
|||
@Task(name = TASK_COMPILE, description = "Compile the project")
|
||||
fun taskCompile(project: Project): TaskResult {
|
||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
||||
val classpath = calculateClasspath(project.compileDependencies)
|
||||
val classpath = calculateClasspath(project.compileDependencies, project.compileProvidedDependencies)
|
||||
|
||||
val projectDirectory = java.io.File(project.directory)
|
||||
val buildDirectory = File(projectDirectory, project.buildDirectory + File.separator + "classes")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue