Maven plugin adds source files from project source directory

This commit is contained in:
Alexey Andreev 2015-10-21 22:03:54 +03:00
parent fb3412b4c0
commit f8452e695d
3 changed files with 31 additions and 1 deletions

View File

@ -214,6 +214,11 @@ public abstract class AbstractJavascriptMojo extends AbstractMojo {
lookup.setLocalRepository(localRepository); lookup.setLocalRepository(localRepository);
lookup.setRemoteRepositories(remoteRepositories); lookup.setRemoteRepositories(remoteRepositories);
lookup.setPluginDependencies(pluginArtifacts); lookup.setPluginDependencies(pluginArtifacts);
return lookup.resolve(); List<SourceFileProvider> providers = lookup.resolve();
addSourceProviders(providers);
return providers;
}
protected void addSourceProviders(@SuppressWarnings("unused") List<SourceFileProvider> providers) {
} }
} }

View File

@ -17,6 +17,7 @@ package org.teavm.maven;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase; 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.RuntimeCopyOperation;
import org.teavm.tooling.TeaVMTool; import org.teavm.tooling.TeaVMTool;
import org.teavm.tooling.TeaVMToolException; 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") @Parameter(defaultValue = "${project.build.directory}/javascript")
private File targetDirectory; private File targetDirectory;
@Parameter(defaultValue = "${project.build.sourceDirectory}")
private File sourceDirectory;
@Parameter @Parameter
private String targetFileName = "classes.js"; private String targetFileName = "classes.js";
@ -102,4 +108,9 @@ public class BuildJavascriptMojo extends AbstractJavascriptMojo {
throw new MojoExecutionException("IO error occured", e); throw new MojoExecutionException("IO error occured", e);
} }
} }
@Override
protected void addSourceProviders(List<SourceFileProvider> providers) {
providers.add(new DirectorySourceFileProvider(sourceDirectory));
}
} }

View File

@ -43,6 +43,8 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
import org.teavm.testing.JUnitTestAdapter; import org.teavm.testing.JUnitTestAdapter;
import org.teavm.testing.TestAdapter; import org.teavm.testing.TestAdapter;
import org.teavm.tooling.TeaVMToolException; 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.TeaVMTestTool;
import org.teavm.tooling.testing.TestPlan; import org.teavm.tooling.testing.TestPlan;
@ -60,6 +62,12 @@ public class BuildJavascriptTestMojo extends AbstractJavascriptMojo {
@Parameter(defaultValue = "${project.build.directory}/javascript-test") @Parameter(defaultValue = "${project.build.directory}/javascript-test")
private File targetDirectory; private File targetDirectory;
@Parameter(defaultValue = "${project.build.sourceDirectory}")
private File sourceDirectory;
@Parameter(defaultValue = "${project.build.testSourceDirectory}")
private File testSourceDirectory;
@Parameter(defaultValue = "${project.build.testOutputDirectory}") @Parameter(defaultValue = "${project.build.testOutputDirectory}")
private File testFiles; private File testFiles;
@ -243,4 +251,10 @@ public class BuildJavascriptTestMojo extends AbstractJavascriptMojo {
protected boolean isSupportedScope(String scope) { protected boolean isSupportedScope(String scope) {
return testScopes.contains(scope); return testScopes.contains(scope);
} }
@Override
protected void addSourceProviders(List<SourceFileProvider> providers) {
providers.add(new DirectorySourceFileProvider(sourceDirectory));
providers.add(new DirectorySourceFileProvider(testSourceDirectory));
}
} }