From ad7f30a0de27be3ef34fb4d2d6a493ef687b3e9f Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Thu, 13 Aug 2015 00:36:15 +0200 Subject: [PATCH] One can customize the compilation scope in pom.xml. As such following snipet in pom will include compile & runtime dependencies in the compilation: compile runtime --- .../org/teavm/maven/BuildJavascriptMojo.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java b/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java index 720ea0686..c3027a90a 100644 --- a/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java +++ b/teavm-maven/teavm-maven-plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java @@ -40,12 +40,9 @@ import org.teavm.tooling.*; * * @author Alexey Andreev */ -@Mojo(name = "build-javascript", requiresDependencyResolution = ResolutionScope.COMPILE, - requiresDependencyCollection = ResolutionScope.COMPILE) +@Mojo(name = "build-javascript", requiresDependencyResolution = ResolutionScope.RUNTIME, + requiresDependencyCollection = ResolutionScope.RUNTIME) public class BuildJavascriptMojo extends AbstractMojo { - private static Set compileScopes = new HashSet<>(Arrays.asList( - Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_SYSTEM)); - @Component private MavenProject project; @@ -67,6 +64,9 @@ public class BuildJavascriptMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.outputDirectory}") private File classFiles; + @Parameter + private List compileScopes; + @Parameter private String targetFileName = "classes.js"; @@ -305,8 +305,15 @@ public class BuildJavascriptMojo extends AbstractMojo { log.info("Preparing classpath for JavaScript generation"); List urls = new ArrayList<>(); StringBuilder classpath = new StringBuilder(); + Set scopes; + if (compileScopes == null) { + scopes = new HashSet<>(Arrays.asList( + Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_SYSTEM)); + } else { + scopes = new HashSet<>(compileScopes); + } for (Artifact artifact : project.getArtifacts()) { - if (!compileScopes.contains(artifact.getScope())) { + if (!scopes.contains(artifact.getScope())) { continue; } File file = artifact.getFile();