mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
Clean up.
This commit is contained in:
parent
7824dbc9a4
commit
73d73af0a7
3 changed files with 44 additions and 52 deletions
|
@ -110,8 +110,6 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val compilerArgs = hashMapOf<String, List<String>>()
|
|
||||||
|
|
||||||
protected fun compilerArgsFor(project: Project) : List<String> {
|
protected fun compilerArgsFor(project: Project) : List<String> {
|
||||||
val result = project.projectProperties.get(COMPILER_ARGS)
|
val result = project.projectProperties.get(COMPILER_ARGS)
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
@ -175,7 +173,6 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun doCompile(project: Project, cai: CompilerActionInfo) : TaskResult
|
|
||||||
abstract fun doJavadoc(project: Project, cai: CompilerActionInfo) : TaskResult
|
abstract fun doJavadoc(project: Project, cai: CompilerActionInfo) : TaskResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,17 +62,6 @@ class JavaPlugin @Inject constructor(
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doCompile(project: Project, cai: CompilerActionInfo) : TaskResult {
|
|
||||||
val result =
|
|
||||||
if (cai.sourceFiles.size > 0) {
|
|
||||||
javaCompiler.compile(project, context, cai.copy(compilerArgs = compilerArgsFor(project)))
|
|
||||||
} else {
|
|
||||||
warn("Couldn't find any source files to compile")
|
|
||||||
TaskResult()
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
@Task(name = TASK_COMPILE_TEST, description = "Compile the tests", runAfter = arrayOf("compile"))
|
@Task(name = TASK_COMPILE_TEST, description = "Compile the tests", runAfter = arrayOf("compile"))
|
||||||
fun taskCompileTest(project: Project): TaskResult {
|
fun taskCompileTest(project: Project): TaskResult {
|
||||||
val sourceFiles = findSourceFiles(project.directory, project.sourceDirectoriesTest)
|
val sourceFiles = findSourceFiles(project.directory, project.sourceDirectoriesTest)
|
||||||
|
@ -95,7 +84,16 @@ class JavaPlugin @Inject constructor(
|
||||||
override fun affinity(project: Project, context: KobaltContext) =
|
override fun affinity(project: Project, context: KobaltContext) =
|
||||||
if (project.sourceSuffix == ".java") 1 else 0
|
if (project.sourceSuffix == ".java") 1 else 0
|
||||||
|
|
||||||
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) = doCompile(project, info)
|
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
|
val result =
|
||||||
|
if (info.sourceFiles.size > 0) {
|
||||||
|
javaCompiler.compile(project, context, info.copy(compilerArgs = compilerArgsFor(project)))
|
||||||
|
} else {
|
||||||
|
warn("Couldn't find any source files to compile")
|
||||||
|
TaskResult()
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
|
|
|
@ -39,21 +39,7 @@ class KotlinPlugin @Inject constructor(
|
||||||
|
|
||||||
override fun accept(project: Project) = project is KotlinProject
|
override fun accept(project: Project) = project is KotlinProject
|
||||||
|
|
||||||
override fun doCompile(project: Project, cai: CompilerActionInfo) : TaskResult {
|
override fun doJavadoc(project: Project, cai: CompilerActionInfo): TaskResult {
|
||||||
val result =
|
|
||||||
if (cai.sourceFiles.size > 0) {
|
|
||||||
compilePrivate(project, cai.dependencies, cai.sourceFiles, cai.outputDir)
|
|
||||||
} else {
|
|
||||||
warn("Couldn't find any source files")
|
|
||||||
TaskResult()
|
|
||||||
}
|
|
||||||
|
|
||||||
lp(project, "Compilation " + if (result.success) "succeeded" else "failed")
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun doJavadoc(project: Project, cai: CompilerActionInfo) : TaskResult {
|
|
||||||
warn("javadoc task not implemented for Kotlin, call the dokka task instead")
|
warn("javadoc task not implemented for Kotlin, call the dokka task instead")
|
||||||
return TaskResult()
|
return TaskResult()
|
||||||
}
|
}
|
||||||
|
@ -91,7 +77,7 @@ class KotlinPlugin @Inject constructor(
|
||||||
}.compile(project, context)
|
}.compile(project, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getKotlinCompilerJar(name: String) : String {
|
private fun getKotlinCompilerJar(name: String): String {
|
||||||
val id = "org.jetbrains.kotlin:$name:${KotlinCompiler.KOTLIN_VERSION}"
|
val id = "org.jetbrains.kotlin:$name:${KotlinCompiler.KOTLIN_VERSION}"
|
||||||
val dep = MavenDependency.create(id, executors.miscExecutor)
|
val dep = MavenDependency.create(id, executors.miscExecutor)
|
||||||
val result = dep.jarFile.get().absolutePath
|
val result = dep.jarFile.get().absolutePath
|
||||||
|
@ -100,7 +86,7 @@ class KotlinPlugin @Inject constructor(
|
||||||
|
|
||||||
|
|
||||||
// interface IClasspathContributor
|
// interface IClasspathContributor
|
||||||
override fun entriesFor(project: Project?) : List<IClasspathDependency> =
|
override fun entriesFor(project: Project?): List<IClasspathDependency> =
|
||||||
if (project == null || project is KotlinProject) {
|
if (project == null || project is KotlinProject) {
|
||||||
// All Kotlin projects automatically get the Kotlin runtime added to their class path
|
// All Kotlin projects automatically get the Kotlin runtime added to their class path
|
||||||
listOf(getKotlinCompilerJar("kotlin-stdlib"), getKotlinCompilerJar("kotlin-runtime"))
|
listOf(getKotlinCompilerJar("kotlin-stdlib"), getKotlinCompilerJar("kotlin-runtime"))
|
||||||
|
@ -114,7 +100,18 @@ class KotlinPlugin @Inject constructor(
|
||||||
override fun affinity(project: Project, context: KobaltContext) =
|
override fun affinity(project: Project, context: KobaltContext) =
|
||||||
if (project.sourceSuffix == ".kt") 1 else 0
|
if (project.sourceSuffix == ".kt") 1 else 0
|
||||||
|
|
||||||
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) = doCompile(project, info)
|
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
|
val result =
|
||||||
|
if (info.sourceFiles.size > 0) {
|
||||||
|
compilePrivate(project, info.dependencies, info.sourceFiles, info.outputDir)
|
||||||
|
} else {
|
||||||
|
warn("Couldn't find any source files")
|
||||||
|
TaskResult()
|
||||||
|
}
|
||||||
|
|
||||||
|
lp(project, "Compilation " + if (result.success) "succeeded" else "failed")
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue