diff --git a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java index a4f78a6f4ae..7d0d01fc8c6 100644 --- a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java +++ b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java @@ -26,6 +26,7 @@ import org.jetbrains.jet.cli.jvm.compiler.*; import org.jetbrains.jet.config.CommonConfigurationKeys; import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.utils.KotlinPaths; +import org.jetbrains.jet.utils.KotlinPathsFromHomeDir; import org.jetbrains.jet.utils.PathUtil; import java.io.File; @@ -199,7 +200,7 @@ public class BytecodeCompiler { } private static KotlinPaths getKotlinPathsForAntTask() { - return new KotlinPaths(PathUtil.getJarPathForClass(BytecodeCompiler.class).getParentFile().getParentFile()); + return new KotlinPathsFromHomeDir(PathUtil.getJarPathForClass(BytecodeCompiler.class).getParentFile().getParentFile()); } } diff --git a/compiler/tests/org/jetbrains/jet/JetTestUtils.java b/compiler/tests/org/jetbrains/jet/JetTestUtils.java index fcb851e5b51..6f4681404da 100644 --- a/compiler/tests/org/jetbrains/jet/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/jet/JetTestUtils.java @@ -51,6 +51,7 @@ import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; import org.jetbrains.jet.util.slicedmap.SlicedMap; import org.jetbrains.jet.util.slicedmap.WritableSlice; import org.jetbrains.jet.utils.KotlinPaths; +import org.jetbrains.jet.utils.KotlinPathsFromHomeDir; import org.junit.Assert; import javax.tools.*; @@ -492,7 +493,7 @@ public class JetTestUtils { } public static KotlinPaths getPathsForTests() { - return new KotlinPaths(new File("dist/kotlinc")); + return new KotlinPathsFromHomeDir(new File("dist/kotlinc")); } public static JetFile loadJetFile(@NotNull Project project, @NotNull File ioFile) throws IOException { diff --git a/compiler/util/src/org/jetbrains/jet/utils/KotlinPaths.java b/compiler/util/src/org/jetbrains/jet/utils/KotlinPaths.java index 67ba3b1386f..a6f6408bd40 100644 --- a/compiler/util/src/org/jetbrains/jet/utils/KotlinPaths.java +++ b/compiler/util/src/org/jetbrains/jet/utils/KotlinPaths.java @@ -20,46 +20,22 @@ import org.jetbrains.annotations.NotNull; import java.io.File; -public class KotlinPaths { - // kotlinc directory - private final File homePath; - - public KotlinPaths(@NotNull File homePath) { - this.homePath = homePath; - } +public interface KotlinPaths { + @NotNull + File getHomePath(); @NotNull - public File getHomePath() { - return homePath; - } + File getLibPath(); @NotNull - public File getLibPath() { - return new File(homePath, "lib"); - } + File getRuntimePath(); @NotNull - public File getRuntimePath() { - return getLibraryFile("kotlin-runtime.jar"); - } + File getJdkAnnotationsPath(); @NotNull - public File getJdkAnnotationsPath() { - return getLibraryFile(PathUtil.JDK_ANNOTATIONS_JAR); - } + File getJsLibJsPath(); @NotNull - public File getJsLibJsPath() { - return getLibraryFile(PathUtil.JS_LIB_JS_NAME); - } - - @NotNull - public File getJsLibJarPath() { - return getLibraryFile(PathUtil.JS_LIB_JAR_NAME); - } - - @NotNull - private File getLibraryFile(@NotNull String fileName) { - return new File(getLibPath(), fileName); - } + File getJsLibJarPath(); } diff --git a/compiler/util/src/org/jetbrains/jet/utils/KotlinPathsFromHomeDir.java b/compiler/util/src/org/jetbrains/jet/utils/KotlinPathsFromHomeDir.java new file mode 100644 index 00000000000..789c86b36c6 --- /dev/null +++ b/compiler/util/src/org/jetbrains/jet/utils/KotlinPathsFromHomeDir.java @@ -0,0 +1,71 @@ +/* + * 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.utils; + +import org.jetbrains.annotations.NotNull; + +import java.io.File; + +public class KotlinPathsFromHomeDir implements KotlinPaths { + // kotlinc directory + private final File homePath; + + public KotlinPathsFromHomeDir(@NotNull File homePath) { + this.homePath = homePath; + } + + @Override + @NotNull + public File getHomePath() { + return homePath; + } + + @Override + @NotNull + public File getLibPath() { + return new File(homePath, "lib"); + } + + @Override + @NotNull + public File getRuntimePath() { + return getLibraryFile("kotlin-runtime.jar"); + } + + @Override + @NotNull + public File getJdkAnnotationsPath() { + return getLibraryFile(PathUtil.JDK_ANNOTATIONS_JAR); + } + + @Override + @NotNull + public File getJsLibJsPath() { + return getLibraryFile(PathUtil.JS_LIB_JS_NAME); + } + + @Override + @NotNull + public File getJsLibJarPath() { + return getLibraryFile(PathUtil.JS_LIB_JAR_NAME); + } + + @NotNull + private File getLibraryFile(@NotNull String fileName) { + return new File(getLibPath(), fileName); + } +} diff --git a/compiler/util/src/org/jetbrains/jet/utils/PathUtil.java b/compiler/util/src/org/jetbrains/jet/utils/PathUtil.java index a659126a94b..4df763b3c6e 100644 --- a/compiler/util/src/org/jetbrains/jet/utils/PathUtil.java +++ b/compiler/util/src/org/jetbrains/jet/utils/PathUtil.java @@ -39,12 +39,12 @@ public class PathUtil { @NotNull public static KotlinPaths getKotlinPathsForIdeaPlugin() { - return new KotlinPaths(getCompilerPathForIdeaPlugin()); + return new KotlinPathsFromHomeDir(getCompilerPathForIdeaPlugin()); } @NotNull public static KotlinPaths getKotlinPathsForJpsPlugin() { - return new KotlinPaths(getCompilerPathForJpsPlugin()); + return new KotlinPathsFromHomeDir(getCompilerPathForJpsPlugin()); } @NotNull @@ -61,12 +61,12 @@ public class PathUtil { // Not running from a jar, i.e. it is it must be a unit test return getKotlinPathsForDistDirectory(); } - return new KotlinPaths(getCompilerPathForCompilerJar()); + return new KotlinPathsFromHomeDir(getCompilerPathForCompilerJar()); } @NotNull public static KotlinPaths getKotlinPathsForDistDirectory() { - return new KotlinPaths(new File("dist/kotlinc")); + return new KotlinPathsFromHomeDir(new File("dist/kotlinc")); } @NotNull