kapt: Fix sequential builds (KT-8733)

This commit is contained in:
Yan Zhulanow
2015-08-08 23:20:05 +03:00
parent b3073dbd2d
commit edb35ae6ce
4 changed files with 48 additions and 8 deletions
@@ -89,15 +89,17 @@ public class AnnotationProcessingManager(
val javaAptSourceDir = File(aptWorkingDir, "java_src")
val javaHackPackageDir = File(javaAptSourceDir, GEN_ANNOTATION)
javaHackPackageDir.mkdirs()
if (!javaHackPackageDir.exists()) javaHackPackageDir.mkdirs()
val javaHackClFile = File(javaHackPackageDir, "Cl.java")
javaHackClFile.writeText(
"package __gen.annotation;" +
"class Cl { @__gen.KotlinAptAnnotation boolean v; }")
if (!javaHackClFile.exists()) {
javaHackClFile.writeText("package __gen.annotation; class Cl { @__gen.KotlinAptAnnotation boolean v; }")
project.getLogger().kotlinDebug("kapt: Java file stub generated: $javaHackClFile")
}
project.getLogger().kotlinDebug("kapt: Java file stub generated: $javaHackClFile")
javaTask.source(javaAptSourceDir)
if (!javaTask.source.contains(javaHackClFile)) {
javaTask.source(javaAptSourceDir)
}
}
private fun appendAnnotationsFileLocationArgument() {
@@ -613,6 +613,7 @@ private fun Project.initKapt(
javaTask.doFirst {
kaptManager.setupKapt()
kaptManager.generateJavaHackFile()
}
javaTask.doLast {
@@ -99,7 +99,9 @@ class KotlinGradleIT: BaseGradleIT() {
}
Test fun testKaptSimple() {
Project("kaptSimple", "1.12").build("build") {
val project = Project("kaptSimple", "1.12")
project.build("build") {
assertSuccessful()
assertContains("kapt: Class file stubs are not used")
assertContains(":compileKotlin")
@@ -109,10 +111,16 @@ class KotlinGradleIT: BaseGradleIT() {
assertFileExists("build/classes/main/example/TestClass.class")
assertFileExists("build/classes/main/example/TestClassGenerated.class")
}
project.build("build") {
assertSuccessful()
}
}
Test fun testKaptStubs() {
Project("kaptStubs", "1.12").build("build") {
val project = Project("kaptStubs", "1.12")
project.build("build") {
assertSuccessful()
assertContains("kapt: Using class file stubs")
assertContains(":compileKotlin")
@@ -122,6 +130,10 @@ class KotlinGradleIT: BaseGradleIT() {
assertFileExists("build/classes/main/example/TestClass.class")
assertFileExists("build/classes/main/example/TestClassGenerated.class")
}
project.build("build") {
assertSuccessful()
}
}
Test fun testKaptArguments() {
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javaPackage;
public class JavaClass {
public void test() {
System.out.println(example.TestClassGenerated.class.getName());
}
}