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.setRemoteRepositories(remoteRepositories);
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.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<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.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<SourceFileProvider> providers) {
providers.add(new DirectorySourceFileProvider(sourceDirectory));
providers.add(new DirectorySourceFileProvider(testSourceDirectory));
}
}