Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72e7e48e1b | ||
|
|
de21f4fc0d | ||
|
|
aa120eae1b | ||
|
|
c9f56d7187 | ||
|
|
f1f3362f00 | ||
|
|
846e02a439 | ||
|
|
de45b98652 | ||
|
|
52aac1f24b | ||
|
|
6f1e386a63 | ||
|
|
b25646c45e | ||
|
|
141a22941b | ||
|
|
4ba804039d | ||
|
|
41d8067d09 | ||
|
|
f2c4b0b3a7 | ||
|
|
80521c89a1 | ||
|
|
f116e493a2 | ||
|
|
eff0b43059 | ||
|
|
05adb5f119 | ||
|
|
85c2fa9d96 | ||
|
|
ad2f0af0a3 | ||
|
|
b0baa443ca | ||
|
|
ceef88aa8d | ||
|
|
7038122a2c | ||
|
|
d0cb229d81 | ||
|
|
dec44cf623 | ||
|
|
e3626bdbf8 | ||
|
|
85dba196a0 | ||
|
|
8ede035b2a | ||
|
|
9b080710a1 | ||
|
|
0a69deb73a | ||
|
|
80e03c558b | ||
|
|
e7f2c1da67 | ||
|
|
00abdc4340 | ||
|
|
0a3bf69eff | ||
|
|
8e66eaefdf | ||
|
|
aadc05a270 |
@@ -7,3 +7,6 @@ pom.xml.versionsBackup
|
|||||||
.project
|
.project
|
||||||
.classpath
|
.classpath
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
|||||||
@@ -7,18 +7,26 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.inteligr8.alfresco</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>amp-plugin</artifactId>
|
<artifactId>amp-maven-plugin</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.1.0</version>
|
||||||
<packaging>maven-plugin</packaging>
|
<packaging>maven-plugin</packaging>
|
||||||
|
|
||||||
<name>A Maven plugin to generate AMP files</name>
|
<name>A Maven plugin to generate AMP files</name>
|
||||||
<description>Generate Alfresco Module Packages (AMP) files in a way simialr to WAR files</description>
|
<description>Generate Alfresco Module Packages (AMP) files in a way simialr to WAR files</description>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<url>https://bitbucket.org/inteligr8/maven-amp-plugin</url>
|
||||||
|
</scm>
|
||||||
|
<organization>
|
||||||
|
<name>Inteligr8</name>
|
||||||
|
<url>https://www.inteligr8.com</url>
|
||||||
|
</organization>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>brian.long</id>
|
<id>brian.long</id>
|
||||||
<name>Brian Long</name>
|
<name>Brian Long</name>
|
||||||
<email>brian@inteligr8.com</email>
|
<email>brian@inteligr8.com</email>
|
||||||
|
<url>https://twitter.com/brianmlong</url>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
@@ -83,7 +91,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-plugin-plugin</artifactId>
|
<artifactId>maven-plugin-plugin</artifactId>
|
||||||
<version>3.6.0</version>
|
<version>3.6.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<goalPrefix>amp</goalPrefix>
|
<goalPrefix>amp</goalPrefix>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -109,9 +117,8 @@
|
|||||||
<repository>
|
<repository>
|
||||||
<id>inteligr8-releases</id>
|
<id>inteligr8-releases</id>
|
||||||
<name>Inteligr8 Releases</name>
|
<name>Inteligr8 Releases</name>
|
||||||
<url>http://repos.yateslong.us/nexus/repository/inteligr8-public</url>
|
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package com.inteligr8.alfresco.amp;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
import org.apache.maven.plugin.logging.Log;
|
||||||
|
import org.eclipse.aether.artifact.Artifact;
|
||||||
|
import org.eclipse.aether.graph.DependencyFilter;
|
||||||
|
import org.eclipse.aether.graph.DependencyNode;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactRequest;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactResolutionException;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactResult;
|
||||||
|
|
||||||
|
public class AmpDependencyFilter implements DependencyFilter {
|
||||||
|
|
||||||
|
private final Pattern modulePropertiesPattern = Pattern.compile("^alfresco/module/[^/]+/module\\.properties$");
|
||||||
|
private final String moduleExtension = "amp";
|
||||||
|
private final Set<String> ignoreDependenciesOfParentScopes = new HashSet<>(Arrays.asList("provided", "system"));
|
||||||
|
|
||||||
|
private final int streamBufferSize = 16 * 1024;
|
||||||
|
private final Log log;
|
||||||
|
private final Charset charset;
|
||||||
|
private final ArtifactResolutionCallback callback;
|
||||||
|
private final String projectModuleId;
|
||||||
|
|
||||||
|
private Set<String> moduleIds = new HashSet<String>();
|
||||||
|
private Set<String> notModuleIds = new HashSet<String>();
|
||||||
|
|
||||||
|
public AmpDependencyFilter(Log log, String charsetName, ArtifactResolutionCallback callback) {
|
||||||
|
this.log = log;
|
||||||
|
this.charset = Charset.forName(charsetName);
|
||||||
|
this.callback = callback;
|
||||||
|
|
||||||
|
this.projectModuleId = this.getModuleId(this.callback.getProject().getArtifact());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getModuleId(org.apache.maven.artifact.Artifact artifact) {
|
||||||
|
return artifact.getGroupId() + "." + artifact.getArtifactId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getModuleId(Artifact artifact) {
|
||||||
|
return artifact.getGroupId() + "." + artifact.getArtifactId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
|
||||||
|
Artifact artifact = node.getArtifact();
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Checking dependency: " + artifact.getArtifactId());
|
||||||
|
|
||||||
|
String possibleModuleId = this.getModuleId(artifact);
|
||||||
|
if (this.projectModuleId.equals(possibleModuleId)) {
|
||||||
|
// always include project itself, even if it is a module
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (this.isOrIsInAlfrescoModule(possibleModuleId, node, parents.iterator())) {
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Not packaging library; detected as Alfresco Module or as dependency to other Alfresco Module: " + artifact.getArtifactId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (NotInScopeException nise) {
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Not packaging library; detected as provided by another dependency [" + nise.getNotInScopeParentArtifact() + "]: " + artifact.getArtifactId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOrIsInAlfrescoModule(String possibleModuleId, DependencyNode depNode, Iterator<DependencyNode> parents) throws NotInScopeException {
|
||||||
|
Artifact artifact = depNode.getArtifact();
|
||||||
|
|
||||||
|
if (this.projectModuleId.equals(possibleModuleId)) {
|
||||||
|
return false;
|
||||||
|
} else if (depNode.getDependency() != null && this.ignoreDependenciesOfParentScopes.contains(depNode.getDependency().getScope())) {
|
||||||
|
throw new NotInScopeException(artifact);
|
||||||
|
} else if (this.moduleIds.contains(possibleModuleId)) {
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Detected as Alfresco Module: " + artifact.getArtifactId());
|
||||||
|
return true;
|
||||||
|
} else if (this.notModuleIds.contains(possibleModuleId)) {
|
||||||
|
return false;
|
||||||
|
} else if (parents != null && parents.hasNext()) {
|
||||||
|
DependencyNode parentNode = parents.next();
|
||||||
|
String parentModuleId = this.getModuleId(parentNode.getArtifact());
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Checking parent dependency: " + artifact.getArtifactId());
|
||||||
|
|
||||||
|
if (this.isOrIsInAlfrescoModule(parentModuleId, parentNode, parents)) {
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Detected as dependency to other Alfresco Module: " + artifact.getArtifactId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// never seen this artifact or its parents
|
||||||
|
return this.isAlfrescoModule(possibleModuleId, depNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isAlfrescoModule(String possibleModuleId, DependencyNode depNode) {
|
||||||
|
Artifact artifact = depNode.getArtifact();
|
||||||
|
|
||||||
|
if (this.moduleExtension.equalsIgnoreCase(artifact.getExtension())) {
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Detected as Alfresco Module: " + artifact.getArtifactId());
|
||||||
|
this.moduleIds.add(possibleModuleId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = artifact.getFile();
|
||||||
|
try {
|
||||||
|
if (file == null) {
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Resolving dependency to get file: " + artifact.getArtifactId());
|
||||||
|
ArtifactResult result = this.callback.resolveArtifact(new ArtifactRequest(depNode));
|
||||||
|
if (result.isMissing() || !result.isResolved())
|
||||||
|
throw new ArtifactResolutionException(Arrays.asList(result));
|
||||||
|
artifact = result.getArtifact();
|
||||||
|
file = artifact.getFile();
|
||||||
|
}
|
||||||
|
if (this.log.isDebugEnabled())
|
||||||
|
this.log.debug("Checking dependency file: " + file);
|
||||||
|
|
||||||
|
if (this.isAlfrescoModuleJar(file)) {
|
||||||
|
this.moduleIds.add(possibleModuleId);
|
||||||
|
if (this.log.isInfoEnabled())
|
||||||
|
this.log.info("Detected as Alfresco Module: " + artifact.getArtifactId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.notModuleIds.add(possibleModuleId);
|
||||||
|
return false;
|
||||||
|
} catch (ArtifactResolutionException are) {
|
||||||
|
this.log.warn("An artifact could not be resolved; assuming it is not an Alfresco module and continuing");
|
||||||
|
return false;
|
||||||
|
} catch (IOException ie) {
|
||||||
|
this.log.warn("An I/O issue occurred while inspecting a JAR to see if it is an Alfresco module; assuming it isn't and continuing");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlfrescoModuleJar(File file) throws IOException {
|
||||||
|
FileInputStream fistream = new FileInputStream(file);
|
||||||
|
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
|
||||||
|
ZipInputStream zstream = new ZipInputStream(bistream, this.charset);
|
||||||
|
try {
|
||||||
|
ZipEntry zentry = zstream.getNextEntry();
|
||||||
|
while (zentry != null) {
|
||||||
|
try {
|
||||||
|
Matcher modPropsMatcher = this.modulePropertiesPattern.matcher(zentry.getName());
|
||||||
|
if (modPropsMatcher.find())
|
||||||
|
return true;
|
||||||
|
} finally {
|
||||||
|
zstream.closeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
zentry = zstream.getNextEntry();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
zstream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import java.io.BufferedOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -13,10 +12,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -41,6 +37,10 @@ import org.codehaus.plexus.component.annotations.Requirement;
|
|||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.eclipse.aether.graph.Dependency;
|
import org.eclipse.aether.graph.Dependency;
|
||||||
|
import org.eclipse.aether.impl.ArtifactResolver;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactRequest;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactResolutionException;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactResult;
|
||||||
import org.eclipse.aether.util.filter.DependencyFilterUtils;
|
import org.eclipse.aether.util.filter.DependencyFilterUtils;
|
||||||
import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
|
import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
|
||||||
import org.eclipse.aether.util.filter.ScopeDependencyFilter;
|
import org.eclipse.aether.util.filter.ScopeDependencyFilter;
|
||||||
@@ -48,9 +48,8 @@ import org.eclipse.aether.util.filter.ScopeDependencyFilter;
|
|||||||
@Mojo( name = "amp", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
|
@Mojo( name = "amp", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
|
||||||
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME )
|
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME )
|
||||||
@Component( role = org.apache.maven.plugin.Mojo.class )
|
@Component( role = org.apache.maven.plugin.Mojo.class )
|
||||||
public class AmpMojo extends AbstractMojo {
|
public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback {
|
||||||
|
|
||||||
private final Pattern modulePropertiesPattern = Pattern.compile("^alfresco/module/[^/]+/module\\.properties$");
|
|
||||||
private final int streamBufferSize = 16384;
|
private final int streamBufferSize = 16384;
|
||||||
|
|
||||||
@Parameter( defaultValue = "${project}", readonly = true )
|
@Parameter( defaultValue = "${project}", readonly = true )
|
||||||
@@ -62,6 +61,12 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
@Requirement
|
@Requirement
|
||||||
private ProjectDependenciesResolver resolver;
|
private ProjectDependenciesResolver resolver;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private ArtifactResolver artifactResolver;
|
||||||
|
|
||||||
|
@Parameter( property = "classifier", required = false )
|
||||||
|
protected String classifier;
|
||||||
|
|
||||||
@Parameter( property = "outputFile", required = true, defaultValue = "${project.build.directory}/${project.artifactId}-${project.version}.amp" )
|
@Parameter( property = "outputFile", required = true, defaultValue = "${project.build.directory}/${project.artifactId}-${project.version}.amp" )
|
||||||
protected String outputAmpFile;
|
protected String outputAmpFile;
|
||||||
|
|
||||||
@@ -88,14 +93,26 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
|
|
||||||
@Parameter( property = "skip", required = true, defaultValue = "false" )
|
@Parameter( property = "skip", required = true, defaultValue = "false" )
|
||||||
protected boolean skip;
|
protected boolean skip;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MavenProject getProject() {
|
||||||
|
return this.project;
|
||||||
|
}
|
||||||
|
|
||||||
public void execute() throws MojoExecutionException {
|
public void execute() throws MojoExecutionException {
|
||||||
if (this.skip) {
|
if (this.skip) {
|
||||||
this.getLog().debug("Skipped AMP packaging");
|
this.getLog().debug("Skipped AMP package");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.getLog().debug("Executing AMP packaging");
|
this.getLog().debug("Executing AMP packaging");
|
||||||
|
|
||||||
|
this.classifier = StringUtils.trimToNull(this.classifier);
|
||||||
|
if (this.classifier != null) {
|
||||||
|
this.getLog().info("A classifier was specified; injecting classifier into module and output artifact names");
|
||||||
|
this.outputAmpFile = this.injectClassifier(this.outputAmpFile);
|
||||||
|
this.moduleJarFile = this.injectClassifier(this.moduleJarFile);
|
||||||
|
}
|
||||||
|
|
||||||
this.normalize();
|
this.normalize();
|
||||||
|
|
||||||
File ampFile = this.getOutputFile();
|
File ampFile = this.getOutputFile();
|
||||||
@@ -127,6 +144,22 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String injectClassifier(String filename) {
|
||||||
|
int lastDot = filename.lastIndexOf('.');
|
||||||
|
if (lastDot < 0)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
|
int lastDash = filename.lastIndexOf('-', lastDot-1);
|
||||||
|
if (lastDash > 0) {
|
||||||
|
// see if the classifier was already specified
|
||||||
|
String possibleClassifier = filename.substring(lastDash+1, lastDot);
|
||||||
|
if (this.classifier.equals(possibleClassifier))
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename.substring(0, lastDot) + '-' + this.classifier + filename.substring(lastDot);
|
||||||
|
}
|
||||||
|
|
||||||
private void normalize() {
|
private void normalize() {
|
||||||
this.outputAmpFile = StringUtils.trimToNull(this.outputAmpFile);
|
this.outputAmpFile = StringUtils.trimToNull(this.outputAmpFile);
|
||||||
this.moduleJarFile = StringUtils.trimToNull(this.moduleJarFile);
|
this.moduleJarFile = StringUtils.trimToNull(this.moduleJarFile);
|
||||||
@@ -202,13 +235,8 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
} else {
|
} else {
|
||||||
for (Dependency dependency : deps) {
|
for (Dependency dependency : deps) {
|
||||||
File file = dependency.getArtifact().getFile();
|
File file = dependency.getArtifact().getFile();
|
||||||
if (this.isAlfrescoModule(file)) {
|
this.zipFile(zstream, file, "lib");
|
||||||
if (this.getLog().isInfoEnabled())
|
libcount++;
|
||||||
this.getLog().info("Not packaging JAR; detected as Alfresco JAR Module: " + dependency.getArtifact().getArtifactId());
|
|
||||||
} else {
|
|
||||||
this.zipFile(zstream, file, "lib");
|
|
||||||
libcount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getLog().isInfoEnabled())
|
if (this.getLog().isInfoEnabled())
|
||||||
@@ -217,9 +245,9 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
|
|
||||||
for (FileSet fileset : this.libDirectories)
|
for (FileSet fileset : this.libDirectories)
|
||||||
libcount += this.zipFileset(zstream, fileset, "lib");
|
libcount += this.zipFileset(zstream, fileset, "lib");
|
||||||
|
|
||||||
if (libcount == 0)
|
if (libcount == 0)
|
||||||
throw new IllegalStateException("There are no external libraries to include, making an AMP pointless");
|
this.getLog().warn("There are no external libraries to include; an AMP is not recommended");
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getExclusions() {
|
private List<String> getExclusions() {
|
||||||
@@ -234,9 +262,10 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
|
|
||||||
ScopeDependencyFilter scopeFilter = new ScopeDependencyFilter(Arrays.asList(includeScopes), new ArrayList<String>(0));
|
ScopeDependencyFilter scopeFilter = new ScopeDependencyFilter(Arrays.asList(includeScopes), new ArrayList<String>(0));
|
||||||
ExclusionsDependencyFilter exclusionFilter = new ExclusionsDependencyFilter(this.getExclusions());
|
ExclusionsDependencyFilter exclusionFilter = new ExclusionsDependencyFilter(this.getExclusions());
|
||||||
|
AmpDependencyFilter ampFilter = new AmpDependencyFilter(this.getLog(), this.charsetName, this);
|
||||||
|
|
||||||
DependencyResolutionRequest request = new DefaultDependencyResolutionRequest(this.project, this.session.getRepositorySession());
|
DependencyResolutionRequest request = new DefaultDependencyResolutionRequest(this.project, this.session.getRepositorySession());
|
||||||
request.setResolutionFilter(DependencyFilterUtils.andFilter(scopeFilter, exclusionFilter));
|
request.setResolutionFilter(DependencyFilterUtils.andFilter(scopeFilter, exclusionFilter, ampFilter));
|
||||||
|
|
||||||
DependencyResolutionResult result = this.resolver.resolve(request);
|
DependencyResolutionResult result = this.resolver.resolve(request);
|
||||||
return result.getResolvedDependencies();
|
return result.getResolvedDependencies();
|
||||||
@@ -275,11 +304,12 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
zstream.putNextEntry(new ZipEntry(filename));
|
zstream.putNextEntry(new ZipEntry(filename));
|
||||||
|
|
||||||
File file = new File(directory, filename);
|
File file = new File(directory, filename);
|
||||||
FileReader freader = new FileReader(file);
|
FileInputStream fistream = new FileInputStream(file);
|
||||||
|
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
|
||||||
try {
|
try {
|
||||||
IOUtil.copy(freader, zstream);
|
IOUtil.copy(bistream, zstream);
|
||||||
} finally {
|
} finally {
|
||||||
freader.close();
|
bistream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
zstream.closeEntry();
|
zstream.closeEntry();
|
||||||
@@ -301,39 +331,20 @@ public class AmpMojo extends AbstractMojo {
|
|||||||
|
|
||||||
zstream.putNextEntry(new ZipEntry(targetPath + file.getName()));
|
zstream.putNextEntry(new ZipEntry(targetPath + file.getName()));
|
||||||
|
|
||||||
FileReader freader = new FileReader(file);
|
FileInputStream fistream = new FileInputStream(file);
|
||||||
|
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
|
||||||
try {
|
try {
|
||||||
IOUtil.copy(freader, zstream);
|
IOUtil.copy(bistream, zstream);
|
||||||
} finally {
|
} finally {
|
||||||
freader.close();
|
bistream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
zstream.closeEntry();
|
zstream.closeEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAlfrescoModule(File file) throws IOException {
|
@Override
|
||||||
FileInputStream fistream = new FileInputStream(file);
|
public ArtifactResult resolveArtifact(ArtifactRequest artifactRequest) throws ArtifactResolutionException {
|
||||||
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
|
return this.artifactResolver.resolveArtifact(this.session.getRepositorySession(), artifactRequest);
|
||||||
ZipInputStream zstream = new ZipInputStream(bistream, Charset.forName(this.charsetName));
|
|
||||||
try {
|
|
||||||
ZipEntry zentry = zstream.getNextEntry();
|
|
||||||
while (zentry != null) {
|
|
||||||
this.getLog().debug("dep entry: " + zentry.getName());
|
|
||||||
try {
|
|
||||||
Matcher modPropsMatcher = this.modulePropertiesPattern.matcher(zentry.getName());
|
|
||||||
if (modPropsMatcher.find())
|
|
||||||
return true;
|
|
||||||
} finally {
|
|
||||||
zstream.closeEntry();
|
|
||||||
}
|
|
||||||
|
|
||||||
zentry = zstream.getNextEntry();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
zstream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.inteligr8.alfresco.amp;
|
||||||
|
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactRequest;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactResolutionException;
|
||||||
|
import org.eclipse.aether.resolution.ArtifactResult;
|
||||||
|
|
||||||
|
public interface ArtifactResolutionCallback {
|
||||||
|
|
||||||
|
MavenProject getProject();
|
||||||
|
|
||||||
|
ArtifactResult resolveArtifact(ArtifactRequest artifactRequest) throws ArtifactResolutionException;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.inteligr8.alfresco.amp;
|
||||||
|
|
||||||
|
import org.eclipse.aether.artifact.Artifact;
|
||||||
|
|
||||||
|
public class NotInScopeException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 8055701654626788700L;
|
||||||
|
|
||||||
|
private final Artifact notInScopeParentArtifact;
|
||||||
|
private Artifact impactedChildArtifact;
|
||||||
|
|
||||||
|
public NotInScopeException(Artifact notInScopeParentArtifact) {
|
||||||
|
super("The '" + notInScopeParentArtifact.getArtifactId() + "' artifact is not scope");
|
||||||
|
this.notInScopeParentArtifact = notInScopeParentArtifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotInScopeException(Artifact notInScopeParentArtifact, Artifact impactedChildArtifact) {
|
||||||
|
super("The '" + notInScopeParentArtifact.getArtifactId() + "' artifact is not scope, impacting the '" + impactedChildArtifact.getArtifactId() + "' artifact");
|
||||||
|
this.notInScopeParentArtifact = notInScopeParentArtifact;
|
||||||
|
this.impactedChildArtifact = impactedChildArtifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact getNotInScopeParentArtifact() {
|
||||||
|
return this.notInScopeParentArtifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact getImpactedChildArtifact() {
|
||||||
|
return this.impactedChildArtifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user