001    /*
002     * Copyright 2010-2016 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.cli.common.arguments;
018    
019    import com.sampullara.cli.Argument;
020    import org.jetbrains.annotations.NotNull;
021    
022    public class K2JVMCompilerArguments extends CommonCompilerArguments {
023        public static final long serialVersionUID = 0L;
024    
025        @Argument(value = "d", description = "Destination for generated class files")
026        @ValueDescription("<directory|jar>")
027        public String destination;
028    
029        @Argument(value = "classpath", alias = "cp", description = "Paths where to find user class files")
030        @ValueDescription("<path>")
031        public String classpath;
032    
033        @GradleOption(DefaultValues.BooleanFalseDefault.class)
034        @Argument(value = "include-runtime", description = "Include Kotlin runtime in to resulting .jar")
035        public boolean includeRuntime;
036    
037        @GradleOption(DefaultValues.StringNullDefault.class)
038        @Argument(value = "jdk-home", description = "Path to JDK home directory to include into classpath, if differs from default JAVA_HOME")
039        @ValueDescription("<path>")
040        public String jdkHome;
041    
042        @GradleOption(DefaultValues.BooleanFalseDefault.class)
043        @Argument(value = "no-jdk", description = "Don't include Java runtime into classpath")
044        public boolean noJdk;
045    
046        @GradleOption(DefaultValues.BooleanTrueDefault.class)
047        @Argument(value = "no-stdlib", description = "Don't include Kotlin runtime into classpath")
048        public boolean noStdlib;
049    
050        @GradleOption(DefaultValues.BooleanTrueDefault.class)
051        @Argument(value = "no-reflect", description = "Don't include Kotlin reflection implementation into classpath")
052        public boolean noReflect;
053    
054        @Argument(value = "module", description = "Path to the module file to compile")
055        @ValueDescription("<path>")
056        public String module;
057    
058        @Argument(value = "script", description = "Evaluate the script file")
059        public boolean script;
060    
061        @Argument(value = "script-templates", description = "Script definition template classes")
062        @ValueDescription("<fully qualified class name[,]>")
063        public String[] scriptTemplates;
064    
065        @Argument(value = "kotlin-home", description = "Path to Kotlin compiler home directory, used for runtime libraries discovery")
066        @ValueDescription("<path>")
067        public String kotlinHome;
068    
069        @Argument(value = "module-name", description = "Module name")
070        public String moduleName;
071    
072        @GradleOption(DefaultValues.JvmTargetVersions.class)
073        @Argument(value = "jvm-target", description = "Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6")
074        @ValueDescription("<version>")
075        public String jvmTarget;
076    
077        @GradleOption(DefaultValues.BooleanFalseDefault.class)
078        @Argument(value = "java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters")
079        public boolean javaParameters;
080    
081        // Advanced options
082        @Argument(value = "Xno-call-assertions", description = "Don't generate not-null assertion after each invocation of method returning not-null")
083        public boolean noCallAssertions;
084    
085        @Argument(value = "Xno-param-assertions", description = "Don't generate not-null assertions on parameters of methods accessible from Java")
086        public boolean noParamAssertions;
087    
088        @Argument(value = "Xno-optimize", description = "Disable optimizations")
089        public boolean noOptimize;
090    
091        @Argument(value = "Xreport-perf", description = "Report detailed performance statistics")
092        public boolean reportPerf;
093    
094        @Argument(value = "Xmultifile-parts-inherit", description = "Compile multifile classes as a hierarchy of parts and facade")
095        public boolean inheritMultifileParts;
096    
097        @Argument(value = "Xskip-metadata-version-check", description = "Load classes with bad metadata version anyway (incl. pre-release classes)")
098        public boolean skipMetadataVersionCheck;
099    
100        @Argument(value = "Xskip-runtime-version-check", description = "Allow Kotlin runtime libraries of incompatible versions in the classpath")
101        public boolean skipRuntimeVersionCheck;
102    
103        @Argument(value = "Xdump-declarations-to", description = "Path to JSON file to dump Java to Kotlin declaration mappings")
104        @ValueDescription("<path>")
105        public String declarationsOutputPath;
106    
107        @Argument(value = "Xsingle-module", description = "Combine modules for source files and binary dependencies into a single module")
108        public boolean singleModule;
109    
110        @Argument(value = "Xadd-compiler-builtins", description = "Add definitions of built-in declarations to the compilation classpath (useful with -no-stdlib)")
111        public boolean addCompilerBuiltIns;
112    
113        @Argument(value = "Xload-builtins-from-dependencies", description = "Load definitions of built-in declarations from module dependencies, instead of from the compiler")
114        public boolean loadBuiltInsFromDependencies;
115    
116        // Paths to output directories for friend modules.
117        public String[] friendPaths;
118    
119        @Override
120        @NotNull
121        public String executableScriptFileName() {
122            return "kotlinc-jvm";
123        }
124    
125    }