Specify Phase For Built-Plugin Invocations

To avoid a chicken/egg problem, usages of plugins built with the reactor
must have a supplied phase, otherwise they need to be installed prior to
being used in the build.

Also, support having dependencies that are not installed, but contained
within the reactor.

Change-Id: I13bb817a7f247dc538965a5c6dc9052aca60ed4e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1425
Reviewed-by: Till Westmann <tillw@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-installer/pom.xml b/asterixdb/asterix-installer/pom.xml
index f8cb866..36afffa 100644
--- a/asterixdb/asterix-installer/pom.xml
+++ b/asterixdb/asterix-installer/pom.xml
@@ -46,6 +46,7 @@
         <version>${project.version}</version>
         <executions>
           <execution>
+            <phase>generate-resources</phase>
             <goals>
               <!--<goal>licensedownload</goal>-->
               <goal>generate</goal>
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
index 179d426..191aa6b 100644
--- a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/GenerateFileMojo.java
@@ -56,7 +56,6 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-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.plugins.annotations.ResolutionScope;
@@ -64,8 +63,7 @@
 
 @Mojo(name = "generate",
         requiresProject = true,
-        requiresDependencyResolution = ResolutionScope.TEST,
-        defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
+        requiresDependencyResolution = ResolutionScope.TEST)
 public class GenerateFileMojo extends LicenseMojo {
 
     public static final Pattern FOUNDATION_PATTERN = Pattern.compile("^\\s*This product includes software developed " +
diff --git a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
index debb06f..eab4f10 100644
--- a/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
+++ b/asterixdb/asterix-maven-plugins/license-automation-plugin/src/main/java/org/apache/asterix/license/LicenseMojo.java
@@ -159,8 +159,8 @@
                 licenseUrl = fakeLicenseUrl;
             }
         }
-        File path = new File(localRepository.getBasedir(), localRepository.pathOf(depProject.getArtifact()));
-        addProject(new Project(depProject, depLocation, path), new LicenseSpec(licenseUrl, displayName), true);
+        addProject(new Project(depProject, depLocation, depProject.getArtifact().getFile()),
+                new LicenseSpec(licenseUrl, displayName), true);
     }
 
     protected void addProject(Project project, LicenseSpec spec, boolean additive) {
diff --git a/asterixdb/asterix-server/pom.xml b/asterixdb/asterix-server/pom.xml
index c764752..4009b1e 100644
--- a/asterixdb/asterix-server/pom.xml
+++ b/asterixdb/asterix-server/pom.xml
@@ -47,6 +47,7 @@
         <version>${project.version}</version>
         <executions>
           <execution>
+            <phase>generate-resources</phase>
             <goals>
               <goal>generate</goal>
             </goals>
diff --git a/asterixdb/asterix-yarn/pom.xml b/asterixdb/asterix-yarn/pom.xml
index adb183b..3c484f9 100644
--- a/asterixdb/asterix-yarn/pom.xml
+++ b/asterixdb/asterix-yarn/pom.xml
@@ -91,6 +91,7 @@
         <version>${project.version}</version>
         <executions>
           <execution>
+            <phase>generate-resources</phase>
             <goals>
               <goal>generate</goal>
             </goals>