diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/JSSourceJarMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/JSSourceJarMojo.java index 72e52ed9f43..8e2b80df083 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/JSSourceJarMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/JSSourceJarMojo.java @@ -1,6 +1,5 @@ package org.jetbrains.kotlin.maven; -import com.google.common.io.Files; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -65,7 +64,7 @@ public class JSSourceJarMojo extends AbstractMojo { } } if (definitionSourceDir != null) { - if (!librarySourceDir.exists()) { + if (!definitionSourceDir.exists()) { getLog().warn("Definition directory does not exist: " + definitionSourceDir); } else { try { diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java index 5c43b65e711..3b3ed4766fc 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java @@ -18,18 +18,19 @@ package org.jetbrains.kotlin.maven; import com.google.common.io.Files; import com.google.common.io.InputSupplier; +import com.intellij.openapi.util.io.FileUtil; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments; import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments; import org.jetbrains.jet.cli.js.K2JSCompiler; -import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.k2js.config.MetaInfServices; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.nio.charset.Charset; -import java.util.Arrays; import java.util.List; /** @@ -81,7 +82,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); - if (appendLibraryJS != null && appendLibraryJS.booleanValue()) { + if (appendLibraryJS != null && appendLibraryJS) { try { Charset charset = Charset.defaultCharset(); File file = new File(outputFile); @@ -97,7 +98,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojo { throw new MojoExecutionException(e.getMessage(), e); } } - if (copyLibraryJS != null && copyLibraryJS.booleanValue()) { + if (copyLibraryJS != null && copyLibraryJS) { getLog().info("Copying kotlin JS library to " + outputKotlinJSDir); copyJsLibraryFile(KOTLIN_JS_MAPS); @@ -107,7 +108,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojo { } } - protected void appendFile(String jsLib, StringBuilder builder) throws MojoExecutionException { + private static void appendFile(String jsLib, StringBuilder builder) throws MojoExecutionException { // lets copy the kotlin library into the output directory try { final InputStream inputStream = MetaInfServices.loadClasspathResource(jsLib); diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java index 8f294bd4c07..8aefe9303e3 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java @@ -47,8 +47,6 @@ import java.util.zip.ZipFile; import static com.intellij.openapi.util.text.StringUtil.join; public abstract class KotlinCompileMojoBase extends AbstractMojo { - - // TODO it would be nice to avoid using 2 injected fields for sources // but I've not figured out how to have a defaulted parameter value // which is also customisable inside an in a maven pom.xml @@ -182,10 +180,10 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { } } - final CommonCompilerArguments arguments = createCompilerArguments(); + CommonCompilerArguments arguments = createCompilerArguments(); configureCompilerArguments(arguments); - final CLICompiler compiler = createCompiler(); + CLICompiler compiler = createCompiler(); printCompilerArgumentsIfDebugEnabled(arguments, compiler); final Log log = getLog(); @@ -209,14 +207,14 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { } }; - final ExitCode exitCode = executeCompiler(compiler, arguments, messageCollector); + ExitCode exitCode = executeCompiler(compiler, arguments, messageCollector); switch (exitCode) { case COMPILATION_ERROR: throw new MojoExecutionException("Compilation error. See log for more details"); - case INTERNAL_ERROR: throw new MojoExecutionException("Internal compiler error. See log for more details"); + default: } } @@ -280,7 +278,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { // don't include runtime, it should be in maven dependencies arguments.noStdlib = true; - final ArrayList classpathList = new ArrayList(); + ArrayList classpathList = new ArrayList(); if (module != null) { log.info("Compiling Kotlin module " + module); @@ -361,20 +359,20 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { return join(list, File.pathSeparator); } - protected File getJdkAnnotations() { - final ClassLoader classLoader = getClass().getClassLoader(); + @NotNull + private static File getJdkAnnotations() { + ClassLoader classLoader = KotlinCompileMojoBase.class.getClassLoader(); if (!(classLoader instanceof URLClassLoader)) { - throw new RuntimeException("Kotlin plugin`s classloader is not URLClassLoader"); + throw new RuntimeException("Kotlin plugin`s class loader is not URLClassLoader"); } - final URLClassLoader urlClassLoader = (URLClassLoader) classLoader; - for (URL url : urlClassLoader.getURLs()) { - final String path = url.getPath(); + for (URL url : ((URLClassLoader) classLoader).getURLs()) { + String path = url.getPath(); if (StringUtil.isEmpty(path)) { continue; } - final File file = new File(path); + File file = new File(path); if (file.getName().startsWith("kotlin-jdk-annotations")) { return file; } @@ -383,12 +381,12 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { throw new RuntimeException("Could not get jdk annotations from Kotlin plugin`s classpath"); } - protected List scanAnnotations(Log log) { - final List annotations = new ArrayList(); + private List scanAnnotations(Log log) { + List annotations = new ArrayList(); - final Set artifacts = project.getArtifacts(); + Set artifacts = project.getArtifacts(); for (Artifact artifact : artifacts) { - final File file = artifact.getFile(); + File file = artifact.getFile(); if (containsAnnotations(file, log)) { log.info("Discovered kotlin annotations in: " + file); try { @@ -403,14 +401,14 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { return annotations; } - protected boolean containsAnnotations(File file, Log log) { + private static boolean containsAnnotations(File file, Log log) { log.debug("Scanning for kotlin annotations in " + file); ZipFile zipFile = null; try { zipFile = new ZipFile(file); - final Enumeration entries = zipFile.entries(); + Enumeration entries = zipFile.entries(); while (entries.hasMoreElements()) { String name = entries.nextElement().getName(); if (name.endsWith("/annotations.xml")) { diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java index 4abb354be9d..b49d2f28aa0 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java @@ -40,7 +40,6 @@ public class KotlinTestCompileMojo extends KotlinCompileMojoBase { */ private boolean skip; - // TODO it would be nice to avoid using 2 injected fields for sources // but I've not figured out how to have a defaulted parameter value // which is also customisable inside an in a maven pom.xml @@ -76,6 +75,7 @@ public class KotlinTestCompileMojo extends KotlinCompileMojoBase { */ private List defaultSourceDir; + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("Test compilation is skipped");