1
0
Fork 0
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:
Cedric Beust 2016-02-02 16:31:07 -08:00
commit 9e53359790
25 changed files with 170 additions and 64 deletions

View file

@ -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) {

View file

@ -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")

View file

@ -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 =

View file

@ -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")

View file

@ -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 {

View file

@ -1 +1 @@
kobalt.version=0.407
kobalt.version=0.408

View 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")
}
}
}
}

View file

@ -0,0 +1 @@
kobalt.version=0.408

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*

View file

@ -0,0 +1,8 @@
package example;
public class JavaClass {
public void run() {
System.out.println("JavaClass run()");
}
}

View file

@ -0,0 +1,6 @@
package example
fun main(argv: Array<String>) {
println("KotlinMain calling JavaClass().run()")
JavaClass().run()
}

View 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")
}
}
}
}

View file

@ -0,0 +1 @@
kobalt.version=0.408

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*

View file

@ -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();
}
}

View file

@ -0,0 +1,11 @@
package example
import kotlin.io.*
class KotlinClass {
fun run() {
println("KotlinClass run()")
}
}