net.dongliu.prettypb.maven.ProtocTestCompileMojo Maven / Gradle / Ivy
package net.dongliu.prettypb.maven;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
/**
* @phase generate-test-sources
* @goal testCompile
* @requiresDependencyResolution test
*/
public final class ProtocTestCompileMojo extends AbstractProtocMojo {
/**
* The source directories containing the sources to be compiled.
*
* @parameter default-value="${basedir}/src/test/proto"
* @required
*/
private File protoTestSourceRoot;
/**
* This is the directory into which the {@code .java} will be created.
*
* @parameter default-value="${project.build.directory}/generated-test-sources/protoc"
* @required
*/
private File outputDirectory;
@Override
protected void attachFiles() {
project.addTestCompileSourceRoot(outputDirectory.getAbsolutePath());
projectHelper.addTestResource(project, protoTestSourceRoot.getAbsolutePath(),
Arrays.asList("**/*.proto"), Collections.emptyList());
}
@Override
protected Set getDependencyArtifacts() {
//TODO: get test dependency
return Collections.emptySet();
}
@Override
protected File getOutputDirectory() {
return outputDirectory;
}
@Override
protected File getProtoSourceRoot() {
return protoTestSourceRoot;
}
}