Maven plugin: fix warnings, update copyrights
This commit is contained in:
+12
-21
@@ -23,7 +23,6 @@ import org.apache.maven.artifact.DefaultArtifact;
|
|||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
@@ -58,6 +57,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to execute kotlin script files during the build process.
|
* Allows to execute kotlin script files during the build process.
|
||||||
@@ -106,13 +106,13 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
@Parameter(defaultValue = "${localRepository}", required = true, readonly = true)
|
@Parameter(defaultValue = "${localRepository}", required = true, readonly = true)
|
||||||
private ArtifactRepository localRepository;
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.scriptTemplates", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.scriptTemplates")
|
||||||
protected List<String> scriptTemplates;
|
protected List<String> scriptTemplates;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.scriptArguments", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.scriptArguments")
|
||||||
protected List<String> scriptArguments;
|
protected List<String> scriptArguments;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.scriptClasspath", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.scriptClasspath")
|
||||||
protected List<String> scriptClasspath;
|
protected List<String> scriptClasspath;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -167,7 +167,7 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
|
|
||||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
||||||
|
|
||||||
List<File> deps = new ArrayList<File>();
|
List<File> deps = new ArrayList<>();
|
||||||
|
|
||||||
deps.addAll(PathUtil.getJdkClassesRootsFromCurrentJre());
|
deps.addAll(PathUtil.getJdkClassesRootsFromCurrentJre());
|
||||||
deps.addAll(getDependenciesForScript());
|
deps.addAll(getDependenciesForScript());
|
||||||
@@ -184,7 +184,10 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
configuration.add(JVMConfigurationKeys.CONTENT_ROOTS, new KotlinSourceRoot(scriptFile.getAbsolutePath()));
|
configuration.add(JVMConfigurationKeys.CONTENT_ROOTS, new KotlinSourceRoot(scriptFile.getAbsolutePath()));
|
||||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, JvmAbi.DEFAULT_MODULE_NAME);
|
configuration.put(CommonConfigurationKeys.MODULE_NAME, JvmAbi.DEFAULT_MODULE_NAME);
|
||||||
|
|
||||||
K2JVMCompiler.Companion.configureScriptDefinitions(scriptTemplates.toArray(new String[scriptTemplates.size()]), configuration, messageCollector, new HashMap<String, Object>());
|
K2JVMCompiler.Companion.configureScriptDefinitions(
|
||||||
|
scriptTemplates.toArray(new String[scriptTemplates.size()]),
|
||||||
|
configuration, messageCollector, new HashMap<>()
|
||||||
|
);
|
||||||
|
|
||||||
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||||
|
|
||||||
@@ -214,7 +217,7 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<File> getDependenciesForScript() throws MojoExecutionException {
|
private List<File> getDependenciesForScript() throws MojoExecutionException {
|
||||||
List<File> deps = new ArrayList<File>();
|
List<File> deps = new ArrayList<>();
|
||||||
|
|
||||||
deps.addAll(getKotlinRuntimeDependencies());
|
deps.addAll(getKotlinRuntimeDependencies());
|
||||||
deps.add(getThisPluginAsDependency());
|
deps.add(getThisPluginAsDependency());
|
||||||
@@ -234,25 +237,13 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
return getArtifactFile(artifact);
|
return getArtifactFile(artifact);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getDependencyFile(Dependency dep) {
|
|
||||||
ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(dep.getType());
|
|
||||||
Artifact artifact = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), null, dep.getType(), null, artifactHandler);
|
|
||||||
return getArtifactFile(artifact);
|
|
||||||
}
|
|
||||||
|
|
||||||
private File getArtifactFile(Artifact artifact) {
|
private File getArtifactFile(Artifact artifact) {
|
||||||
localRepository.find(artifact);
|
localRepository.find(artifact);
|
||||||
return artifact.getFile();
|
return artifact.getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<File> getThisPluginDependencies() {
|
private List<File> getThisPluginDependencies() {
|
||||||
List<File> files = new ArrayList<File>();
|
return plugin.getDependencies().stream().map(this::getDependencyFile).collect(Collectors.toList());
|
||||||
|
|
||||||
for (ComponentDependency dep: plugin.getDependencies()) {
|
|
||||||
files.add(getDependencyFile(dep));
|
|
||||||
}
|
|
||||||
|
|
||||||
return files;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getThisPluginAsDependency() {
|
private File getThisPluginAsDependency() {
|
||||||
@@ -269,7 +260,7 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
|
|||||||
Artifact stdlibDep = null;
|
Artifact stdlibDep = null;
|
||||||
Artifact runtimeDep = null;
|
Artifact runtimeDep = null;
|
||||||
|
|
||||||
ArrayList<File> files = new ArrayList<File>(2);
|
ArrayList<File> files = new ArrayList<>(2);
|
||||||
|
|
||||||
for (Artifact dep: project.getArtifacts()) {
|
for (Artifact dep: project.getArtifacts()) {
|
||||||
if (dep.getArtifactId().equals("kotlin-stdlib")) {
|
if (dep.getArtifactId().equals("kotlin-stdlib")) {
|
||||||
|
|||||||
+16
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
|||||||
+5
-5
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -102,7 +102,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
|||||||
arguments.moduleKind = moduleKind;
|
arguments.moduleKind = moduleKind;
|
||||||
arguments.main = main;
|
arguments.main = main;
|
||||||
|
|
||||||
List<String> libraries = null;
|
List<String> libraries;
|
||||||
try {
|
try {
|
||||||
libraries = getKotlinJavascriptLibraryFiles();
|
libraries = getKotlinJavascriptLibraryFiles();
|
||||||
} catch (DependencyResolutionRequiredException e) {
|
} catch (DependencyResolutionRequiredException e) {
|
||||||
@@ -118,7 +118,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
|||||||
if (outputFile != null) {
|
if (outputFile != null) {
|
||||||
ConcurrentMap<String, List<String>> collector = getOutputDirectoriesCollector();
|
ConcurrentMap<String, List<String>> collector = getOutputDirectoriesCollector();
|
||||||
String key = project.getArtifactId();
|
String key = project.getArtifactId();
|
||||||
List<String> paths = collector.computeIfAbsent(key, k -> Collections.synchronizedList(new ArrayList<String>()));
|
List<String> paths = collector.computeIfAbsent(key, k -> Collections.synchronizedList(new ArrayList<>()));
|
||||||
paths.add(new File(outputFile).getParent());
|
paths.add(new File(outputFile).getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<String> getKotlinJavascriptLibraryFiles() throws DependencyResolutionRequiredException {
|
private List<String> getKotlinJavascriptLibraryFiles() throws DependencyResolutionRequiredException {
|
||||||
List<String> libraries = new ArrayList<String>();
|
List<String> libraries = new ArrayList<>();
|
||||||
|
|
||||||
for (String path : getClassPathElements()) {
|
for (String path : getClassPathElements()) {
|
||||||
File file = new File(path);
|
File file = new File(path);
|
||||||
@@ -197,7 +197,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
|||||||
try {
|
try {
|
||||||
ConcurrentMap<String, List<String>> collector = (ConcurrentMap<String, List<String>>) getPluginContext().get(OUTPUT_DIRECTORIES_COLLECTOR_PROPERTY_NAME);
|
ConcurrentMap<String, List<String>> collector = (ConcurrentMap<String, List<String>>) getPluginContext().get(OUTPUT_DIRECTORIES_COLLECTOR_PROPERTY_NAME);
|
||||||
if (collector == null) {
|
if (collector == null) {
|
||||||
collector = new ConcurrentSkipListMap<String, List<String>>();
|
collector = new ConcurrentSkipListMap<>();
|
||||||
getPluginContext().put(OUTPUT_DIRECTORIES_COLLECTOR_PROPERTY_NAME, collector);
|
getPluginContext().put(OUTPUT_DIRECTORIES_COLLECTOR_PROPERTY_NAME, collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-11
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,10 @@ package org.jetbrains.kotlin.maven;
|
|||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugins.annotations.*;
|
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||||
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -34,7 +37,8 @@ import org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.intellij.openapi.util.text.StringUtil.join;
|
import static com.intellij.openapi.util.text.StringUtil.join;
|
||||||
import static org.jetbrains.kotlin.maven.Util.filterClassPath;
|
import static org.jetbrains.kotlin.maven.Util.filterClassPath;
|
||||||
@@ -64,22 +68,22 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
|||||||
@Parameter(defaultValue = "${project.artifactId}-test", required = true, readonly = true)
|
@Parameter(defaultValue = "${project.artifactId}-test", required = true, readonly = true)
|
||||||
protected String testModuleName;
|
protected String testModuleName;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.jvmTarget", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.jvmTarget")
|
||||||
protected String jvmTarget;
|
protected String jvmTarget;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.jdkHome", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.jdkHome")
|
||||||
protected String jdkHome;
|
protected String jdkHome;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.scriptTemplates", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.scriptTemplates")
|
||||||
protected List<String> scriptTemplates;
|
protected List<String> scriptTemplates;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.incremental", defaultValue = "false", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.incremental", defaultValue = "false")
|
||||||
private boolean myIncremental;
|
private boolean myIncremental;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.incremental.cache.root", defaultValue = "${project.build.directory}/kotlin-ic", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.incremental.cache.root", defaultValue = "${project.build.directory}/kotlin-ic")
|
||||||
public String incrementalCachesRoot;
|
public String incrementalCachesRoot;
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.javaParameters", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.javaParameters")
|
||||||
protected boolean javaParameters;
|
protected boolean javaParameters;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -119,7 +123,7 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
|||||||
|
|
||||||
File sourcesDir = AnnotationProcessingManager.getGeneratedSourcesDirectory(project, getSourceSetName());
|
File sourcesDir = AnnotationProcessingManager.getGeneratedSourcesDirectory(project, getSourceSetName());
|
||||||
if (sourcesDir.isDirectory()) {
|
if (sourcesDir.isDirectory()) {
|
||||||
paths = new ArrayList<String>(paths);
|
paths = new ArrayList<>(paths);
|
||||||
paths.add(sourcesDir.getAbsolutePath());
|
paths.add(sourcesDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,13 +188,14 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
|||||||
if (toolsJar != null) {
|
if (toolsJar != null) {
|
||||||
project.getClassRealm().addURL(toolsJar);
|
project.getClassRealm().addURL(toolsJar);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.execute();
|
super.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NotNull
|
||||||
protected ExitCode execCompiler(
|
protected ExitCode execCompiler(
|
||||||
CLICompiler<K2JVMCompilerArguments> compiler,
|
CLICompiler<K2JVMCompilerArguments> compiler,
|
||||||
MessageCollector messageCollector,
|
MessageCollector messageCollector,
|
||||||
|
|||||||
+16
-9
@@ -1,22 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import org.apache.maven.plugin.compiler.CompilationFailureException;
|
import org.apache.maven.plugin.compiler.CompilationFailureException;
|
||||||
import org.codehaus.plexus.compiler.CompilerMessage;
|
import org.codehaus.plexus.compiler.CompilerMessage;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class KotlinCompilationFailureException extends CompilationFailureException {
|
public class KotlinCompilationFailureException extends CompilationFailureException {
|
||||||
private List<CompilerMessage> compilerMessages;
|
|
||||||
|
|
||||||
public KotlinCompilationFailureException(@NotNull List<CompilerMessage> compilerMessages) {
|
public KotlinCompilationFailureException(@NotNull List<CompilerMessage> compilerMessages) {
|
||||||
super(compilerMessages);
|
super(compilerMessages);
|
||||||
this.compilerMessages = Collections.unmodifiableList(compilerMessages);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CompilerMessage> getCompilerMessages() {
|
|
||||||
return compilerMessages;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-41
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,14 +20,16 @@ import com.google.common.base.Joiner;
|
|||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
import com.intellij.util.Processor;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginExecution;
|
import org.apache.maven.model.PluginExecution;
|
||||||
import org.apache.maven.plugin.*;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.MojoExecution;
|
||||||
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugins.annotations.Component;
|
import org.apache.maven.plugins.annotations.Component;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
@@ -80,18 +82,15 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
@Parameter
|
@Parameter
|
||||||
private boolean multiPlatform = false;
|
private boolean multiPlatform = false;
|
||||||
|
|
||||||
private List<String> getAppliedCompilerPlugins() {
|
|
||||||
return (compilerPlugins == null) ? Collections.<String>emptyList() : compilerPlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<String> getSourceFilePaths() {
|
protected List<String> getSourceFilePaths() {
|
||||||
if (sourceDirs != null && !sourceDirs.isEmpty()) return sourceDirs;
|
if (sourceDirs != null && !sourceDirs.isEmpty()) return sourceDirs;
|
||||||
return project.getCompileSourceRoots();
|
return project.getCompileSourceRoots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private List<File> getSourceDirs() {
|
private List<File> getSourceDirs() {
|
||||||
List<String> sources = getSourceFilePaths();
|
List<String> sources = getSourceFilePaths();
|
||||||
List<File> result = new ArrayList<File>(sources.size());
|
List<File> result = new ArrayList<>(sources.size());
|
||||||
|
|
||||||
for (String source : sources) {
|
for (String source : sources) {
|
||||||
addSourceRoots(result, source);
|
addSourceRoots(result, source);
|
||||||
@@ -168,17 +167,17 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
public String testModule;
|
public String testModule;
|
||||||
|
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.languageVersion", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.languageVersion")
|
||||||
protected String languageVersion;
|
protected String languageVersion;
|
||||||
|
|
||||||
|
|
||||||
@Parameter(property = "kotlin.compiler.apiVersion", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.apiVersion")
|
||||||
protected String apiVersion;
|
protected String apiVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* possible values are: enable, error, warn
|
* possible values are: enable, error, warn
|
||||||
*/
|
*/
|
||||||
@Parameter(property = "kotlin.compiler.experimental.coroutines", required = false, readonly = false)
|
@Parameter(property = "kotlin.compiler.experimental.coroutines")
|
||||||
@Nullable
|
@Nullable
|
||||||
protected String experimentalCoroutines;
|
protected String experimentalCoroutines;
|
||||||
|
|
||||||
@@ -237,17 +236,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasKotlinFilesInSources() throws MojoExecutionException {
|
private boolean hasKotlinFilesInSources() throws MojoExecutionException {
|
||||||
List<File> sources = getSourceDirs();
|
for (File root : getSourceDirs()) {
|
||||||
if (sources == null || sources.isEmpty()) return false;
|
|
||||||
|
|
||||||
for (File root : sources) {
|
|
||||||
if (root.exists()) {
|
if (root.exists()) {
|
||||||
boolean sourcesExists = !FileUtil.processFilesRecursively(root, new Processor<File>() {
|
boolean sourcesExists = !FileUtil.processFilesRecursively(root, file -> !file.getName().endsWith(".kt"));
|
||||||
@Override
|
|
||||||
public boolean process(File file) {
|
|
||||||
return !file.getName().endsWith(".kt");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (sourcesExists) return true;
|
if (sourcesExists) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,9 +284,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
protected abstract void configureSpecificCompilerArguments(@NotNull A arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException;
|
protected abstract void configureSpecificCompilerArguments(@NotNull A arguments, @NotNull List<File> sourceRoots) throws MojoExecutionException;
|
||||||
|
|
||||||
private List<String> getCompilerPluginClassPaths() {
|
private List<String> getCompilerPluginClassPaths() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
|
||||||
List<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<>();
|
||||||
|
|
||||||
for (Dependency dependency : mojoExecution.getPlugin().getDependencies()) {
|
for (Dependency dependency : mojoExecution.getPlugin().getDependencies()) {
|
||||||
Artifact artifact = system.createDependencyArtifact(dependency);
|
Artifact artifact = system.createDependencyArtifact(dependency);
|
||||||
@@ -319,14 +310,15 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Map<String, KotlinMavenPluginExtension> loadCompilerPlugins() throws PluginNotFoundException {
|
private Map<String, KotlinMavenPluginExtension> loadCompilerPlugins() throws PluginNotFoundException {
|
||||||
Map<String, KotlinMavenPluginExtension> loadedPlugins = new HashMap<String, KotlinMavenPluginExtension>();
|
if (compilerPlugins == null) return Collections.emptyMap();
|
||||||
for (String pluginName : getAppliedCompilerPlugins()) {
|
|
||||||
|
Map<String, KotlinMavenPluginExtension> loadedPlugins = new HashMap<>();
|
||||||
|
for (String pluginName : compilerPlugins) {
|
||||||
getLog().debug("Looking for plugin " + pluginName);
|
getLog().debug("Looking for plugin " + pluginName);
|
||||||
try {
|
try {
|
||||||
KotlinMavenPluginExtension extension = container.lookup(KotlinMavenPluginExtension.class, pluginName);
|
KotlinMavenPluginExtension extension = container.lookup(KotlinMavenPluginExtension.class, pluginName);
|
||||||
loadedPlugins.put(pluginName, extension);
|
loadedPlugins.put(pluginName, extension);
|
||||||
getLog().debug("Got plugin instance" + pluginName + " of type " + extension.getClass().getName());
|
getLog().debug("Got plugin instance" + pluginName + " of type " + extension.getClass().getName());
|
||||||
|
|
||||||
} catch (ComponentLookupException e) {
|
} catch (ComponentLookupException e) {
|
||||||
getLog().debug("Unable to get plugin instance" + pluginName);
|
getLog().debug("Unable to get plugin instance" + pluginName);
|
||||||
throw new PluginNotFoundException(pluginName, e);
|
throw new PluginNotFoundException(pluginName, e);
|
||||||
@@ -337,7 +329,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<String> renderCompilerPluginOptions(@NotNull List<PluginOption> options) {
|
private List<String> renderCompilerPluginOptions(@NotNull List<PluginOption> options) {
|
||||||
List<String> renderedOptions = new ArrayList<String>(options.size());
|
List<String> renderedOptions = new ArrayList<>(options.size());
|
||||||
for (PluginOption option : options) {
|
for (PluginOption option : options) {
|
||||||
renderedOptions.add(option.toString());
|
renderedOptions.add(option.toString());
|
||||||
}
|
}
|
||||||
@@ -350,7 +342,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
throw new IllegalStateException("No mojoExecution injected");
|
throw new IllegalStateException("No mojoExecution injected");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PluginOption> pluginOptions = new ArrayList<PluginOption>();
|
List<PluginOption> pluginOptions = new ArrayList<>();
|
||||||
|
|
||||||
Map<String, KotlinMavenPluginExtension> plugins = loadCompilerPlugins();
|
Map<String, KotlinMavenPluginExtension> plugins = loadCompilerPlugins();
|
||||||
|
|
||||||
@@ -374,15 +366,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
pluginOptions.addAll(parseUserProvidedPluginOptions(this.pluginOptions, plugins));
|
pluginOptions.addAll(parseUserProvidedPluginOptions(this.pluginOptions, plugins));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, List<PluginOption>> optionsByPluginName = new LinkedHashMap<String, List<PluginOption>>();
|
Map<String, List<PluginOption>> optionsByPluginName = new LinkedHashMap<>();
|
||||||
for (PluginOption option : pluginOptions) {
|
for (PluginOption option : pluginOptions) {
|
||||||
List<PluginOption> optionsForPlugin = optionsByPluginName.get(option.pluginName);
|
optionsByPluginName.computeIfAbsent(option.pluginName, key -> new ArrayList<>()).add(option);
|
||||||
if (optionsForPlugin == null) {
|
|
||||||
optionsForPlugin = new ArrayList<PluginOption>();
|
|
||||||
optionsByPluginName.put(option.pluginName, optionsForPlugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
optionsForPlugin.add(option);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<String, List<PluginOption>> entry : optionsByPluginName.entrySet()) {
|
for (Map.Entry<String, List<PluginOption>> entry : optionsByPluginName.entrySet()) {
|
||||||
@@ -410,7 +396,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
@NotNull List<String> rawOptions,
|
@NotNull List<String> rawOptions,
|
||||||
@NotNull Map<String, KotlinMavenPluginExtension> plugins
|
@NotNull Map<String, KotlinMavenPluginExtension> plugins
|
||||||
) throws PluginOptionIllegalFormatException, PluginNotFoundException {
|
) throws PluginOptionIllegalFormatException, PluginNotFoundException {
|
||||||
List<PluginOption> pluginOptions = new ArrayList<PluginOption>(rawOptions.size());
|
List<PluginOption> pluginOptions = new ArrayList<>(rawOptions.size());
|
||||||
|
|
||||||
for (String rawOption : rawOptions) {
|
for (String rawOption : rawOptions) {
|
||||||
Matcher matcher = OPTION_PATTERN.matcher(rawOption);
|
Matcher matcher = OPTION_PATTERN.matcher(rawOption);
|
||||||
@@ -434,7 +420,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<File> getSourceRoots() throws MojoExecutionException {
|
private List<File> getSourceRoots() throws MojoExecutionException {
|
||||||
List<File> sourceRoots = new ArrayList<File>();
|
List<File> sourceRoots = new ArrayList<>();
|
||||||
for (File sourceDir : getSourceDirs()) {
|
for (File sourceDir : getSourceDirs()) {
|
||||||
if (sourceDir.exists()) {
|
if (sourceDir.exists()) {
|
||||||
sourceRoots.add(sourceDir);
|
sourceRoots.add(sourceDir);
|
||||||
@@ -489,9 +475,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
|||||||
List<String> pluginArguments;
|
List<String> pluginArguments;
|
||||||
try {
|
try {
|
||||||
pluginArguments = renderCompilerPluginOptions(getCompilerPluginOptions());
|
pluginArguments = renderCompilerPluginOptions(getCompilerPluginOptions());
|
||||||
} catch (PluginNotFoundException e) {
|
} catch (PluginNotFoundException | PluginOptionIllegalFormatException e) {
|
||||||
throw new MojoExecutionException(e.getMessage(), e);
|
|
||||||
} catch (PluginOptionIllegalFormatException e) {
|
|
||||||
throw new MojoExecutionException(e.getMessage(), e);
|
throw new MojoExecutionException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecution;
|
import org.apache.maven.plugin.MojoExecution;
|
||||||
|
|||||||
+3
-8
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,20 +26,15 @@ import org.apache.maven.project.MavenProject;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
||||||
import org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager;
|
import org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager;
|
||||||
import org.jetbrains.kotlin.maven.kapt.KaptTestJvmCompilerMojo;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// Note!
|
||||||
|
// Please change {@link KaptTestJvmCompilerMojo} because it was mostly copied from this file.
|
||||||
/**
|
/**
|
||||||
* Compiles Kotlin test sources
|
* Compiles Kotlin test sources
|
||||||
*
|
|
||||||
* @noinspection UnusedDeclaration
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Note!
|
|
||||||
* Please change {@link KaptTestJvmCompilerMojo} as well as it was majorly copied from this file. */
|
|
||||||
|
|
||||||
@Mojo(name = "test-compile",
|
@Mojo(name = "test-compile",
|
||||||
defaultPhase = LifecyclePhase.TEST_COMPILE,
|
defaultPhase = LifecyclePhase.TEST_COMPILE,
|
||||||
requiresDependencyResolution = ResolutionScope.TEST,
|
requiresDependencyResolution = ResolutionScope.TEST,
|
||||||
|
|||||||
+4
-5
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2013 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -29,12 +29,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts Kotlin to JavaScript code
|
* Converts Kotlin to JavaScript code
|
||||||
*
|
|
||||||
* @noinspection UnusedDeclaration
|
|
||||||
*/
|
*/
|
||||||
@Mojo(name = "test-js",
|
@Mojo(name = "test-js",
|
||||||
defaultPhase = LifecyclePhase.TEST_COMPILE,
|
defaultPhase = LifecyclePhase.TEST_COMPILE,
|
||||||
@@ -74,7 +73,7 @@ public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo {
|
|||||||
private String outputFile;
|
private String outputFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag enables or disables metafile generation
|
* Flag enables or disables .meta.js file generation
|
||||||
*/
|
*/
|
||||||
@Parameter(defaultValue = "true")
|
@Parameter(defaultValue = "true")
|
||||||
private boolean metaInfo;
|
private boolean metaInfo;
|
||||||
|
|||||||
+22
-28
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,8 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import com.intellij.openapi.util.Pair;
|
import com.intellij.openapi.util.Pair;
|
||||||
import kotlin.collections.CollectionsKt;
|
|
||||||
import kotlin.jvm.functions.Function1;
|
|
||||||
import org.apache.maven.plugin.logging.Log;
|
import org.apache.maven.plugin.logging.Log;
|
||||||
import org.codehaus.plexus.compiler.CompilerMessage;
|
import org.codehaus.plexus.compiler.CompilerMessage;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -30,12 +28,13 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class MavenPluginLogMessageCollector implements MessageCollector {
|
public class MavenPluginLogMessageCollector implements MessageCollector {
|
||||||
private final Log log;
|
private final Log log;
|
||||||
private final ArrayList<Pair<CompilerMessageLocation, String>> collectedErrors = new ArrayList<Pair<CompilerMessageLocation, String>>();
|
private final ArrayList<Pair<CompilerMessageLocation, String>> collectedErrors = new ArrayList<>();
|
||||||
|
|
||||||
public MavenPluginLogMessageCollector(Log log) {
|
public MavenPluginLogMessageCollector(Log log) {
|
||||||
this.log = checkNotNull(log, "log shouldn't be null");
|
this.log = checkNotNull(log, "log shouldn't be null");
|
||||||
@@ -65,7 +64,7 @@ public class MavenPluginLogMessageCollector implements MessageCollector {
|
|||||||
switch (severity) {
|
switch (severity) {
|
||||||
case EXCEPTION:
|
case EXCEPTION:
|
||||||
case ERROR: {
|
case ERROR: {
|
||||||
collectedErrors.add(new Pair<CompilerMessageLocation, String>(location, message));
|
collectedErrors.add(new Pair<>(location, message));
|
||||||
log.error(text);
|
log.error(text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -90,31 +89,26 @@ public class MavenPluginLogMessageCollector implements MessageCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void throwKotlinCompilerException() throws KotlinCompilationFailureException {
|
public void throwKotlinCompilerException() throws KotlinCompilationFailureException {
|
||||||
throw new KotlinCompilationFailureException(
|
throw new KotlinCompilationFailureException(getCollectedErrors().stream().map(pair -> {
|
||||||
CollectionsKt.map(getCollectedErrors(), new Function1<Pair<CompilerMessageLocation, String>, CompilerMessage>() {
|
CompilerMessageLocation location = pair.getFirst();
|
||||||
@Override
|
String message = pair.getSecond();
|
||||||
public CompilerMessage invoke(Pair<CompilerMessageLocation, String> pair) {
|
if (location == null) {
|
||||||
CompilerMessageLocation location = pair.getFirst();
|
return new CompilerMessage(null, CompilerMessage.Kind.ERROR, 0, 0, 0, 0, message);
|
||||||
String message = pair.getSecond();
|
}
|
||||||
if (location == null) {
|
|
||||||
return new CompilerMessage(null, CompilerMessage.Kind.ERROR, 0, 0, 0, 0, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
String lineContent = location.getLineContent();
|
String lineContent = location.getLineContent();
|
||||||
int lineContentLength = lineContent == null ? 0 : lineContent.length();
|
int lineContentLength = lineContent == null ? 0 : lineContent.length();
|
||||||
|
|
||||||
return new CompilerMessage(
|
return new CompilerMessage(
|
||||||
location.getPath(),
|
location.getPath(),
|
||||||
CompilerMessage.Kind.ERROR,
|
CompilerMessage.Kind.ERROR,
|
||||||
fixLocation(location.getLine()),
|
fixLocation(location.getLine()),
|
||||||
fixLocation(location.getColumn()),
|
fixLocation(location.getColumn()),
|
||||||
fixLocation(location.getLine()),
|
fixLocation(location.getLine()),
|
||||||
Math.min(fixLocation(location.getColumn()), lineContentLength),
|
Math.min(fixLocation(location.getColumn()), lineContentLength),
|
||||||
message
|
message
|
||||||
);
|
);
|
||||||
}
|
}).collect(Collectors.toList()));
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int fixLocation(int n) {
|
private static int fixLocation(int n) {
|
||||||
|
|||||||
+16
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
|||||||
+16
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
public class PluginOption {
|
public class PluginOption {
|
||||||
|
|||||||
+1
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
|||||||
+16
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
|||||||
+5
-10
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,19 +16,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.maven;
|
package org.jetbrains.kotlin.maven;
|
||||||
|
|
||||||
import kotlin.collections.CollectionsKt;
|
|
||||||
import kotlin.jvm.functions.Function1;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
static List<String> filterClassPath(final File basedir, List<String> classpath) {
|
static List<String> filterClassPath(final File basedir, List<String> classpath) {
|
||||||
return CollectionsKt.filter(classpath, new Function1<String, Boolean>() {
|
return classpath.stream().filter(s ->
|
||||||
@Override
|
new File(s).exists() || new File(basedir, s).exists()
|
||||||
public Boolean invoke(String s) {
|
).collect(Collectors.toList());
|
||||||
return new File(s).exists() || new File(basedir, s).exists();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-1
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven.incremental;
|
package org.jetbrains.kotlin.maven.incremental;
|
||||||
|
|
||||||
import kotlin.jvm.functions.Function0;
|
import kotlin.jvm.functions.Function0;
|
||||||
@@ -77,7 +93,7 @@ public class MavenICReporter implements ICReporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Set<File> compiledKotlinFiles = new HashSet<File>();
|
private final Set<File> compiledKotlinFiles = new HashSet<>();
|
||||||
|
|
||||||
protected boolean isLogEnabled() {
|
protected boolean isLogEnabled() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+26
-11
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven.kapt;
|
package org.jetbrains.kotlin.maven.kapt;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
@@ -68,15 +84,14 @@ public class AnnotationProcessingManager {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
static File getGeneratedClassesDirectory(@NotNull MavenProject project, @NotNull String sourceSetName) {
|
static File getGeneratedClassesDirectory(@NotNull MavenProject project, @NotNull String sourceSetName) {
|
||||||
if (sourceSetName.equals(COMPILE_SOURCE_SET_NAME)) {
|
switch (sourceSetName) {
|
||||||
return new File(project.getModel().getBuild().getOutputDirectory());
|
case COMPILE_SOURCE_SET_NAME:
|
||||||
}
|
return new File(project.getModel().getBuild().getOutputDirectory());
|
||||||
else if (sourceSetName.equals(TEST_SOURCE_SET_NAME)) {
|
case TEST_SOURCE_SET_NAME:
|
||||||
return new File(project.getModel().getBuild().getTestOutputDirectory());
|
return new File(project.getModel().getBuild().getTestOutputDirectory());
|
||||||
}
|
default:
|
||||||
else {
|
throw new IllegalArgumentException("'" + COMPILE_SOURCE_SET_NAME + "' or '" +
|
||||||
throw new IllegalArgumentException("'" + COMPILE_SOURCE_SET_NAME + "' or '" +
|
TEST_SOURCE_SET_NAME + "' expected");
|
||||||
TEST_SOURCE_SET_NAME + "' expected");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +106,7 @@ public class AnnotationProcessingManager {
|
|||||||
aptDependencies = Collections.emptyList();
|
aptDependencies = Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Artifact> requiredArtifacts = new LinkedHashSet<Artifact>();
|
Set<Artifact> requiredArtifacts = new LinkedHashSet<>();
|
||||||
|
|
||||||
requiredArtifacts.add(getArtifact(artifactHandlerManager, KAPT_DEPENDENCY));
|
requiredArtifacts.add(getArtifact(artifactHandlerManager, KAPT_DEPENDENCY));
|
||||||
|
|
||||||
@@ -114,7 +129,7 @@ public class AnnotationProcessingManager {
|
|||||||
throw new IllegalStateException("Annotation processing artifacts were not resolved.");
|
throw new IllegalStateException("Annotation processing artifacts were not resolved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> apClasspath = new ArrayList<String>(resolutionResult.getArtifacts().size());
|
List<String> apClasspath = new ArrayList<>(resolutionResult.getArtifacts().size());
|
||||||
String kaptCompilerPluginArtifact = null;
|
String kaptCompilerPluginArtifact = null;
|
||||||
|
|
||||||
for (Artifact artifact : resolutionResult.getArtifacts()) {
|
for (Artifact artifact : resolutionResult.getArtifacts()) {
|
||||||
|
|||||||
+19
-5
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven.kapt;
|
package org.jetbrains.kotlin.maven.kapt;
|
||||||
|
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
@@ -15,12 +31,10 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.getGeneratedClassesDirectory;
|
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.*;
|
||||||
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.getGeneratedSourcesDirectory;
|
|
||||||
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.getStubsDirectory;
|
|
||||||
|
|
||||||
/** @noinspection UnusedDeclaration */
|
/** @noinspection UnusedDeclaration */
|
||||||
@Mojo(name = "kapt", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = false)
|
@Mojo(name = "kapt", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE)
|
||||||
public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
||||||
@Parameter
|
@Parameter
|
||||||
private String[] annotationProcessors;
|
private String[] annotationProcessors;
|
||||||
@@ -62,7 +76,7 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
|||||||
@NotNull K2JVMCompilerArguments arguments,
|
@NotNull K2JVMCompilerArguments arguments,
|
||||||
@NotNull AnnotationProcessingManager.ResolvedArtifacts resolvedArtifacts
|
@NotNull AnnotationProcessingManager.ResolvedArtifacts resolvedArtifacts
|
||||||
) {
|
) {
|
||||||
List<KaptOption> options = new ArrayList<KaptOption>();
|
List<KaptOption> options = new ArrayList<>();
|
||||||
|
|
||||||
options.add(new KaptOption("aptOnly", true));
|
options.add(new KaptOption("aptOnly", true));
|
||||||
options.add(new KaptOption("useLightAnalysis", useLightAnalysis));
|
options.add(new KaptOption("useLightAnalysis", useLightAnalysis));
|
||||||
|
|||||||
+16
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven.kapt;
|
package org.jetbrains.kotlin.maven.kapt;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|||||||
+17
-1
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 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.kotlin.maven.kapt;
|
package org.jetbrains.kotlin.maven.kapt;
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
@@ -18,7 +34,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @noinspection UnusedDeclaration
|
* @noinspection UnusedDeclaration
|
||||||
*/
|
*/
|
||||||
@Mojo(name = "test-kapt", defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = false)
|
@Mojo(name = "test-kapt", defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.TEST)
|
||||||
public class KaptTestJvmCompilerMojo extends KaptJVMCompilerMojo {
|
public class KaptTestJvmCompilerMojo extends KaptJVMCompilerMojo {
|
||||||
/**
|
/**
|
||||||
* Flag to allow test compilation to be skipped.
|
* Flag to allow test compilation to be skipped.
|
||||||
|
|||||||
Reference in New Issue
Block a user