Merge pull request #247 from nskvortsov/master

Fix missing Kotlin tests
This commit is contained in:
Leonid Shalupov
2013-04-17 06:03:29 -07:00
4 changed files with 15 additions and 6 deletions
@@ -64,10 +64,7 @@ open class KotlinPlugin: Plugin<Project> {
javaBasePlugin.configureForSourceSet(sourceSet, kotlinTask)
// store kotlin classes in separate directory. They will serve as class-path to java compiler
val kotlinOutputDir = File(project.getBuildDir(), "kotlin-classes/${sourceSetName}")
// builtBy allows to correctly run kotlinTask as a transitive dependency on anything,
// that wants to use sourceSet output (e.g., 'jar' task
sourceSet.getOutput()?.dir(mapOf(Pair("builtBy", kotlinTask)), kotlinOutputDir)
kotlinTask.setDestinationDir(kotlinOutputDir);
kotlinTask.kotlinDestinationDir = kotlinOutputDir;
kotlinTask.setDescription("Compiles the $sourceSet.kotlin.")
kotlinTask.source(kotlinDirSet)
@@ -76,7 +73,7 @@ open class KotlinPlugin: Plugin<Project> {
if (javaTask != null) {
javaTask.dependsOn(kotlinTaskName)
val javacClassPath = javaTask.getClasspath() + project.files(kotlinTask.getDestinationDir());
val javacClassPath = javaTask.getClasspath() + project.files(kotlinTask.kotlinDestinationDir);
javaTask.setClasspath(javacClassPath)
}
}
@@ -23,6 +23,7 @@ import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.apache.commons.lang.StringUtils
import org.gradle.api.initialization.dsl.ScriptHandler
import org.apache.commons.io.FileUtils
public open class KotlinCompile(): AbstractCompile() {
@@ -32,6 +33,8 @@ public open class KotlinCompile(): AbstractCompile() {
public val kotlinOptions: K2JVMCompilerArguments = K2JVMCompilerArguments();
public var kotlinDestinationDir : File? = getDestinationDir()
// override setSource to track source directory sets
override fun setSource(source: Any?) {
srcDirsRoots.clear()
@@ -98,7 +101,7 @@ public open class KotlinCompile(): AbstractCompile() {
args.setClasspath(effectiveClassPath)
}
args.outputDir = if (StringUtils.isEmpty(kotlinOptions.outputDir)) { getDestinationDir()?.getPath() } else { kotlinOptions.outputDir }
args.outputDir = if (StringUtils.isEmpty(kotlinOptions.outputDir)) { kotlinDestinationDir?.getPath() } else { kotlinOptions.outputDir }
val embeddedAnnotations = getAnnotations()
val userAnnotations = (kotlinOptions.annotations ?: "").split(File.pathSeparatorChar).toList()
@@ -116,6 +119,9 @@ public open class KotlinCompile(): AbstractCompile() {
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
else -> {}
}
// Copy kotlin classes to all classes directory
FileUtils.copyDirectory(kotlinDestinationDir, getDestinationDir())
}
fun getAnnotations(): File {
@@ -58,6 +58,7 @@ class BasicKotlinGradleIT {
assertTrue(buildOutput.contains(":compileKotlin"), "Should contain ':compileKotlin'")
assertTrue(buildOutput.contains(":compileTestKotlin"), "Should contain ':compileTestKotlin'")
assertTrue(buildOutput.contains(":compileDeployKotlin"), "Should contain ':compileDeployKotlin'")
assertTrue(File(projectDir, "build/reports/tests/demo.TestSource.html").exists(), "Test report does not exist. Were tests executed?")
// Run the build second time, assert everything is up-to-date
@@ -25,6 +25,11 @@ dependencies {
compile 'com.google.guava:guava:12.0'
deployCompile 'com.google.guava:guava:12.0'
testCompile 'org.testng:testng:6.8'
testRuntime 'org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT'
}
test {
useTestNG()
}
task show << {