diff --git a/pom.xml b/pom.xml
index 61a2f34..4344213 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,12 @@
provided
+
+ org.apache.maven.plugin-tools
+ maven-plugin-tools-api
+ ${maven-plugin-annotations.version}
+
+
org.sonatype.plexus
plexus-build-api
diff --git a/src/main/java/com/github/bohnman/PackageInfoMojo.java b/src/main/java/com/github/bohnman/PackageInfoMojo.java
index 6fa9b72..2dfdf84 100644
--- a/src/main/java/com/github/bohnman/PackageInfoMojo.java
+++ b/src/main/java/com/github/bohnman/PackageInfoMojo.java
@@ -6,6 +6,7 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.SelectorUtils;
import org.codehaus.plexus.util.StringUtils;
@@ -39,6 +40,9 @@ public class PackageInfoMojo extends AbstractMojo {
private static final String PACKAGE_INFO_JAVA = "package-info.java";
private static final Pattern PACKAGE_STATEMENT_PATTERN = Pattern.compile("^\\s*package\\s[\\S]+?\\s*;$", Pattern.MULTILINE);
+ @Parameter(defaultValue = "${project}")
+ private MavenProject project;
+
@Parameter(defaultValue = "${project.basedir}/src/main/java")
private File sourceDirectory;
@@ -94,6 +98,8 @@ public void execute() throws MojoExecutionException {
try {
getLog().info(format("Generating package-info.java: %s", this));
generate();
+ getLog().info("Adding generated code to project sources");
+ addSourceRoot();
getLog().debug("Done.");
} catch (MojoExecutionException e) {
throw e;
@@ -121,6 +127,10 @@ private void generate() throws MojoExecutionException {
walk(sourceDirectory, outputDirectory, "");
}
+ private void addSourceRoot() {
+ project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
+ }
+
private void validate() throws MojoExecutionException {
getLog().debug("Validating parameters");