Make kotlin-runtime dependency optional for kotlin script executor for maven, but still add if it's found.

This commit is contained in:
Ilya Gorbunov
2017-01-21 00:22:02 +03:00
parent 070f9d9d17
commit 43003cffbb
@@ -270,21 +270,25 @@ public class ExecuteKotlinScriptMojo extends AbstractMojo {
Artifact stdlibDep = null; Artifact stdlibDep = null;
Artifact runtimeDep = null; Artifact runtimeDep = null;
ArrayList<File> files = new ArrayList<File>(2);
for (Artifact dep: project.getArtifacts()) { for (Artifact dep: project.getArtifacts()) {
if (dep.getArtifactId().equals("kotlin-stdlib")) { if (dep.getArtifactId().equals("kotlin-stdlib")) {
files.add(getArtifactFile(dep));
stdlibDep = dep; stdlibDep = dep;
} }
if (dep.getArtifactId().equals("kotlin-runtime")) { if (dep.getArtifactId().equals("kotlin-runtime")) {
files.add(getArtifactFile(dep));
runtimeDep = dep; runtimeDep = dep;
} }
if (stdlibDep != null && runtimeDep != null) break; if (stdlibDep != null && runtimeDep != null) break;
} }
if (stdlibDep == null || runtimeDep == null) { if (stdlibDep == null) {
throw new MojoExecutionException("Unable to find kotlin-stdlib and kotlin-runtime artifacts among project dependencies"); throw new MojoExecutionException("Unable to find kotlin-stdlib artifacts among project dependencies");
} }
return Arrays.asList(getArtifactFile(stdlibDep), getArtifactFile(runtimeDep)); return files;
} }
private void initCompiler() { private void initCompiler() {