Merge pull request #247 from nskvortsov/master
Fix missing Kotlin tests
This commit is contained in:
+2
-5
@@ -64,10 +64,7 @@ open class KotlinPlugin: Plugin<Project> {
|
|||||||
javaBasePlugin.configureForSourceSet(sourceSet, kotlinTask)
|
javaBasePlugin.configureForSourceSet(sourceSet, kotlinTask)
|
||||||
// store kotlin classes in separate directory. They will serve as class-path to java compiler
|
// store kotlin classes in separate directory. They will serve as class-path to java compiler
|
||||||
val kotlinOutputDir = File(project.getBuildDir(), "kotlin-classes/${sourceSetName}")
|
val kotlinOutputDir = File(project.getBuildDir(), "kotlin-classes/${sourceSetName}")
|
||||||
// builtBy allows to correctly run kotlinTask as a transitive dependency on anything,
|
kotlinTask.kotlinDestinationDir = kotlinOutputDir;
|
||||||
// that wants to use sourceSet output (e.g., 'jar' task
|
|
||||||
sourceSet.getOutput()?.dir(mapOf(Pair("builtBy", kotlinTask)), kotlinOutputDir)
|
|
||||||
kotlinTask.setDestinationDir(kotlinOutputDir);
|
|
||||||
|
|
||||||
kotlinTask.setDescription("Compiles the $sourceSet.kotlin.")
|
kotlinTask.setDescription("Compiles the $sourceSet.kotlin.")
|
||||||
kotlinTask.source(kotlinDirSet)
|
kotlinTask.source(kotlinDirSet)
|
||||||
@@ -76,7 +73,7 @@ open class KotlinPlugin: Plugin<Project> {
|
|||||||
|
|
||||||
if (javaTask != null) {
|
if (javaTask != null) {
|
||||||
javaTask.dependsOn(kotlinTaskName)
|
javaTask.dependsOn(kotlinTaskName)
|
||||||
val javacClassPath = javaTask.getClasspath() + project.files(kotlinTask.getDestinationDir());
|
val javacClassPath = javaTask.getClasspath() + project.files(kotlinTask.kotlinDestinationDir);
|
||||||
javaTask.setClasspath(javacClassPath)
|
javaTask.setClasspath(javacClassPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -23,6 +23,7 @@ import org.gradle.api.logging.Logger
|
|||||||
import org.gradle.api.logging.Logging
|
import org.gradle.api.logging.Logging
|
||||||
import org.apache.commons.lang.StringUtils
|
import org.apache.commons.lang.StringUtils
|
||||||
import org.gradle.api.initialization.dsl.ScriptHandler
|
import org.gradle.api.initialization.dsl.ScriptHandler
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
|
|
||||||
public open class KotlinCompile(): AbstractCompile() {
|
public open class KotlinCompile(): AbstractCompile() {
|
||||||
|
|
||||||
@@ -32,6 +33,8 @@ public open class KotlinCompile(): AbstractCompile() {
|
|||||||
|
|
||||||
public val kotlinOptions: K2JVMCompilerArguments = K2JVMCompilerArguments();
|
public val kotlinOptions: K2JVMCompilerArguments = K2JVMCompilerArguments();
|
||||||
|
|
||||||
|
public var kotlinDestinationDir : File? = getDestinationDir()
|
||||||
|
|
||||||
// override setSource to track source directory sets
|
// override setSource to track source directory sets
|
||||||
override fun setSource(source: Any?) {
|
override fun setSource(source: Any?) {
|
||||||
srcDirsRoots.clear()
|
srcDirsRoots.clear()
|
||||||
@@ -98,7 +101,7 @@ public open class KotlinCompile(): AbstractCompile() {
|
|||||||
args.setClasspath(effectiveClassPath)
|
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 embeddedAnnotations = getAnnotations()
|
||||||
val userAnnotations = (kotlinOptions.annotations ?: "").split(File.pathSeparatorChar).toList()
|
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")
|
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy kotlin classes to all classes directory
|
||||||
|
FileUtils.copyDirectory(kotlinDestinationDir, getDestinationDir())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAnnotations(): File {
|
fun getAnnotations(): File {
|
||||||
|
|||||||
+1
@@ -58,6 +58,7 @@ class BasicKotlinGradleIT {
|
|||||||
assertTrue(buildOutput.contains(":compileKotlin"), "Should contain ':compileKotlin'")
|
assertTrue(buildOutput.contains(":compileKotlin"), "Should contain ':compileKotlin'")
|
||||||
assertTrue(buildOutput.contains(":compileTestKotlin"), "Should contain ':compileTestKotlin'")
|
assertTrue(buildOutput.contains(":compileTestKotlin"), "Should contain ':compileTestKotlin'")
|
||||||
assertTrue(buildOutput.contains(":compileDeployKotlin"), "Should contain ':compileDeployKotlin'")
|
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
|
// Run the build second time, assert everything is up-to-date
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ dependencies {
|
|||||||
compile 'com.google.guava:guava:12.0'
|
compile 'com.google.guava:guava:12.0'
|
||||||
deployCompile 'com.google.guava:guava:12.0'
|
deployCompile 'com.google.guava:guava:12.0'
|
||||||
testCompile 'org.testng:testng:6.8'
|
testCompile 'org.testng:testng:6.8'
|
||||||
|
testRuntime 'org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT'
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useTestNG()
|
||||||
}
|
}
|
||||||
|
|
||||||
task show << {
|
task show << {
|
||||||
|
|||||||
Reference in New Issue
Block a user