restore compilation after rebase of dropping external annotations; fix affected tests

This commit is contained in:
Dmitry Jemerov
2015-10-08 13:55:39 +02:00
parent c41aefe2cb
commit 7e2c2ef678
13 changed files with 12 additions and 72 deletions
@@ -27,20 +27,10 @@ import java.io.File
import java.util.* import java.util.*
class KotlinCompilerAdapter : Javac13() { class KotlinCompilerAdapter : Javac13() {
var externalAnnotations: Path? = null
var moduleName: String? = null var moduleName: String? = null
var additionalArguments: MutableList<Commandline.Argument> = ArrayList(0) var additionalArguments: MutableList<Commandline.Argument> = ArrayList(0)
fun createExternalAnnotations(): Path {
if (externalAnnotations == null) {
externalAnnotations = Path(getProject())
}
return externalAnnotations!!.createPath()
}
fun createCompilerArg(): Commandline.Argument { fun createCompilerArg(): Commandline.Argument {
val argument = Commandline.Argument() val argument = Commandline.Argument()
additionalArguments.add(argument) additionalArguments.add(argument)
@@ -70,8 +60,6 @@ class KotlinCompilerAdapter : Javac13() {
// it is constructed only of sources which are newer than classes with the same name // it is constructed only of sources which are newer than classes with the same name
kotlinc.src = javac.srcdir kotlinc.src = javac.srcdir
kotlinc.externalAnnotations = externalAnnotations
if (moduleName == null) { if (moduleName == null) {
moduleName = javac.defaultModuleName moduleName = javac.defaultModuleName
} }
@@ -121,8 +121,6 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.addJvmClasspathRoots(getClasspath(paths, arguments)) configuration.addJvmClasspathRoots(getClasspath(paths, arguments))
configuration.addAll(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY, getAnnotationsPath(paths, arguments))
configuration.put(JVMConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME) configuration.put(JVMConfigurationKeys.MODULE_NAME, arguments.moduleName ?: JvmAbi.DEFAULT_MODULE_NAME)
if (arguments.module == null && arguments.freeArgs.isEmpty() && !arguments.version) { if (arguments.module == null && arguments.freeArgs.isEmpty() && !arguments.version) {
@@ -287,17 +285,6 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
} }
return classpath return classpath
} }
private fun getAnnotationsPath(paths: KotlinPaths, arguments: K2JVMCompilerArguments): List<File> {
val annotationsPath = arrayListOf<File>()
if (arguments.annotations != null) {
annotationsPath.addAll(arguments.annotations.split(File.pathSeparatorChar).map { File(it) })
}
if (!arguments.noJdkAnnotations) {
annotationsPath.add(paths.getJdkAnnotationsPath())
}
return annotationsPath
}
} }
} }
-1
View File
@@ -3,4 +3,3 @@ name
outputDir=out outputDir=out
sources=[] sources=[]
classpath=[] classpath=[]
annotations=[]
@@ -17,12 +17,10 @@
package org.jetbrains.kotlin.test package org.jetbrains.kotlin.test
public enum class ConfigurationKind( public enum class ConfigurationKind(
public val withJdkAnnotations: Boolean,
public val withRuntime: Boolean, public val withRuntime: Boolean,
public val withReflection: Boolean public val withReflection: Boolean
) { ) {
JDK_ONLY(withJdkAnnotations = false, withRuntime = false, withReflection = false), JDK_ONLY(withRuntime = false, withReflection = false),
JDK_AND_ANNOTATIONS(withJdkAnnotations = true, withRuntime = false, withReflection = false), NO_KOTLIN_REFLECT(withRuntime = true, withReflection = false),
NO_KOTLIN_REFLECT(withJdkAnnotations = true, withRuntime = true, withReflection = false), ALL(withRuntime = true, withReflection = true),
ALL(withJdkAnnotations = true, withRuntime = true, withReflection = true),
} }
@@ -27,7 +27,5 @@ public interface Module {
public fun getClasspathRoots(): List<String> public fun getClasspathRoots(): List<String>
public fun getAnnotationsRoots(): List<String>
public fun getJavaSourceRoots(): List<String> public fun getJavaSourceRoots(): List<String>
} }
@@ -18,13 +18,7 @@ package org.jetbrains.kotlin.idea.test;
import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.AnnotationOrderRootType;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.test.JetTestUtils; import org.jetbrains.kotlin.test.JetTestUtils;
@@ -43,13 +37,7 @@ public class PluginTestCaseBase {
@NotNull @NotNull
private static Sdk getSdk(String sdkHome) { private static Sdk getSdk(String sdkHome) {
Sdk sdk = JavaSdk.getInstance().createJdk("JDK", sdkHome, true); return JavaSdk.getInstance().createJdk("JDK", sdkHome, true);
SdkModificator modificator = sdk.getSdkModificator();
VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(getJdkAnnotationsJar());
assert file != null;
modificator.addRoot(JarFileSystem.getInstance().getJarRootForLocalFile(file), AnnotationOrderRootType.getInstance());
modificator.commitChanges();
return sdk;
} }
@NotNull @NotNull
@@ -64,15 +52,6 @@ public class PluginTestCaseBase {
return getSdk(javaHome); return getSdk(javaHome);
} }
@NotNull
public static File getJdkAnnotationsJar() {
File jdkAnnotations = new File(JetTestUtils.getHomeDirectory(), "dist/kotlinc/lib/kotlin-jdk-annotations.jar");
if (!jdkAnnotations.exists()) {
throw new RuntimeException("Kotlin JDK annotations jar not found; please run 'ant dist' to build it");
}
return jdkAnnotations;
}
public static boolean isAllFilesPresentTest(@NotNull String testName) { public static boolean isAllFilesPresentTest(@NotNull String testName) {
return StringUtil.startsWithIgnoreCase(testName, "allFilesPresentIn"); return StringUtil.startsWithIgnoreCase(testName, "allFilesPresentIn");
} }
@@ -2,6 +2,6 @@ import java.net.URI
// WITH_RUNTIME // WITH_RUNTIME
fun foo(): URI { fun foo(): URI? {
return java.io.File("x").toURI() return java.io.File("x").toURI()
} }
@@ -2,4 +2,4 @@
import java.io.DataInputStream import java.io.DataInputStream
import java.io.InputStream import java.io.InputStream
class C(p0: InputStream) : DataInputStream<caret>(p0) class C(p0: InputStream?) : DataInputStream<caret>(p0)
@@ -2,4 +2,4 @@
// ACTION: Add constructor parameters from ArrayList(Int) // ACTION: Add constructor parameters from ArrayList(Int)
import java.util.ArrayList import java.util.ArrayList
class C(p0: MutableCollection<out String>) : ArrayList<String><caret>(p0) class C(p0: MutableCollection<out String>?) : ArrayList<String><caret>(p0)
@@ -246,7 +246,6 @@ public object KotlinCompilerRunner {
with(settings) { with(settings) {
module = moduleFile.absolutePath module = moduleFile.absolutePath
noStdlib = true noStdlib = true
noJdkAnnotations = true
noJdk = true noJdk = true
} }
} }
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap; import com.intellij.util.containers.MultiMap;
import kotlin.CollectionsKt;
import kotlin.io.FilesKt; import kotlin.io.FilesKt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -140,15 +139,5 @@ public class KotlinBuilderModuleScriptGenerator {
return result; return result;
} }
@NotNull
private static JpsSdkType getSdkType(@NotNull JpsModule module) {
for (JpsDependencyElement dependency : module.getDependenciesList().getDependencies()) {
if (dependency instanceof JpsSdkDependency) {
return ((JpsSdkDependency) dependency).getSdkType();
}
}
return JpsJavaSdkType.INSTANCE;
}
private KotlinBuilderModuleScriptGenerator() {} private KotlinBuilderModuleScriptGenerator() {}
} }
@@ -36,11 +36,11 @@ import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.org.objectweb.asm.ClassWriter import org.jetbrains.org.objectweb.asm.ClassWriter
import java.io.IOException import java.io.IOException
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
val DEFAULT_ANNOTATIONS = "org.jebrains.kotlin.gradle.defaultAnnotations"
import java.io.File import java.io.File
import java.util.HashSet import java.util.HashSet
val DEFAULT_ANNOTATIONS = "org.jebrains.kotlin.gradle.defaultAnnotations"
val ANNOTATIONS_PLUGIN_NAME = "org.jetbrains.kotlin.kapt" val ANNOTATIONS_PLUGIN_NAME = "org.jetbrains.kotlin.kapt"
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile() { abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile() {
@@ -97,6 +97,9 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
getLog().info("Classes directory is " + output); getLog().info("Classes directory is " + output);
arguments.destination = output; arguments.destination = output;
arguments.moduleName = moduleName;
getLog().info("Module name is " + moduleName);
try { try {
Args.parse(arguments, ArrayUtil.toStringArray(args)); Args.parse(arguments, ArrayUtil.toStringArray(args));
} }