9 Commits
Author SHA1 Message Date
brian.long eff0b43059 Merge branch 'develop' into stable 2021-06-02 14:15:32 -04:00
brian.long 05adb5f119 excluding this project itself 2021-06-02 14:15:10 -04:00
brian.long 85c2fa9d96 v1.0.5 pom 2021-06-02 08:34:28 -04:00
brian.long ad2f0af0a3 Merge branch 'develop' into stable 2021-06-02 08:31:04 -04:00
brian.long b0baa443ca added parent search 2021-06-02 08:30:23 -04:00
brian.long ceef88aa8d added module cache to exclude dependencies of modules 2021-06-02 08:19:46 -04:00
brian.long 7038122a2c v1.0.4 pom 2021-05-19 16:15:01 -04:00
brian.long d0cb229d81 Merge branch 'develop' into stable 2021-05-19 16:14:26 -04:00
brian.long dec44cf623 fixed zip streaming 2021-05-19 16:14:12 -04:00
5 changed files with 61 additions and 11 deletions
+3
View File
@@ -7,3 +7,6 @@ pom.xml.versionsBackup
.project
.classpath
# Visual Studio Code
.factorypath
+2 -2
View File
@@ -8,7 +8,7 @@
<groupId>com.inteligr8.alfresco</groupId>
<artifactId>amp-plugin</artifactId>
<version>1.0.3</version>
<version>1.0.5</version>
<packaging>maven-plugin</packaging>
<name>A Maven plugin to generate AMP files</name>
@@ -91,7 +91,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.1</version>
<configuration>
<goalPrefix>amp</goalPrefix>
</configuration>
@@ -6,7 +6,9 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -27,11 +29,23 @@ public class AmpDependencyFilter implements DependencyFilter {
private final Log log;
private final Charset charset;
private final ArtifactResolutionCallback callback;
private final String projectModuleId;
private Set<String> moduleIds = 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
@@ -39,6 +53,29 @@ public class AmpDependencyFilter implements DependencyFilter {
Artifact artifact = node.getArtifact();
if (this.log.isDebugEnabled())
this.log.debug("Checking dependency: " + artifact.getArtifactId());
String moduleId = this.getModuleId(artifact);
if (this.projectModuleId.equals(moduleId)) {
// always include project itself, even if it is a module
return true;
}
if (this.moduleIds.contains(moduleId)) {
if (this.log.isDebugEnabled())
this.log.debug("Not packaging library; detected as Alfresco Module: " + node.getArtifact().getArtifactId());
return false;
} else if (parents != null) {
for (DependencyNode parent : parents) {
String parentModuleId = this.getModuleId(parent.getArtifact());
if (this.moduleIds.contains(parentModuleId)) {
this.moduleIds.add(moduleId);
if (this.log.isDebugEnabled())
this.log.debug("Not packaging library; detected as dependency to other Alfresco Module: " + node.getArtifact().getArtifactId());
return false;
}
}
}
File file = artifact.getFile();
try {
if (file == null) {
@@ -54,8 +91,9 @@ public class AmpDependencyFilter implements DependencyFilter {
this.log.debug("Checking dependency file: " + file);
if (this.isAlfrescoModule(file)) {
this.moduleIds.add(moduleId);
if (this.log.isInfoEnabled())
this.log.info("Not packaging JAR; detected as Alfresco JAR Module: " + node.getArtifact().getArtifactId());
this.log.info("Not packaging library; detected as Alfresco Module: " + node.getArtifact().getArtifactId());
return false;
}
@@ -1,10 +1,10 @@
package com.inteligr8.alfresco.amp;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -90,10 +90,15 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
@Parameter( property = "skip", required = true, defaultValue = "false" )
protected boolean skip;
@Override
public MavenProject getProject() {
return this.project;
}
public void execute() throws MojoExecutionException {
if (this.skip) {
this.getLog().debug("Skipped AMP packaging");
this.getLog().debug("Skipped AMP package");
return;
}
this.getLog().debug("Executing AMP packaging");
@@ -273,11 +278,12 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
zstream.putNextEntry(new ZipEntry(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 {
IOUtil.copy(freader, zstream);
IOUtil.copy(bistream, zstream);
} finally {
freader.close();
bistream.close();
}
zstream.closeEntry();
@@ -300,13 +306,13 @@ public class AmpMojo extends AbstractMojo implements ArtifactResolutionCallback
zstream.putNextEntry(new ZipEntry(targetPath + file.getName()));
FileInputStream fistream = new FileInputStream(file);
BufferedInputStream bistream = new BufferedInputStream(fistream, this.streamBufferSize);
try {
IOUtil.copy(fistream, zstream);
IOUtil.copy(bistream, zstream);
} finally {
fistream.close();
bistream.close();
}
zstream.flush();
zstream.closeEntry();
}
@@ -1,11 +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;
}