Added no-stdlib and -Xfriend-paths compile options
This commit is contained in:
parent
04fd7fe037
commit
51d046a2f7
4 changed files with 31 additions and 5 deletions
1
examples/.idea/.name
generated
Normal file
1
examples/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
|||
bld-koltin-examples
|
|
@ -198,7 +198,8 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
executeBuildSources(
|
||||
compileMainClasspath(),
|
||||
sources(mainSourceFiles(), mainSourceDirectories()),
|
||||
buildMainDirectory());
|
||||
buildMainDirectory(),
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,8 +208,9 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
* @param classpath the classpath list used for the compilation
|
||||
* @param sources the source files to compile
|
||||
* @param destination the destination directory
|
||||
* @param friendPaths the output directory for friendly modules
|
||||
*/
|
||||
protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination)
|
||||
protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination, File friendPaths)
|
||||
throws IOException {
|
||||
if (sources.isEmpty() || destination == null) {
|
||||
return;
|
||||
|
@ -225,8 +227,11 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
args.add("-d");
|
||||
args.add(destination.getAbsolutePath());
|
||||
|
||||
args.add("-no-reflect");
|
||||
args.add("-no-stdlib");
|
||||
// friend-path
|
||||
if (friendPaths != null) {
|
||||
args.add("-Xfriend-paths");
|
||||
args.add(friendPaths.getAbsolutePath());
|
||||
}
|
||||
|
||||
// options
|
||||
if (compileOptions_ != null) {
|
||||
|
@ -254,7 +259,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
|
|||
executeBuildSources(
|
||||
compileTestClasspath(),
|
||||
sources(testSourceFiles(), testSourceDirectories()),
|
||||
buildTestDirectory());
|
||||
buildTestDirectory(), buildMainDirectory());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,7 @@ public class CompileKotlinOptions {
|
|||
private String moduleName_;
|
||||
private boolean noJdk_;
|
||||
private boolean noReflect_;
|
||||
private boolean noStdLib_ = true;
|
||||
private boolean noWarn_;
|
||||
private String path_;
|
||||
private boolean progressive_;
|
||||
|
@ -177,6 +178,11 @@ public class CompileKotlinOptions {
|
|||
args.add("-no-reflect");
|
||||
}
|
||||
|
||||
// no-std-lib
|
||||
if (noStdLib_) {
|
||||
args.add("-no-stdlib");
|
||||
}
|
||||
|
||||
// no-warn
|
||||
if (noWarn_) {
|
||||
args.add("-no-warn");
|
||||
|
@ -398,6 +404,18 @@ public class CompileKotlinOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't automatically include the Kotlin/JVM stdlib ({@code kotlin-stdlib.jar}) and Kotlin reflection
|
||||
* ({@code kotlin-reflect.jar}) into the classpath.
|
||||
*
|
||||
* @param noStdLib {@code true} or {@code false}
|
||||
* @return this class instance
|
||||
*/
|
||||
public CompileKotlinOptions noStdLib(boolean noStdLib) {
|
||||
noStdLib_ = noStdLib;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppress the compiler from displaying warnings during compilation.
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@ class CompileKotlinOptionsTest {
|
|||
var args = new CompileKotlinOptions()
|
||||
.argFile(List.of("arg1.txt", "arg2.txt"))
|
||||
.classpath(List.of("path1", "path2"))
|
||||
.noStdLib(false)
|
||||
.optIn(List.of("opt1", "opt2"))
|
||||
.options(List.of("-foo", "-bar"))
|
||||
.scriptTemplates(List.of("temp1", "temp2"))
|
||||
|
@ -92,6 +93,7 @@ class CompileKotlinOptionsTest {
|
|||
"-module-name", "module",
|
||||
"-no-jdk",
|
||||
"-no-reflect",
|
||||
"-no-stdlib",
|
||||
"-no-warn",
|
||||
"-opt-in", "opt1",
|
||||
"-opt-in", "opt2",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue