Misc: Fix compiler argument usages after refactoring
This commit is contained in:
+1
-1
@@ -89,7 +89,7 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil
|
||||
environment: GradleCompilerEnvironment
|
||||
): ExitCode {
|
||||
val buildFile = makeModuleFile(
|
||||
args.moduleName,
|
||||
args.moduleName!!,
|
||||
isTest = false,
|
||||
outputDir = args.destinationAsFile,
|
||||
sourcesToCompile = sourcesToCompile,
|
||||
|
||||
+2
-2
@@ -66,8 +66,8 @@ open class KaptGenerateStubsTask : KotlinCompile() {
|
||||
val args = createCompilerArgs()
|
||||
|
||||
kotlinCompileTask.setupCompilerArgs(args)
|
||||
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths).toSet().toTypedArray()
|
||||
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions).toTypedArray()
|
||||
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths!!).toSet().toTypedArray()
|
||||
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions!!).toTypedArray()
|
||||
args.verbose = project.hasProperty("kapt.verbose") && project.property("kapt.verbose").toString().toBoolean() == true
|
||||
args.classpathAsList = this.compileClasspath.toList()
|
||||
args.destinationAsFile = this.destinationDir
|
||||
|
||||
+2
-2
@@ -55,8 +55,8 @@ open class KaptTask : ConventionTask() {
|
||||
val args = K2JVMCompilerArguments()
|
||||
kotlinCompileTask.setupCompilerArgs(args)
|
||||
|
||||
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths).toSet().toTypedArray()
|
||||
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions).toTypedArray()
|
||||
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths!!).toSet().toTypedArray()
|
||||
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions!!).toTypedArray()
|
||||
args.verbose = project.hasProperty("kapt.verbose") && project.property("kapt.verbose").toString().toBoolean() == true
|
||||
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompil
|
||||
with(args) {
|
||||
classpath = classpathList.joinToString(File.pathSeparator)
|
||||
destination = destinationDir.canonicalPath
|
||||
freeArgs = sourceRoots.kotlinSourceFiles.map { it.canonicalPath }
|
||||
freeArgs = sourceRoots.kotlinSourceFiles.mapTo(ArrayList<String>()) { it.canonicalPath }
|
||||
}
|
||||
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
|
||||
+10
-10
@@ -96,11 +96,11 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JSCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
arguments.outputFile = outputFile;
|
||||
arguments.noStdlib = true;
|
||||
arguments.metaInfo = metaInfo;
|
||||
arguments.moduleKind = moduleKind;
|
||||
arguments.main = main;
|
||||
arguments.setOutputFile(outputFile);
|
||||
arguments.setNoStdlib(true);
|
||||
arguments.setMetaInfo(metaInfo);
|
||||
arguments.setModuleKind(moduleKind);
|
||||
arguments.setMain(main);
|
||||
|
||||
List<String> libraries;
|
||||
try {
|
||||
@@ -109,11 +109,11 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
throw new MojoExecutionException("Unresolved dependencies", e);
|
||||
}
|
||||
getLog().debug("libraries: " + libraries);
|
||||
arguments.libraries = StringUtil.join(libraries, File.pathSeparator);
|
||||
arguments.setLibraries(StringUtil.join(libraries, File.pathSeparator));
|
||||
|
||||
arguments.sourceMap = sourceMap;
|
||||
arguments.sourceMapPrefix = sourceMapPrefix;
|
||||
arguments.sourceMapEmbedSources = sourceMapEmbedSources;
|
||||
arguments.setSourceMap(sourceMap);
|
||||
arguments.setSourceMapPrefix(sourceMapPrefix);
|
||||
arguments.setSourceMapEmbedSources(sourceMapEmbedSources);
|
||||
|
||||
if (outputFile != null) {
|
||||
ConcurrentMap<String, List<String>> collector = getOutputDirectoriesCollector();
|
||||
@@ -131,7 +131,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
}
|
||||
}
|
||||
|
||||
arguments.sourceMapSourceRoots = sourceMapSourceRoots.toString();
|
||||
arguments.setSourceMapSourceRoots(sourceMapSourceRoots.toString());
|
||||
}
|
||||
|
||||
protected List<String> getClassPathElements() throws DependencyResolutionRequiredException {
|
||||
|
||||
+11
-11
@@ -139,11 +139,11 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
||||
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JVMCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
arguments.destination = output;
|
||||
arguments.setDestination(output);
|
||||
|
||||
// don't include runtime, it should be in maven dependencies
|
||||
arguments.noStdlib = true;
|
||||
arguments.javaParameters = this.javaParameters;
|
||||
arguments.setNoStdlib(true);
|
||||
arguments.setJavaParameters(this.javaParameters);
|
||||
|
||||
//noinspection deprecation
|
||||
if (module != null || testModule != null) {
|
||||
@@ -156,35 +156,35 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
||||
String classPathString = join(classpathList, File.pathSeparator);
|
||||
if (isJava9Module(sourceRoots)) {
|
||||
getLog().debug("Module path: " + classPathString);
|
||||
arguments.javaModulePath = classPathString;
|
||||
arguments.setJavaModulePath(classPathString);
|
||||
}
|
||||
else {
|
||||
getLog().debug("Classpath: " + classPathString);
|
||||
arguments.classpath = classPathString;
|
||||
arguments.setClasspath(classPathString);
|
||||
}
|
||||
}
|
||||
|
||||
getLog().debug("Classes directory is " + output);
|
||||
arguments.destination = output;
|
||||
arguments.setDestination(output);
|
||||
|
||||
arguments.moduleName = moduleName;
|
||||
arguments.setModuleName(moduleName);
|
||||
getLog().info("Module name is " + moduleName);
|
||||
|
||||
if (arguments.noOptimize) {
|
||||
if (arguments.getNoOptimize()) {
|
||||
getLog().info("Optimization is turned off");
|
||||
}
|
||||
|
||||
if (jvmTarget != null) {
|
||||
arguments.jvmTarget = jvmTarget;
|
||||
arguments.setJvmTarget(jvmTarget);
|
||||
}
|
||||
|
||||
if (jdkHome != null) {
|
||||
getLog().info("Overriding JDK home path with: " + jdkHome);
|
||||
arguments.jdkHome = jdkHome;
|
||||
arguments.setJdkHome(jdkHome);
|
||||
}
|
||||
|
||||
if (scriptTemplates != null && !scriptTemplates.isEmpty()) {
|
||||
arguments.scriptTemplates = scriptTemplates.toArray(new String[0]);
|
||||
arguments.setScriptTemplates(scriptTemplates.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -230,7 +230,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
List<File> sourceRoots
|
||||
) throws MojoExecutionException {
|
||||
for (File sourceRoot : sourceRoots) {
|
||||
arguments.freeArgs.add(sourceRoot.getPath());
|
||||
arguments.getFreeArgs().add(sourceRoot.getPath());
|
||||
}
|
||||
return compiler.exec(messageCollector, Services.EMPTY, arguments);
|
||||
}
|
||||
@@ -439,16 +439,16 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
|
||||
private void configureCompilerArguments(@NotNull A arguments, @NotNull CLICompiler<A> compiler, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
if (getLog().isDebugEnabled()) {
|
||||
arguments.verbose = true;
|
||||
arguments.setVerbose(true);
|
||||
}
|
||||
|
||||
arguments.suppressWarnings = nowarn;
|
||||
arguments.languageVersion = languageVersion;
|
||||
arguments.apiVersion = apiVersion;
|
||||
arguments.multiPlatform = multiPlatform;
|
||||
arguments.setSuppressWarnings(nowarn);
|
||||
arguments.setLanguageVersion(languageVersion);
|
||||
arguments.setApiVersion(apiVersion);
|
||||
arguments.setMultiPlatform(multiPlatform);
|
||||
|
||||
if (experimentalCoroutines != null) {
|
||||
arguments.coroutinesState = experimentalCoroutines;
|
||||
arguments.setCoroutinesState(experimentalCoroutines);
|
||||
}
|
||||
|
||||
configureSpecificCompilerArguments(arguments, sourceRoots);
|
||||
@@ -460,24 +460,24 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
throw new MojoExecutionException(e.getMessage());
|
||||
}
|
||||
|
||||
if (arguments.noInline) {
|
||||
if (arguments.getNoInline()) {
|
||||
getLog().info("Method inlining is turned off");
|
||||
}
|
||||
|
||||
List<String> pluginClassPaths = getCompilerPluginClassPaths();
|
||||
if (pluginClassPaths != null && !pluginClassPaths.isEmpty()) {
|
||||
if (arguments.pluginClasspaths == null || arguments.pluginClasspaths.length == 0) {
|
||||
arguments.pluginClasspaths = pluginClassPaths.toArray(new String[pluginClassPaths.size()]);
|
||||
if (arguments.getPluginClasspaths() == null || arguments.getPluginClasspaths().length == 0) {
|
||||
arguments.setPluginClasspaths(pluginClassPaths.toArray(new String[pluginClassPaths.size()]));
|
||||
} else {
|
||||
for (String path : pluginClassPaths) {
|
||||
if (ArrayUtil.indexOf(arguments.pluginClasspaths, path) < 0) {
|
||||
arguments.pluginClasspaths = ArrayUtil.append(arguments.pluginClasspaths, path);
|
||||
if (ArrayUtil.indexOf(arguments.getPluginClasspaths(), path) < 0) {
|
||||
arguments.setPluginClasspaths(ArrayUtil.append(arguments.getPluginClasspaths(), path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("Plugin classpaths are: " + Joiner.on(", ").join(arguments.pluginClasspaths));
|
||||
getLog().debug("Plugin classpaths are: " + Joiner.on(", ").join(arguments.getPluginClasspaths()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -494,7 +494,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
getLog().debug("Plugin options are: " + Joiner.on(", ").join(pluginArguments));
|
||||
}
|
||||
|
||||
arguments.pluginOptions = pluginArguments.toArray(new String[pluginArguments.size()]);
|
||||
arguments.setPluginOptions(pluginArguments.toArray(new String[pluginArguments.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class KotlinTestCompileMojo extends K2JVMCompileMojo {
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JVMCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
classpath = testClasspath;
|
||||
arguments.friendPaths = new String[] { output };
|
||||
arguments.setFriendPaths(new String[] { output });
|
||||
output = testOutput;
|
||||
super.configureSpecificCompilerArguments(arguments, sourceRoots);
|
||||
}
|
||||
|
||||
+3
-3
@@ -81,13 +81,13 @@ public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo {
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JSCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
List<String> friends = getOutputDirectoriesCollector().getOrDefault(project.getArtifactId(), Collections.emptyList());
|
||||
arguments.friendModules = StringUtil.join(friends, File.pathSeparator);
|
||||
arguments.setFriendModules(StringUtil.join(friends, File.pathSeparator));
|
||||
output = testOutput;
|
||||
|
||||
super.configureSpecificCompilerArguments(arguments, sourceRoots);
|
||||
|
||||
arguments.outputFile = outputFile;
|
||||
arguments.metaInfo = metaInfo;
|
||||
arguments.setOutputFile(outputFile);
|
||||
arguments.setMetaInfo(metaInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -61,10 +61,10 @@ public class MetadataMojo extends KotlinCompileMojoBase<K2MetadataCompilerArgume
|
||||
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2MetadataCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
arguments.destination = output;
|
||||
if (!arguments.multiPlatform) {
|
||||
arguments.setDestination(output);
|
||||
if (!arguments.getMultiPlatform()) {
|
||||
getLog().info("multiPlatform forced for metadata generation");
|
||||
arguments.multiPlatform = true;
|
||||
arguments.setMultiPlatform(true);
|
||||
}
|
||||
|
||||
List<String> classpathList = filterClassPath(project.getBasedir(), classpath);
|
||||
@@ -73,7 +73,7 @@ public class MetadataMojo extends KotlinCompileMojoBase<K2MetadataCompilerArgume
|
||||
if (!classpathList.isEmpty()) {
|
||||
String classPathString = join(classpathList, File.pathSeparator);
|
||||
getLog().debug("Classpath: " + classPathString);
|
||||
arguments.classpath = classPathString;
|
||||
arguments.setClasspath(classPathString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -49,10 +49,10 @@ public class TestMetadataMojo extends MetadataMojo {
|
||||
output = testOutput;
|
||||
super.configureSpecificCompilerArguments(arguments, sourceRoots);
|
||||
|
||||
if (arguments.classpath == null) {
|
||||
arguments.classpath = productionOutput;
|
||||
if (arguments.getClasspath() == null) {
|
||||
arguments.setClasspath(productionOutput);
|
||||
} else {
|
||||
arguments.classpath = arguments.classpath + File.pathSeparator + productionOutput;
|
||||
arguments.setClasspath(arguments.getClasspath() + File.pathSeparator + productionOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -83,7 +83,7 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
||||
options.add(new KaptOption("correctErrorTypes", correctErrorTypes));
|
||||
options.add(new KaptOption("processors", annotationProcessors));
|
||||
|
||||
if (arguments.verbose) {
|
||||
if (arguments.getVerbose()) {
|
||||
options.add(new KaptOption("verbose", true));
|
||||
}
|
||||
|
||||
@@ -133,13 +133,17 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
||||
}
|
||||
|
||||
String[] kaptOptions = renderKaptOptions(getKaptOptions(arguments, resolvedArtifacts));
|
||||
arguments.pluginOptions = joinArrays(arguments.pluginOptions, kaptOptions);
|
||||
arguments.setPluginOptions(joinArrays(arguments.getPluginOptions(), kaptOptions));
|
||||
|
||||
String jdkToolsJarPath = getJdkToolsJarPath();
|
||||
arguments.pluginClasspaths = joinArrays(arguments.pluginClasspaths,
|
||||
(jdkToolsJarPath == null)
|
||||
? new String[] { resolvedArtifacts.kaptCompilerPluginArtifact }
|
||||
: new String[] { jdkToolsJarPath, resolvedArtifacts.kaptCompilerPluginArtifact });
|
||||
arguments.setPluginClasspaths(
|
||||
joinArrays(
|
||||
arguments.getPluginClasspaths(),
|
||||
(jdkToolsJarPath == null)
|
||||
? new String[]{resolvedArtifacts.kaptCompilerPluginArtifact}
|
||||
: new String[]{jdkToolsJarPath, resolvedArtifacts.kaptCompilerPluginArtifact}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class KaptTestJvmCompilerMojo extends KaptJVMCompilerMojo {
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JVMCompilerArguments arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException {
|
||||
classpath = testClasspath;
|
||||
arguments.friendPaths = new String[] { output };
|
||||
arguments.setFriendPaths(new String[] { output });
|
||||
output = testOutput;
|
||||
super.configureSpecificCompilerArguments(arguments, sourceRoots);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user