001 /*
002 * Copyright 2010-2015 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.kotlin.utils;
018
019 import org.jetbrains.annotations.NotNull;
020
021 import java.io.File;
022
023 public class KotlinPathsFromHomeDir implements KotlinPaths {
024 // kotlinc directory
025 private final File homePath;
026
027 public KotlinPathsFromHomeDir(@NotNull File homePath) {
028 this.homePath = homePath;
029 }
030
031 @Override
032 @NotNull
033 public File getHomePath() {
034 return homePath;
035 }
036
037 @Override
038 @NotNull
039 public File getLibPath() {
040 return new File(homePath, "lib");
041 }
042
043 @Override
044 @NotNull
045 public File getRuntimePath() {
046 return getLibraryFile(PathUtil.KOTLIN_JAVA_RUNTIME_JAR);
047 }
048
049 @NotNull
050 @Override
051 public File getReflectPath() {
052 return getLibraryFile(PathUtil.KOTLIN_JAVA_REFLECT_JAR);
053 }
054
055 @Override
056 @NotNull
057 public File getScriptRuntimePath() {
058 return getLibraryFile(PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR);
059 }
060
061 @NotNull
062 @Override
063 public File getKotlinTestPath() {
064 return getLibraryFile(PathUtil.KOTLIN_TEST_JAR);
065 }
066
067 @NotNull
068 @Override
069 public File getRuntimeSourcesPath() {
070 return getLibraryFile(PathUtil.KOTLIN_JAVA_RUNTIME_SRC_JAR);
071 }
072
073 @Override
074 @NotNull
075 public File getJsStdLibJarPath() {
076 return getLibraryFile(PathUtil.JS_LIB_JAR_NAME);
077 }
078
079 @Override
080 @NotNull
081 public File getJsStdLibSrcJarPath() {
082 return getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME);
083 }
084
085 @NotNull
086 @Override
087 public File getJsKotlinTestJarPath() {
088 return getLibraryFile(PathUtil.KOTLIN_TEST_JS_JAR);
089 }
090
091 @NotNull
092 @Override
093 public File getAllOpenPluginJarPath() {
094 return getLibraryFile(PathUtil.ALLOPEN_PLUGIN_JAR_NAME);
095 }
096
097 @NotNull
098 @Override
099 public File getNoArgPluginJarPath() {
100 return getLibraryFile(PathUtil.NOARG_PLUGIN_JAR_NAME);
101 }
102
103 @NotNull
104 @Override
105 public File getCompilerPath() {
106 return getLibraryFile(PathUtil.KOTLIN_COMPILER_JAR);
107 }
108
109 @NotNull
110 @Override
111 public File getBuildNumberFile() {
112 return new File(homePath, "build.txt");
113 }
114
115 @NotNull
116 private File getLibraryFile(@NotNull String fileName) {
117 return new File(getLibPath(), fileName);
118 }
119 }