Loading plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/archiver/AmpUnArchiver.java +45 −3 Original line number Diff line number Diff line package org.alfresco.maven.plugin.archiver; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Properties; import org.alfresco.repo.module.tool.ModuleManagementTool; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.ConfigurationContainer; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginConfiguration; import org.apache.maven.plugin.ContextEnabled; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.zip.AbstractZipUnArchiver; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * This class provides AMP unpacking support for projects depending on AMPs * This allows for example AMPs to be specified as <overlay> in the maven-war-plugin Loading @@ -24,14 +34,44 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { @Requirement private LegacySupport legacySupport; private Map pluginContext = new HashMap(); /** * @parameter default-value="${mojoExecution}" * @readonly */ private MojoExecution mojoExecution; @Override /** * By default the AMPs are unpacked in ${project.directory}/${project.build.finalName} */ public File getDestDirectory() { MavenSession session = legacySupport.getSession(); MavenProject project = session.getCurrentProject(); return new File(project.getBuild().getDirectory() + File.separator + project.getBuild().getFinalName()); // By default we use build finalName File location = new File(project.getBuild().getDirectory() + File.separator + project.getBuild().getFinalName()); // If the war plugin configures a custom webappDirectory instead, we pick it up Plugin warPlugin = project.getPlugin("org.apache.maven.plugins:maven-war-plugin"); if(warPlugin != null) { Xpp3Dom warPluginConfig = (Xpp3Dom) warPlugin.getConfiguration(); if(warPluginConfig != null) { Xpp3Dom warConfigElement = warPluginConfig.getChild("webappDirectory"); if(warConfigElement != null) { String webappDir = warConfigElement.getValue(); if(webappDir != null && !webappDir.isEmpty()) { location = new File(webappDir); } } } } return location; } @Override Loading @@ -41,6 +81,7 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { * Invoke the ModuleManagementTool to install AMP modules on the WAR file; * so far, no backup or force flags are enabled */ File destDirectory = getDestDirectory(); ModuleManagementTool mmt = new ModuleManagementTool(); mmt.setVerbose(false); Loading @@ -48,9 +89,9 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { getLogger().info("Installing into destination file: " + getDestFile()); if(getDestDirectory()!= null) getLogger().info("Installing into destination folder: " + getDestDirectory()); getLogger().info("Installing into destination folder: " + destDirectory); File destLocation = (getDestFile() == null || !getDestFile().exists() ) ? getDestDirectory() : getDestFile(); File destLocation = (getDestFile() == null || !getDestFile().exists() ) ? destDirectory : getDestFile(); getLogger().info("Installing " + getSourceFile() + " into " + destLocation); try { Loading @@ -73,4 +114,5 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { } } } Loading
plugins/alfresco-maven-plugin/src/main/java/org/alfresco/maven/plugin/archiver/AmpUnArchiver.java +45 −3 Original line number Diff line number Diff line package org.alfresco.maven.plugin.archiver; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Properties; import org.alfresco.repo.module.tool.ModuleManagementTool; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.ConfigurationContainer; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginConfiguration; import org.apache.maven.plugin.ContextEnabled; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.zip.AbstractZipUnArchiver; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * This class provides AMP unpacking support for projects depending on AMPs * This allows for example AMPs to be specified as <overlay> in the maven-war-plugin Loading @@ -24,14 +34,44 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { @Requirement private LegacySupport legacySupport; private Map pluginContext = new HashMap(); /** * @parameter default-value="${mojoExecution}" * @readonly */ private MojoExecution mojoExecution; @Override /** * By default the AMPs are unpacked in ${project.directory}/${project.build.finalName} */ public File getDestDirectory() { MavenSession session = legacySupport.getSession(); MavenProject project = session.getCurrentProject(); return new File(project.getBuild().getDirectory() + File.separator + project.getBuild().getFinalName()); // By default we use build finalName File location = new File(project.getBuild().getDirectory() + File.separator + project.getBuild().getFinalName()); // If the war plugin configures a custom webappDirectory instead, we pick it up Plugin warPlugin = project.getPlugin("org.apache.maven.plugins:maven-war-plugin"); if(warPlugin != null) { Xpp3Dom warPluginConfig = (Xpp3Dom) warPlugin.getConfiguration(); if(warPluginConfig != null) { Xpp3Dom warConfigElement = warPluginConfig.getChild("webappDirectory"); if(warConfigElement != null) { String webappDir = warConfigElement.getValue(); if(webappDir != null && !webappDir.isEmpty()) { location = new File(webappDir); } } } } return location; } @Override Loading @@ -41,6 +81,7 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { * Invoke the ModuleManagementTool to install AMP modules on the WAR file; * so far, no backup or force flags are enabled */ File destDirectory = getDestDirectory(); ModuleManagementTool mmt = new ModuleManagementTool(); mmt.setVerbose(false); Loading @@ -48,9 +89,9 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { getLogger().info("Installing into destination file: " + getDestFile()); if(getDestDirectory()!= null) getLogger().info("Installing into destination folder: " + getDestDirectory()); getLogger().info("Installing into destination folder: " + destDirectory); File destLocation = (getDestFile() == null || !getDestFile().exists() ) ? getDestDirectory() : getDestFile(); File destLocation = (getDestFile() == null || !getDestFile().exists() ) ? destDirectory : getDestFile(); getLogger().info("Installing " + getSourceFile() + " into " + destLocation); try { Loading @@ -73,4 +114,5 @@ public class AmpUnArchiver extends AbstractZipUnArchiver { } } }