Removed the need for SDK version in RunMojo

This commit is contained in:
Martin Bergljung 2016-08-24 14:18:54 +01:00
parent 30d72ee6bd
commit b88a0ae73b
2 changed files with 40 additions and 18 deletions

View File

@ -140,4 +140,16 @@ public class InstallMojo extends AbstractMojo {
if(!skipWarManifestCheck && warLocation.isDirectory() && !manifest.exists()) if(!skipWarManifestCheck && warLocation.isDirectory() && !manifest.exists())
throw new MojoExecutionException("No MANIFEST.MF found in " + manifest.getAbsolutePath() + ". AMP installation cannot proceed. Are you binding amp:install to the right phase?"); throw new MojoExecutionException("No MANIFEST.MF found in " + manifest.getAbsolutePath() + ". AMP installation cannot proceed. Are you binding amp:install to the right phase?");
} }
public void setWarLocation(File warLocation) {
this.warLocation = warLocation;
}
public void setAmpLocation(File ampLocation) {
this.ampLocation = ampLocation;
}
public void setForce(boolean force) {
this.force = force;
}
} }

View File

@ -24,6 +24,7 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.BuildPluginManager; import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.LifecyclePhase;
@ -57,7 +58,6 @@ public class RunMojo extends AbstractMojo {
public static final String MAVEN_RESOURCE_PLUGIN_VERSION = "2.7"; public static final String MAVEN_RESOURCE_PLUGIN_VERSION = "2.7";
public static final String MAVEN_TOMCAT7_PLUGIN_VERSION = "2.2"; public static final String MAVEN_TOMCAT7_PLUGIN_VERSION = "2.2";
public static final String MAVEN_BUILD_HELPER_PLUGIN_VERSION = "1.12"; public static final String MAVEN_BUILD_HELPER_PLUGIN_VERSION = "1.12";
public static final String MAVEN_ALFRESCO_PLUGIN_VERSION = "3.0.0-SNAPSHOT";
public static final String PLATFORM_WAR_PREFIX_NAME = "platform"; public static final String PLATFORM_WAR_PREFIX_NAME = "platform";
public static final String SHARE_WAR_PREFIX_NAME = "share"; public static final String SHARE_WAR_PREFIX_NAME = "share";
@ -552,7 +552,8 @@ public class RunMojo extends AbstractMojo {
String originalWarArtifactId, String originalWarArtifactId,
String originalWarVersion) throws MojoExecutionException { String originalWarVersion) throws MojoExecutionException {
final String warOutputDir = getWarOutputDir(warName); final String warOutputDir = getWarOutputDir(warName);
final String ampsOutputDir = "${project.build.directory}/modules/" + warName + "/amps"; final String ampsModuleDir = "modules/" + warName + "/amps";
final String ampsOutputDir = "${project.build.directory}/" + ampsModuleDir;
List<Element> ampModules = new ArrayList<>(); List<Element> ampModules = new ArrayList<>();
List<Element> jarModules = new ArrayList<>(); List<Element> jarModules = new ArrayList<>();
@ -631,19 +632,18 @@ public class RunMojo extends AbstractMojo {
); );
// Then apply all these amps to the unpacked war // Then apply all these amps to the unpacked war
executeMojo( // Call the Alfresco Maven Plugin Install Mojo directly, so we don't have to keep SDK version info here
plugin( String ampsLocation = project.getBasedir() + "/target/" + ampsModuleDir;
groupId("org.alfresco.maven.plugin"), String warLocation = project.getBasedir() + "/target/" + getWarName(warName);
artifactId("alfresco-maven-plugin"), InstallMojo installMojo = new InstallMojo();
version(MAVEN_ALFRESCO_PLUGIN_VERSION) installMojo.setAmpLocation(new File(ampsLocation));
), installMojo.setWarLocation(new File(warLocation));
goal("install"), installMojo.setForce(true);
configuration( try {
element(name("ampLocation"), ampsOutputDir), installMojo.execute();
element(name("warLocation"), warOutputDir) } catch (MojoFailureException e) {
), e.printStackTrace();
execEnv }
);
} }
// Then copy all JAR dependencies to the unpacked war /target/<warName>-war/WEB-INF/lib // Then copy all JAR dependencies to the unpacked war /target/<warName>-war/WEB-INF/lib
@ -1094,10 +1094,20 @@ public class RunMojo extends AbstractMojo {
/** /**
* The directory where the custom war will be assembled * The directory where the custom war will be assembled
* *
* @param warName a war prefix, such as 'platform' or 'share' * @param baseWarName a war base name, such as 'platform' or 'share'
* @return a directory such as: .../aio/target/platform-war * @return a directory such as: .../aio/target/platform-war
*/ */
private String getWarOutputDir(String warName) { private String getWarOutputDir(String baseWarName) {
return "${project.build.directory}/" + warName + "-war"; return "${project.build.directory}/" + getWarName(baseWarName);
}
/**
* Get the war filename based on passed in war type
*
* @param baseWarName a war base name, such as 'platform' or 'share'
* @return
*/
private String getWarName(String baseWarName) {
return baseWarName + "-war";
} }
} }