mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
More refactoring into JvmCompilerPlugin.
This commit is contained in:
parent
da504c682f
commit
51431dca93
3 changed files with 14 additions and 24 deletions
|
@ -2,9 +2,9 @@ package com.beust.kobalt.internal
|
|||
|
||||
import com.beust.kobalt.TaskResult
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.IProjectContributor
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.ProjectDescription
|
||||
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
import com.beust.kobalt.maven.*
|
||||
|
@ -12,6 +12,7 @@ import com.beust.kobalt.misc.KFiles
|
|||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.misc.warn
|
||||
import com.beust.kobalt.plugin.java.JavaPlugin
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -24,7 +25,7 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
|||
open val depFactory: DepFactory,
|
||||
open val dependencyManager: DependencyManager,
|
||||
open val executors: KobaltExecutors,
|
||||
open val jvmCompiler: JvmCompiler) : BasePlugin() {
|
||||
open val jvmCompiler: JvmCompiler) : BasePlugin(), IProjectContributor {
|
||||
|
||||
companion object {
|
||||
@ExportedProjectProperty(doc = "The location of the build directory", type = "String")
|
||||
|
@ -138,10 +139,13 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
|||
.map { File(projectDir, it).absolutePath }
|
||||
}
|
||||
|
||||
fun baseTaskCompile(project: Project, projectDescriptions: List<ProjectDescription>) : TaskResult {
|
||||
override fun projects() = projects
|
||||
|
||||
@Task(name = JavaPlugin.TASK_COMPILE, description = "Compile the project")
|
||||
fun taskCompile(project: Project) : TaskResult {
|
||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
||||
|
||||
val projDeps = dependencyManager.dependentProjectDependencies(projectDescriptions, project, context)
|
||||
val projDeps = dependencyManager.dependentProjectDependencies(projects(), project, context)
|
||||
|
||||
val classpath = dependencyManager.calculateDependencies(project, context, project.compileDependencies,
|
||||
project.compileProvidedDependencies, projDeps)
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.beust.kobalt.plugin.java
|
|||
|
||||
import com.beust.kobalt.TaskResult
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.IProjectContributor
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
|
@ -31,8 +30,7 @@ public class JavaPlugin @Inject constructor(
|
|||
override val executors: KobaltExecutors,
|
||||
val javaCompiler: JavaCompiler,
|
||||
override val jvmCompiler: JvmCompiler)
|
||||
: JvmCompilerPlugin(localRepo, files, depFactory, dependencyManager, executors, jvmCompiler),
|
||||
IProjectContributor {
|
||||
: JvmCompilerPlugin(localRepo, files, depFactory, dependencyManager, executors, jvmCompiler) {
|
||||
companion object {
|
||||
public const val TASK_COMPILE : String = "compile"
|
||||
public const val TASK_JAVADOC : String = "javadoc"
|
||||
|
@ -72,11 +70,6 @@ public class JavaPlugin @Inject constructor(
|
|||
|
||||
}
|
||||
|
||||
@Task(name = TASK_COMPILE, description = "Compile the project")
|
||||
fun taskCompile(project: Project) : TaskResult {
|
||||
return baseTaskCompile(project, projects())
|
||||
}
|
||||
|
||||
override fun doCompile(project: Project, classpath: List<IClasspathDependency>, sourceFiles: List<String>,
|
||||
buildDirectory: File) : TaskResult {
|
||||
val result =
|
||||
|
@ -105,8 +98,6 @@ public class JavaPlugin @Inject constructor(
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun projects() = projects
|
||||
}
|
||||
|
||||
@Directive
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.beust.kobalt.plugin.kotlin
|
||||
|
||||
import com.beust.kobalt.TaskResult
|
||||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.IClasspathContributor
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
import com.beust.kobalt.internal.JvmCompiler
|
||||
|
@ -23,7 +26,7 @@ class KotlinPlugin @Inject constructor(
|
|||
override val executors: KobaltExecutors,
|
||||
override val jvmCompiler: JvmCompiler)
|
||||
: JvmCompilerPlugin(localRepo, files, depFactory, dependencyManager, executors, jvmCompiler),
|
||||
IProjectContributor, IClasspathContributor {
|
||||
IClasspathContributor {
|
||||
|
||||
companion object {
|
||||
public const val TASK_COMPILE: String = "compile"
|
||||
|
@ -34,11 +37,6 @@ class KotlinPlugin @Inject constructor(
|
|||
|
||||
override fun accept(project: Project) = project is KotlinProject
|
||||
|
||||
@Task(name = TASK_COMPILE, description = "Compile the project")
|
||||
fun taskCompile(project: Project): TaskResult {
|
||||
return baseTaskCompile(project, projects())
|
||||
}
|
||||
|
||||
override fun doCompile(project: Project, classpath: List<IClasspathDependency>, sourceFiles: List<String>,
|
||||
buildDirectory: File) : TaskResult {
|
||||
val result =
|
||||
|
@ -86,9 +84,6 @@ class KotlinPlugin @Inject constructor(
|
|||
}.compile(project, context)
|
||||
}
|
||||
|
||||
// interface IProjectContributor
|
||||
override fun projects() = projects
|
||||
|
||||
private fun getKotlinCompilerJar(name: String) : String {
|
||||
val id = "org.jetbrains.kotlin:$name:${KotlinCompiler.KOTLIN_VERSION}"
|
||||
val dep = MavenDependency.create(id, executors.miscExecutor)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue