mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28: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
|
@Directive
|
||||||
public fun dependencies(init: Dependencies.() -> Unit) : Dependencies {
|
public fun dependencies(init: Dependencies.() -> Unit) : Dependencies {
|
||||||
dependencies = Dependencies(this, compileDependencies)
|
dependencies = Dependencies(this, compileDependencies, compileProvidedDependencies)
|
||||||
dependencies!!.init()
|
dependencies!!.init()
|
||||||
return dependencies!!
|
return dependencies!!
|
||||||
}
|
}
|
||||||
|
|
||||||
public val compileDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
val compileDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||||
|
val compileProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
public fun dependenciesTest(init: Dependencies.() -> Unit) : Dependencies {
|
public fun dependenciesTest(init: Dependencies.() -> Unit) : Dependencies {
|
||||||
dependencies = Dependencies(this, testDependencies)
|
dependencies = Dependencies(this, testDependencies, testProvidedDependencies)
|
||||||
dependencies!!.init()
|
dependencies!!.init()
|
||||||
return dependencies!!
|
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>) {
|
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
|
@Directive
|
||||||
fun compile(vararg dep: String) {
|
fun compile(vararg dep: String) {
|
||||||
dep.forEach { dependencies.add(MavenDependency.create(it)) }
|
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}")
|
log(1, "${project.name}: ${s}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun calculateClasspath(dependencies : List<IClasspathDependency>): List<IClasspathDependency> {
|
fun calculateClasspath(vararg allDependencies : List<IClasspathDependency>): List<IClasspathDependency> {
|
||||||
return dependencyManager.transitiveClosure(dependencies)
|
var result = arrayListOf<IClasspathDependency>()
|
||||||
|
allDependencies.forEach { dependencies ->
|
||||||
|
result.addAll(dependencyManager.transitiveClosure(dependencies))
|
||||||
|
}
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun testDependencies(project: Project) : List<IClasspathDependency> {
|
protected fun testDependencies(project: Project) : List<IClasspathDependency> {
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
result.add(FileDependency(makeOutputDir(project).getAbsolutePath()))
|
result.add(FileDependency(makeOutputDir(project).absolutePath))
|
||||||
result.add(FileDependency(makeOutputTestDir(project).getAbsolutePath()))
|
result.add(FileDependency(makeOutputTestDir(project).absolutePath))
|
||||||
result.addAll(calculateClasspath(project.compileDependencies))
|
with(project) {
|
||||||
result.addAll(calculateClasspath(project.testDependencies))
|
arrayListOf(compileDependencies, compileProvidedDependencies, testDependencies,
|
||||||
|
testProvidedDependencies).forEach {
|
||||||
|
result.addAll(calculateClasspath(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
return dependencyManager.reorderDependencies(result)
|
return dependencyManager.reorderDependencies(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class KotlinPlugin @Inject constructor(
|
||||||
@Task(name = TASK_COMPILE, description = "Compile the project")
|
@Task(name = TASK_COMPILE, description = "Compile the project")
|
||||||
fun taskCompile(project: Project): TaskResult {
|
fun taskCompile(project: Project): TaskResult {
|
||||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
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 projectDirectory = java.io.File(project.directory)
|
||||||
val buildDirectory = File(projectDirectory, project.buildDirectory + File.separator + "classes")
|
val buildDirectory = File(projectDirectory, project.buildDirectory + File.separator + "classes")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue