diff --git a/libraries/tools/kotlin-maven-plugin/pom.xml b/libraries/tools/kotlin-maven-plugin/pom.xml index 62e501277cc..ccf40c08717 100644 --- a/libraries/tools/kotlin-maven-plugin/pom.xml +++ b/libraries/tools/kotlin-maven-plugin/pom.xml @@ -7,7 +7,6 @@ 1.4.1 3.0.5 - 1.0.4 @@ -58,16 +57,6 @@ 3.3.0 test - - org.eclipse.aether - aether-impl - 1.1.0 - - - org.apache.maven - maven-artifact - ${maven.version} - 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 e6ec481743a..eab556ee70c 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 @@ -20,6 +20,10 @@ import com.google.common.base.Joiner; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; +import org.apache.maven.artifact.resolver.ArtifactResolutionResult; +import org.apache.maven.model.Dependency; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; @@ -27,6 +31,7 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.jetbrains.annotations.NotNull; @@ -49,6 +54,9 @@ public abstract class KotlinCompileMojoBase e @Component protected MojoExecution mojoExecution; + @Component + protected RepositorySystem system; + /** * The source directories containing the sources to be compiled. */ @@ -230,16 +238,24 @@ public abstract class KotlinCompileMojoBase e result.addAll(compilerPluginsClassPaths); } - // TODO do that once we have compiler running in the separate process -// URL[] urls = mojoExecution.getMojoDescriptor().getRealm().getURLs(); -// for (URL url : urls) { -// if ("file".equals(url.getProtocol())) { -// try { -// result.add(new File(url.toURI()).getAbsolutePath()); -// } catch (URISyntaxException ignore) { -// } -// } -// } + List files = new ArrayList(); + + for (Dependency dependency : mojoExecution.getPlugin().getDependencies()) { + Artifact artifact = system.createDependencyArtifact(dependency); + ArtifactResolutionResult resolved = system.resolve(new ArtifactResolutionRequest().setArtifact(artifact)); + + for (Artifact resolvedArtifact : resolved.getArtifacts()) { + File file = resolvedArtifact.getFile(); + + if (file != null && file.exists()) { + files.add(file); + } + } + } + + for (File file : files) { + result.add(file.getAbsolutePath()); + } return result; }