From f8452e695d6b58ce57c1ef7027938782bb29b08f Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 21 Oct 2015 22:03:54 +0300 Subject: [PATCH] Maven plugin adds source files from project source directory --- .../org/teavm/maven/AbstractJavascriptMojo.java | 7 ++++++- .../java/org/teavm/maven/BuildJavascriptMojo.java | 11 +++++++++++ .../org/teavm/maven/BuildJavascriptTestMojo.java | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/maven/plugin/src/main/java/org/teavm/maven/AbstractJavascriptMojo.java b/tools/maven/plugin/src/main/java/org/teavm/maven/AbstractJavascriptMojo.java index cb43846e3..8863821ba 100644 --- a/tools/maven/plugin/src/main/java/org/teavm/maven/AbstractJavascriptMojo.java +++ b/tools/maven/plugin/src/main/java/org/teavm/maven/AbstractJavascriptMojo.java @@ -214,6 +214,11 @@ public abstract class AbstractJavascriptMojo extends AbstractMojo { lookup.setLocalRepository(localRepository); lookup.setRemoteRepositories(remoteRepositories); lookup.setPluginDependencies(pluginArtifacts); - return lookup.resolve(); + List providers = lookup.resolve(); + addSourceProviders(providers); + return providers; + } + + protected void addSourceProviders(@SuppressWarnings("unused") List providers) { } } diff --git a/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java b/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java index 511dd0cb1..dbc1dac6d 100644 --- a/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java +++ b/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptMojo.java @@ -17,6 +17,7 @@ package org.teavm.maven; import java.io.File; import java.util.Arrays; +import java.util.List; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -28,6 +29,8 @@ import org.teavm.tooling.MethodAlias; import org.teavm.tooling.RuntimeCopyOperation; import org.teavm.tooling.TeaVMTool; import org.teavm.tooling.TeaVMToolException; +import org.teavm.tooling.sources.DirectorySourceFileProvider; +import org.teavm.tooling.sources.SourceFileProvider; /** * @@ -40,6 +43,9 @@ public class BuildJavascriptMojo extends AbstractJavascriptMojo { @Parameter(defaultValue = "${project.build.directory}/javascript") private File targetDirectory; + @Parameter(defaultValue = "${project.build.sourceDirectory}") + private File sourceDirectory; + @Parameter private String targetFileName = "classes.js"; @@ -102,4 +108,9 @@ public class BuildJavascriptMojo extends AbstractJavascriptMojo { throw new MojoExecutionException("IO error occured", e); } } + + @Override + protected void addSourceProviders(List providers) { + providers.add(new DirectorySourceFileProvider(sourceDirectory)); + } } diff --git a/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptTestMojo.java b/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptTestMojo.java index 7d41f0ba8..ccc865863 100644 --- a/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptTestMojo.java +++ b/tools/maven/plugin/src/main/java/org/teavm/maven/BuildJavascriptTestMojo.java @@ -43,6 +43,8 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.teavm.testing.JUnitTestAdapter; import org.teavm.testing.TestAdapter; import org.teavm.tooling.TeaVMToolException; +import org.teavm.tooling.sources.DirectorySourceFileProvider; +import org.teavm.tooling.sources.SourceFileProvider; import org.teavm.tooling.testing.TeaVMTestTool; import org.teavm.tooling.testing.TestPlan; @@ -60,6 +62,12 @@ public class BuildJavascriptTestMojo extends AbstractJavascriptMojo { @Parameter(defaultValue = "${project.build.directory}/javascript-test") private File targetDirectory; + @Parameter(defaultValue = "${project.build.sourceDirectory}") + private File sourceDirectory; + + @Parameter(defaultValue = "${project.build.testSourceDirectory}") + private File testSourceDirectory; + @Parameter(defaultValue = "${project.build.testOutputDirectory}") private File testFiles; @@ -243,4 +251,10 @@ public class BuildJavascriptTestMojo extends AbstractJavascriptMojo { protected boolean isSupportedScope(String scope) { return testScopes.contains(scope); } + + @Override + protected void addSourceProviders(List providers) { + providers.add(new DirectorySourceFileProvider(sourceDirectory)); + providers.add(new DirectorySourceFileProvider(testSourceDirectory)); + } }