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 260d12c926d..bc567f84a9d 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,7 +18,7 @@ package org.jetbrains.kotlin.maven; import com.intellij.util.ArrayUtil; import kotlin.text.StringsKt; -import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -98,7 +98,12 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase libraries = getKotlinJavascriptLibraryFiles(); + List libraries = null; + try { + libraries = getKotlinJavascriptLibraryFiles(); + } catch (DependencyResolutionRequiredException e) { + throw new MojoExecutionException("Unresolved dependencies", e); + } getLog().debug("libraryFiles: " + libraries); arguments.libraryFiles = ArrayUtil.toStringArray(libraries); @@ -116,33 +121,38 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase getClassPathElements() throws DependencyResolutionRequiredException { + return project.getCompileClasspathElements(); + } + /** * Returns all Kotlin Javascript dependencies that this project has, including transitive ones. * * @return array of paths to kotlin javascript libraries */ @NotNull - private List getKotlinJavascriptLibraryFiles() { + private List getKotlinJavascriptLibraryFiles() throws DependencyResolutionRequiredException { List libraries = new ArrayList(); - for (Artifact artifact : project.getArtifacts()) { - if (artifact.getScope().equals(Artifact.SCOPE_COMPILE)) { - File file = artifact.getFile(); - if (LibraryUtils.isKotlinJavascriptLibrary(file)) { - libraries.add(file.getAbsolutePath()); - } - else { - getLog().warn("artifact " + artifact + " is not a Kotlin Javascript Library"); - } + for (String path : getClassPathElements()) { + File file = new File(path); + + if (file.exists() && LibraryUtils.isKotlinJavascriptLibrary(file)) { + libraries.add(file.getAbsolutePath()); + } + else { + getLog().debug("artifact " + file.getAbsolutePath() + " is not a Kotlin Javascript Library"); } } - for (String file : getOutputDirectoriesCollector()) { - if (new File(file).exists()) { - libraries.add(file); + for (String path : getOutputDirectoriesCollector()) { + File file = new File(path); + + if (file.exists() && LibraryUtils.isKotlinJavascriptLibrary(file)) { + libraries.add(file.getAbsolutePath()); } else { - getLog().warn("JS output directory missing: " + file); + getLog().debug("JS output directory missing: " + file); } } diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java index 178cd17f7e9..ecbfa6991c2 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.maven; +import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -86,6 +87,11 @@ public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo { arguments.metaInfo = metaInfo; } + @Override + protected List getClassPathElements() throws DependencyResolutionRequiredException { + return project.getTestClasspathElements(); + } + @Override protected List getRelatedSourceRoots(MavenProject project) { return project.getTestCompileSourceRoots();