mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -07:00
Merge branch 'master' of github.com:cbeust/kobalt
This commit is contained in:
commit
9e53359790
25 changed files with 170 additions and 64 deletions
|
@ -37,7 +37,7 @@ class JavaPlugin @Inject constructor(
|
|||
|
||||
// IDocContributor
|
||||
override fun affinity(project: Project, context: KobaltContext) =
|
||||
if (project.sourceSuffix == ".java") 1 else 0
|
||||
if (project.sourceDirectories.any { it.contains("java") }) 1 else 0
|
||||
|
||||
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||
val result =
|
||||
|
@ -52,12 +52,15 @@ class JavaPlugin @Inject constructor(
|
|||
|
||||
override fun doTaskCompileTest(project: Project): TaskResult {
|
||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_TEST)
|
||||
val compilerActionInfo = createCompilerActionInfo(project, context, isTest = true)
|
||||
val compilerActionInfo = createCompilerActionInfo(project, context, isTest = true,
|
||||
sourceSuffixes = sourceSuffixes)
|
||||
val result = javaCompiler.compile(project, context, compilerActionInfo)
|
||||
return result
|
||||
}
|
||||
|
||||
// ICompilerContributor
|
||||
override val sourceSuffixes = listOf("java")
|
||||
|
||||
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||
val result =
|
||||
if (info.sourceFiles.size > 0) {
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.google.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class JavaProjectInfo : BaseProjectInfo() {
|
||||
override val sourceDirectory = "java"
|
||||
override val defaultSourceDirectories = hashSetOf("src/main/java", "src/main/resources", "src/main/res")
|
||||
override val defaultTestDirectories = hashSetOf("src/test/java", "src/test/resources", "src/test/res")
|
||||
|
||||
|
|
|
@ -76,8 +76,9 @@ class KotlinPlugin @Inject constructor(
|
|||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_TEST)
|
||||
val projectDir = File(project.directory)
|
||||
|
||||
|
||||
val sourceFiles = files.findRecursively(projectDir, project.sourceDirectoriesTest.map { File(it) })
|
||||
{ it: String -> it.endsWith(project.sourceSuffix) }
|
||||
{ file: String -> sourceSuffixes.any { file.endsWith(it) } }
|
||||
.map { File(projectDir, it).absolutePath }
|
||||
|
||||
val result =
|
||||
|
@ -124,8 +125,10 @@ class KotlinPlugin @Inject constructor(
|
|||
|
||||
// ICompilerContributor
|
||||
|
||||
override val sourceSuffixes = listOf("kt")
|
||||
|
||||
override fun affinity(project: Project, context: KobaltContext) =
|
||||
if (project.sourceSuffix == ".kt") 1 else 0
|
||||
if (project.sourceDirectories.any { it.contains("kotlin") }) 2 else 0
|
||||
|
||||
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||
val result =
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.google.inject.Singleton
|
|||
|
||||
@Singleton
|
||||
class KotlinProjectInfo : BaseProjectInfo() {
|
||||
override val sourceDirectory = "kotlin"
|
||||
override val defaultSourceDirectories = hashSetOf("src/main/kotlin", "src/main/resources", "src/main/res")
|
||||
override val defaultTestDirectories = hashSetOf("src/test/kotlin", "src/test/resources", "src/test/res")
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ class PackageConfig(val project: Project) : AttributeHolder {
|
|||
jar {
|
||||
name = "${project.name}-${project.version}-sources.jar"
|
||||
project.sourceDirectories.forEach {
|
||||
include(from(it), to(""), glob("**${project.sourceSuffix}"))
|
||||
include(from(it), to(""), glob("src/**"))
|
||||
}
|
||||
}
|
||||
jar {
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.407
|
||||
kobalt.version=0.408
|
||||
|
|
27
src/test/resources/projects/javaFirst/kobalt/src/Build.kt
Normal file
27
src/test/resources/projects/javaFirst/kobalt/src/Build.kt
Normal file
|
@ -0,0 +1,27 @@
|
|||
import com.beust.kobalt.*
|
||||
import com.beust.kobalt.plugin.packaging.assemble
|
||||
import com.beust.kobalt.plugin.kotlin.*
|
||||
|
||||
val repos = repos()
|
||||
|
||||
|
||||
val p = kotlinProject {
|
||||
|
||||
name = "mixed"
|
||||
group = "com.example"
|
||||
artifactId = name
|
||||
version = "0.1"
|
||||
|
||||
sourceDirectories {
|
||||
path("src/main/java", "src/main/kotlin")
|
||||
}
|
||||
|
||||
assemble {
|
||||
jar {
|
||||
fatJar = true
|
||||
manifest {
|
||||
attributes("Main-Class", "example.KotlinMainKt")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
kobalt.version=0.408
|
2
src/test/resources/projects/javaFirst/kobaltw
Executable file
2
src/test/resources/projects/javaFirst/kobaltw
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*
|
|
@ -0,0 +1,8 @@
|
|||
package example;
|
||||
|
||||
public class JavaClass {
|
||||
public void run() {
|
||||
System.out.println("JavaClass run()");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package example
|
||||
|
||||
fun main(argv: Array<String>) {
|
||||
println("KotlinMain calling JavaClass().run()")
|
||||
JavaClass().run()
|
||||
}
|
27
src/test/resources/projects/kotlinFirst/kobalt/src/Build.kt
Normal file
27
src/test/resources/projects/kotlinFirst/kobalt/src/Build.kt
Normal file
|
@ -0,0 +1,27 @@
|
|||
import com.beust.kobalt.*
|
||||
import com.beust.kobalt.plugin.packaging.assemble
|
||||
import com.beust.kobalt.plugin.kotlin.*
|
||||
|
||||
val repos = repos()
|
||||
|
||||
|
||||
val p = kotlinProject {
|
||||
|
||||
name = "mixed"
|
||||
group = "com.example"
|
||||
artifactId = name
|
||||
version = "0.1"
|
||||
|
||||
sourceDirectories {
|
||||
path("src/main/java", "src/main/kotlin")
|
||||
}
|
||||
|
||||
assemble {
|
||||
jar {
|
||||
fatJar = true
|
||||
manifest {
|
||||
attributes("Main-Class", "example.KotlinMainKt")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
kobalt.version=0.408
|
2
src/test/resources/projects/kotlinFirst/kobaltw
Executable file
2
src/test/resources/projects/kotlinFirst/kobaltw
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*
|
|
@ -0,0 +1,8 @@
|
|||
package example;
|
||||
|
||||
public class JavaMain {
|
||||
public static void main(String[] argv) {
|
||||
System.out.println("JavaMain calling into Kotlin");
|
||||
new KotlinClass().run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package example
|
||||
|
||||
import kotlin.io.*
|
||||
|
||||
class KotlinClass {
|
||||
fun run() {
|
||||
println("KotlinClass run()")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue