Replaced jdk-headers with jdk-annotations everywhere.
This commit is contained in:
@@ -349,29 +349,17 @@
|
|||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="jdkHeaders">
|
<target name="jdkAnnotations">
|
||||||
<cleandir dir="${output}/classes/stdlib"/>
|
<cleandir dir="${output}/classes/stdlib"/>
|
||||||
|
|
||||||
<java classname="org.jetbrains.jet.cli.jvm.K2JVMCompiler" failonerror="true">
|
<jar destfile="${kotlin-home}/lib/alt/kotlin-jdk-annotations.jar">
|
||||||
<classpath>
|
<fileset dir="${basedir}/jdk-annotations"/>
|
||||||
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
|
||||||
</classpath>
|
|
||||||
<arg value="-src"/>
|
|
||||||
<arg value="${basedir}/jdk-headers/src"/>
|
|
||||||
<arg value="-output"/>
|
|
||||||
<arg value="${output}/classes/jdk-headers"/>
|
|
||||||
<arg value="-mode"/>
|
|
||||||
<arg value="jdkHeaders"/>
|
|
||||||
</java>
|
|
||||||
|
|
||||||
<jar destfile="${kotlin-home}/lib/alt/kotlin-jdk-headers.jar">
|
|
||||||
<fileset dir="${output}/classes/jdk-headers"/>
|
|
||||||
|
|
||||||
<manifest>
|
<manifest>
|
||||||
<attribute name="Built-By" value="JetBrains"/>
|
<attribute name="Built-By" value="JetBrains"/>
|
||||||
|
|
||||||
<attribute name="Implementation-Vendor" value="JetBrains"/>
|
<attribute name="Implementation-Vendor" value="JetBrains"/>
|
||||||
<attribute name="Implementation-Title" value="Kotlin Compiler JDK Headers"/>
|
<attribute name="Implementation-Title" value="Kotlin Compiler JDK Annotations"/>
|
||||||
<attribute name="Implementation-Version" value="${build.number}"/>
|
<attribute name="Implementation-Version" value="${build.number}"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
</jar>
|
</jar>
|
||||||
@@ -438,7 +426,7 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="dist"
|
<target name="dist"
|
||||||
depends="init,prepareDist,injectorsGenerator,generateInjectors,compiler,compilerSources,antTools,jdkHeaders,runtime,lang,jslib"/>
|
depends="init,prepareDist,injectorsGenerator,generateInjectors,compiler,compilerSources,antTools,jdkAnnotations,runtime,lang,jslib"/>
|
||||||
|
|
||||||
<target name="zip" depends="dist">
|
<target name="zip" depends="dist">
|
||||||
<zip destfile="${output}/${output.name}.zip">
|
<zip destfile="${output}/${output.name}.zip">
|
||||||
|
|||||||
@@ -57,17 +57,17 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
|||||||
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
|
||||||
|
|
||||||
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
|
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
|
||||||
File jdkHeadersJar;
|
File jdkAnnotationsJar;
|
||||||
if (mode.includeJdkHeaders()) {
|
if (mode.includeJdkAnnotations()) {
|
||||||
if (arguments.jdkHeaders != null) {
|
if (arguments.jdkAnnotations != null) {
|
||||||
jdkHeadersJar = new File(arguments.jdkHeaders);
|
jdkAnnotationsJar = new File(arguments.jdkAnnotations);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jdkHeadersJar = PathUtil.getAltHeadersPath();
|
jdkAnnotationsJar = PathUtil.getJdkAnnotationsPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jdkHeadersJar = null;
|
jdkAnnotationsJar = null;
|
||||||
}
|
}
|
||||||
File runtimeJar;
|
File runtimeJar;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
|||||||
runtimeJar = null;
|
runtimeJar = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkHeadersJar, runtimeJar);
|
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkAnnotationsJar, runtimeJar);
|
||||||
|
|
||||||
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
|
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
|
||||||
if (!arguments.script &&
|
if (!arguments.script &&
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public class K2JVMCompilerArguments extends CompilerArguments {
|
|||||||
@Argument(value = "stdlib", description = "Path to the stdlib.jar")
|
@Argument(value = "stdlib", description = "Path to the stdlib.jar")
|
||||||
public String stdlib;
|
public String stdlib;
|
||||||
|
|
||||||
@Argument(value = "jdkHeaders", description = "Path to the kotlin-jdk-headers.jar")
|
@Argument(value = "jdkAnnotations", description = "Path to the kotlin-jdk-annotations.jar")
|
||||||
public String jdkHeaders;
|
public String jdkAnnotations;
|
||||||
|
|
||||||
@Argument(value = "mode", description = "Special compiler modes: stubs or jdkHeaders")
|
@Argument(value = "mode", description = "Special compiler modes: stubs or jdkHeaders")
|
||||||
public String mode;
|
public String mode;
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
annotationsProvider = new CoreAnnotationsProvider();
|
annotationsProvider = new CoreAnnotationsProvider();
|
||||||
if (compilerSpecialMode.includeJdkHeaders()) {
|
if (compilerSpecialMode.includeJdkAnnotations()) {
|
||||||
for (VirtualFile root : compilerDependencies.getJdkHeaderRoots()) {
|
for (VirtualFile root : compilerDependencies.getJdkAnnotationsRoots()) {
|
||||||
addLibraryRoot(root);
|
annotationsProvider.addExternalAnnotationsRoot(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-15
@@ -1,3 +1,4 @@
|
|||||||
|
/*
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2012 JetBrains s.r.o.
|
* Copyright 2010-2012 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
@@ -35,14 +36,14 @@ public class CompilerDependencies {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private final File jdkJar;
|
private final File jdkJar;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final File jdkHeadersJar;
|
private final File jdkAnnotationsJar;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final File runtimeJar;
|
private final File runtimeJar;
|
||||||
|
|
||||||
public CompilerDependencies(@NotNull CompilerSpecialMode compilerSpecialMode, @Nullable File jdkJar, @Nullable File jdkHeadersJar, @Nullable File runtimeJar) {
|
public CompilerDependencies(@NotNull CompilerSpecialMode compilerSpecialMode, @Nullable File jdkJar, @Nullable File jdkAnnotationsJar, @Nullable File runtimeJar) {
|
||||||
this.compilerSpecialMode = compilerSpecialMode;
|
this.compilerSpecialMode = compilerSpecialMode;
|
||||||
this.jdkJar = jdkJar;
|
this.jdkJar = jdkJar;
|
||||||
this.jdkHeadersJar = jdkHeadersJar;
|
this.jdkAnnotationsJar = jdkAnnotationsJar;
|
||||||
this.runtimeJar = runtimeJar;
|
this.runtimeJar = runtimeJar;
|
||||||
|
|
||||||
if (compilerSpecialMode.includeJdk()) {
|
if (compilerSpecialMode.includeJdk()) {
|
||||||
@@ -50,9 +51,9 @@ public class CompilerDependencies {
|
|||||||
throw new IllegalArgumentException("jdk must be included for mode " + compilerSpecialMode);
|
throw new IllegalArgumentException("jdk must be included for mode " + compilerSpecialMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compilerSpecialMode.includeJdkHeaders()) {
|
if (compilerSpecialMode.includeJdkAnnotations()) {
|
||||||
if (jdkHeadersJar == null) {
|
if (jdkAnnotationsJar == null) {
|
||||||
throw new IllegalArgumentException("jdkHeaders must be included for mode " + compilerSpecialMode);
|
throw new IllegalArgumentException("jdkAnnotations must be included for mode " + compilerSpecialMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compilerSpecialMode.includeKotlinRuntime()) {
|
if (compilerSpecialMode.includeKotlinRuntime()) {
|
||||||
@@ -72,20 +73,15 @@ public class CompilerDependencies {
|
|||||||
return jdkJar;
|
return jdkJar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public File getJdkHeadersJar() {
|
|
||||||
return jdkHeadersJar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public File getRuntimeJar() {
|
public File getRuntimeJar() {
|
||||||
return runtimeJar;
|
return runtimeJar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<VirtualFile> getJdkHeaderRoots() {
|
public List<VirtualFile> getJdkAnnotationsRoots() {
|
||||||
if (compilerSpecialMode.includeJdkHeaders()) {
|
if (compilerSpecialMode.includeJdkAnnotations()) {
|
||||||
return Collections.singletonList(PathUtil.jarFileOrDirectoryToVirtualFile(jdkHeadersJar));
|
return Collections.singletonList(PathUtil.jarFileOrDirectoryToVirtualFile(jdkAnnotationsJar));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -107,7 +103,7 @@ public class CompilerDependencies {
|
|||||||
return new CompilerDependencies(
|
return new CompilerDependencies(
|
||||||
compilerSpecialMode,
|
compilerSpecialMode,
|
||||||
compilerSpecialMode.includeJdk() ? findRtJar() : null,
|
compilerSpecialMode.includeJdk() ? findRtJar() : null,
|
||||||
compilerSpecialMode.includeJdkHeaders() ? PathUtil.getAltHeadersPath() : null,
|
compilerSpecialMode.includeJdkAnnotations() ? PathUtil.getJdkAnnotationsPath() : null,
|
||||||
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
|
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public enum CompilerSpecialMode {
|
|||||||
JS,
|
JS,
|
||||||
;
|
;
|
||||||
|
|
||||||
public boolean includeJdkHeaders() {
|
public boolean includeJdkAnnotations() {
|
||||||
return this == REGULAR || this == STDLIB || this == IDEA;
|
return this == REGULAR || this == STDLIB || this == IDEA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public class PsiClassFinderForJvm implements PsiClassFinder {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
this.altClassFinder = new AltClassFinder(project, compilerDependencies.getJdkHeaderRoots());
|
this.altClassFinder = new AltClassFinder(project, compilerDependencies.getJdkAnnotationsRoots());
|
||||||
this.javaSearchScope = new DelegatingGlobalSearchScope(GlobalSearchScope.allScope(project)) {
|
this.javaSearchScope = new DelegatingGlobalSearchScope(GlobalSearchScope.allScope(project)) {
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(VirtualFile file) {
|
public boolean contains(VirtualFile file) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Usage: org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
|
|||||||
-annotations [String] paths to external annotations
|
-annotations [String] paths to external annotations
|
||||||
-includeRuntime [flag]
|
-includeRuntime [flag]
|
||||||
-stdlib [String] Path to the stdlib.jar
|
-stdlib [String] Path to the stdlib.jar
|
||||||
-jdkHeaders [String] Path to the kotlin-jdk-headers.jar
|
-jdkAnnotations [String] Path to the kotlin-jdk-annotations.jar
|
||||||
-mode [String] Special compiler modes: stubs or jdkHeaders
|
-mode [String] Special compiler modes: stubs or jdkHeaders
|
||||||
-output [String] output directory
|
-output [String] output directory
|
||||||
-module [String] module to compile
|
-module [String] module to compile
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ fun test6() : Boolean {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArrayList without jdk-headers cannot be used in these tests
|
// ArrayList without jdk-annotations cannot be used in these tests
|
||||||
class MyArrayList<T>() {
|
class MyArrayList<T>() {
|
||||||
private var value17: T? = null
|
private var value17: T? = null
|
||||||
private var value39: T? = null
|
private var value39: T? = null
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package kotlin1
|
package kotlin1
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package kotlin1
|
package kotlin1
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -6,6 +5,6 @@ import java.util.*
|
|||||||
fun main(args : Array<String>) {
|
fun main(args : Array<String>) {
|
||||||
val al : ArrayList<Int> = ArrayList<Int>()
|
val al : ArrayList<Int> = ArrayList<Int>()
|
||||||
|
|
||||||
// A type mismatch on this line means that alt-headers were not loaded
|
// A type mismatch on this line means that jdk-annotations were not loaded
|
||||||
al.toArray(Array<Int>(3, {1})) : Array<Int>
|
al.toArray(Array<Int>(3, {1})) : Array<Int>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,10 @@ package org.jetbrains.jet;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileBuiltins;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileBuiltins;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.utils.PathUtil;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,8 +35,8 @@ public class CompileCompilerDependenciesTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void compileJdkHeaders() {
|
public void packJdkAnnotations() {
|
||||||
ForTestCompileJdkHeaders.jdkHeadersForTests();
|
ForTestPackJdkAnnotations.jdkAnnotationsForTests();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -53,7 +52,7 @@ public class CompileCompilerDependenciesTest {
|
|||||||
return new CompilerDependencies(
|
return new CompilerDependencies(
|
||||||
compilerSpecialMode,
|
compilerSpecialMode,
|
||||||
compilerSpecialMode.includeJdk() ? (mockJdk ? JetTestUtils.findMockJdkRtJar() : CompilerDependencies.findRtJar()) : null,
|
compilerSpecialMode.includeJdk() ? (mockJdk ? JetTestUtils.findMockJdkRtJar() : CompilerDependencies.findRtJar()) : null,
|
||||||
compilerSpecialMode.includeJdkHeaders() ? ForTestCompileJdkHeaders.jdkHeadersForTests() : null,
|
compilerSpecialMode.includeJdkAnnotations() ? ForTestPackJdkAnnotations.jdkAnnotationsForTests() : null,
|
||||||
compilerSpecialMode.includeKotlinRuntime() ? ForTestCompileRuntime.runtimeJarForTests() : null);
|
compilerSpecialMode.includeKotlinRuntime() ? ForTestCompileRuntime.runtimeJarForTests() : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2012 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 org.jetbrains.jet.codegen.forTestCompile;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.cli.common.ExitCode;
|
|
||||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Stepan Koltsov
|
|
||||||
*/
|
|
||||||
public class ForTestCompileJdkHeaders {
|
|
||||||
|
|
||||||
private ForTestCompileJdkHeaders() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class JdkHeaders extends ForTestCompileSomething {
|
|
||||||
|
|
||||||
JdkHeaders() {
|
|
||||||
super("jdkHeaders");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doCompile(@NotNull File classesDir) throws Exception {
|
|
||||||
ExitCode exitCode = new K2JVMCompiler().exec(
|
|
||||||
System.err, "-output", classesDir.getPath(), "-src", "./jdk-headers/src", "-mode", "jdkHeaders");
|
|
||||||
if (exitCode != ExitCode.OK) {
|
|
||||||
throw new IllegalStateException("jdk headers compilation failed: " + exitCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final JdkHeaders jdkHeaders = new JdkHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static File jdkHeadersForTests() {
|
|
||||||
return ForTestCompileSomething.ACTUALLY_COMPILE ? JdkHeaders.jdkHeaders.getJarFile() : new File("dist/kotlinc/lib/alt/kotlin-jdk-headers.jar");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -80,7 +80,7 @@ abstract class ForTestCompileSomething {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyToJar(File root, JarOutputStream os) throws IOException {
|
static void copyToJar(File root, JarOutputStream os) throws IOException {
|
||||||
Stack<Pair<String, File>> toCopy = new Stack<Pair<String, File>>();
|
Stack<Pair<String, File>> toCopy = new Stack<Pair<String, File>>();
|
||||||
toCopy.add(new Pair<String, File>("", root));
|
toCopy.add(new Pair<String, File>("", root));
|
||||||
while (!toCopy.empty()) {
|
while (!toCopy.empty()) {
|
||||||
|
|||||||
+72
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2012 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 org.jetbrains.jet.codegen.forTestCompile;
|
||||||
|
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
import com.intellij.openapi.util.Pair;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Stack;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Stepan Koltsov
|
||||||
|
*/
|
||||||
|
public class ForTestPackJdkAnnotations {
|
||||||
|
|
||||||
|
private ForTestPackJdkAnnotations() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File jarFile = null;
|
||||||
|
|
||||||
|
private static File getJarFile() {
|
||||||
|
if (jarFile == null) {
|
||||||
|
try {
|
||||||
|
File tmpDir = JetTestUtils.tmpDir("runtimejar");
|
||||||
|
jarFile = new File(tmpDir, "runtime.jar");
|
||||||
|
FileOutputStream annotationsJar = new FileOutputStream(jarFile);
|
||||||
|
try {
|
||||||
|
JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(annotationsJar));
|
||||||
|
try {
|
||||||
|
ForTestCompileSomething.copyToJar(new File("./jdk-annotations"), jarOutputStream);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
jarOutputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
annotationsJar.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jarFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static File jdkAnnotationsForTests() {
|
||||||
|
return ForTestCompileSomething.ACTUALLY_COMPILE ? getJarFile() : new File("dist/kotlinc/lib/alt/kotlin-jdk-annotations.jar");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.jetbrains.jet.cli.common.ExitCode;
|
import org.jetbrains.jet.cli.common.ExitCode;
|
||||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -44,13 +44,13 @@ public class CompileEnvironmentTest extends TestCase {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
||||||
File jdkHeaders = ForTestCompileJdkHeaders.jdkHeadersForTests();
|
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
|
||||||
File resultJar = new File(tempDir, "result.jar");
|
File resultJar = new File(tempDir, "result.jar");
|
||||||
ExitCode rv = new K2JVMCompiler().exec(System.out,
|
ExitCode rv = new K2JVMCompiler().exec(System.out,
|
||||||
"-module", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
|
"-module", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
|
||||||
"-jar", resultJar.getAbsolutePath(),
|
"-jar", resultJar.getAbsolutePath(),
|
||||||
"-stdlib", stdlib.getAbsolutePath(),
|
"-stdlib", stdlib.getAbsolutePath(),
|
||||||
"-jdkHeaders", jdkHeaders.getAbsolutePath());
|
"-jdkAnnotations", jdkAnnotations.getAbsolutePath());
|
||||||
Assert.assertEquals("compilation completed with non-zero code", ExitCode.OK, rv);
|
Assert.assertEquals("compilation completed with non-zero code", ExitCode.OK, rv);
|
||||||
FileInputStream fileInputStream = new FileInputStream(resultJar);
|
FileInputStream fileInputStream = new FileInputStream(resultJar);
|
||||||
try {
|
try {
|
||||||
@@ -78,10 +78,10 @@ public class CompileEnvironmentTest extends TestCase {
|
|||||||
try {
|
try {
|
||||||
File out = new File(tempDir, "out");
|
File out = new File(tempDir, "out");
|
||||||
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
||||||
File jdkHeaders = ForTestCompileJdkHeaders.jdkHeadersForTests();
|
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
|
||||||
ExitCode exitCode = new K2JVMCompiler()
|
ExitCode exitCode = new K2JVMCompiler()
|
||||||
.exec(System.out, "-src", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt", "-output",
|
.exec(System.out, "-src", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt", "-output",
|
||||||
out.getAbsolutePath(), "-stdlib", stdlib.getAbsolutePath(), "-jdkHeaders", jdkHeaders.getAbsolutePath());
|
out.getAbsolutePath(), "-stdlib", stdlib.getAbsolutePath(), "-jdkAnnotations", jdkAnnotations.getAbsolutePath());
|
||||||
Assert.assertEquals(ExitCode.OK, exitCode);
|
Assert.assertEquals(ExitCode.OK, exitCode);
|
||||||
assertEquals(1, out.listFiles().length);
|
assertEquals(1, out.listFiles().length);
|
||||||
assertEquals(1, out.listFiles()[0].listFiles().length);
|
assertEquals(1, out.listFiles()[0].listFiles().length);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.jvm.compiler;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
||||||
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
|
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
@@ -36,7 +36,6 @@ import org.junit.Assert;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
@@ -80,7 +79,8 @@ public class JavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testResolveJdkHeaderClassWithoutJdk() {
|
public void testResolveJdkHeaderClassWithoutJdk() {
|
||||||
JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable, new CompilerDependencies(CompilerSpecialMode.IDEA, null, ForTestCompileJdkHeaders.jdkHeadersForTests(), null));
|
JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable, new CompilerDependencies(CompilerSpecialMode.IDEA, null, ForTestPackJdkAnnotations
|
||||||
|
.jdkAnnotationsForTests(), null));
|
||||||
|
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
||||||
jetCoreEnvironment.getCompilerDependencies(), jetCoreEnvironment.getProject());
|
jetCoreEnvironment.getCompilerDependencies(), jetCoreEnvironment.getProject());
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ public class PathUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static File getAltHeadersPath() {
|
public static File getJdkAnnotationsPath() {
|
||||||
return getFilePackedIntoLib("alt/kotlin-jdk-headers.jar");
|
return getFilePackedIntoLib("alt/kotlin-jdk-annotations.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<!-- jdkHeaders -->
|
<!-- jdkAnnotations -->
|
||||||
<directory>${kotlin-sdk}/lib/alt</directory>
|
<directory>${kotlin-sdk}/lib/alt</directory>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
|
|||||||
+19
-19
@@ -205,8 +205,8 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
|||||||
log.info("Classes directory is " + output);
|
log.info("Classes directory is " + output);
|
||||||
arguments.setOutputDir(output);
|
arguments.setOutputDir(output);
|
||||||
|
|
||||||
arguments.jdkHeaders = getAltHeaders().getPath();
|
arguments.jdkAnnotations = getJdkAnnotations().getPath();
|
||||||
log.debug("Using alt headers from " + arguments.jdkHeaders);
|
log.debug("Using jdk annotations from " + arguments.jdkAnnotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make a better runtime detection or get rid of it entirely
|
// TODO: Make a better runtime detection or get rid of it entirely
|
||||||
@@ -224,37 +224,37 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File altHeadersPath;
|
private File jdkAnnotationsPath;
|
||||||
|
|
||||||
protected File getAltHeaders() {
|
protected File getJdkAnnotations() {
|
||||||
if (altHeadersPath != null)
|
if (jdkAnnotationsPath != null)
|
||||||
return altHeadersPath;
|
return jdkAnnotationsPath;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
altHeadersPath = extractAltHeaders();
|
jdkAnnotationsPath = extractJdkAnnotations();
|
||||||
|
|
||||||
if (altHeadersPath == null)
|
if (jdkAnnotationsPath == null)
|
||||||
throw new RuntimeException("Can't find kotlin alt headers in maven plugin resources");
|
throw new RuntimeException("Can't find kotlin jdk annotations in maven plugin resources");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return altHeadersPath;
|
return jdkAnnotationsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File extractAltHeaders() throws IOException {
|
private File extractJdkAnnotations() throws IOException {
|
||||||
final String kotlin_jdk_headers = "kotlin-jdk-headers.jar";
|
final String kotlin_jdk_annotations = "kotlin-jdk-annotations.jar";
|
||||||
|
|
||||||
final URL jdkHeadersResource = Resources.getResource(kotlin_jdk_headers);
|
final URL jdkAnnotationsResource = Resources.getResource(kotlin_jdk_annotations);
|
||||||
if (jdkHeadersResource == null)
|
if (jdkAnnotationsResource == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
final File jdkHeadersTempDir = Files.createTempDir();
|
final File jdkAnnotationsTempDir = Files.createTempDir();
|
||||||
jdkHeadersTempDir.deleteOnExit();
|
jdkAnnotationsTempDir.deleteOnExit();
|
||||||
|
|
||||||
final File jdkHeadersFile = new File(jdkHeadersTempDir, kotlin_jdk_headers);
|
final File jdkAnnotationsFile = new File(jdkAnnotationsTempDir, kotlin_jdk_annotations);
|
||||||
Files.copy(Resources.newInputStreamSupplier(jdkHeadersResource), jdkHeadersFile);
|
Files.copy(Resources.newInputStreamSupplier(jdkAnnotationsResource), jdkAnnotationsFile);
|
||||||
|
|
||||||
return jdkHeadersFile;
|
return jdkAnnotationsFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user