This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag maven-launchpad-plugin-2.3.4 in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git
commit e032914e752837c3a07283847aa20609d505f9ea Author: Carsten Ziegeler <[email protected]> AuthorDate: Thu Nov 15 08:04:01 2012 +0000 SLING-2662 : Enhance run mode handling git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@1409683 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 5 +++ .../projectsupport/AbstractBundleListMojo.java | 37 ++++++++++++++++++++++ .../AbstractUsingBundleListMojo.java | 19 ++++++----- .../maven/projectsupport/AttachBundleListMojo.java | 4 +-- .../AttachPartialBundleListMojo.java | 4 +-- .../maven/projectsupport/PreparePackageMojo.java | 6 ++-- 6 files changed, 61 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 04a33dd..f0e0ff9 100644 --- a/pom.xml +++ b/pom.xml @@ -148,6 +148,11 @@ <version>1.5.15</version> </dependency> <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId> <version>1.1</version> diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java index eca43fe..a2f5566 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java @@ -17,6 +17,8 @@ package org.apache.sling.maven.projectsupport; import java.io.File; +import java.io.FileFilter; +import java.io.IOException; import java.util.List; import org.apache.maven.artifact.Artifact; @@ -35,6 +37,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; +import org.codehaus.plexus.util.SelectorUtils; import org.codehaus.plexus.util.StringUtils; public abstract class AbstractBundleListMojo extends AbstractMojo { @@ -219,4 +222,38 @@ public abstract class AbstractBundleListMojo extends AbstractMojo { return artifact; } + /** + * Helper method to copy a whole directory + */ + protected void copyDirectory(final File source, final File target, final String[] includes, final String[] excludes) + throws IOException { + final String prefix = source.getAbsolutePath() + File.separatorChar; + final int prefixLength = prefix.length(); + org.apache.commons.io.FileUtils.copyDirectory(source, target, new FileFilter() { + + public boolean accept(final File file) { + final String path = file.getAbsolutePath().substring(prefixLength).replace(File.separatorChar, '/'); + if ( includes != null ) { + boolean matched = false; + for(int i = 0; i<includes.length && !matched; i++) { + if ( SelectorUtils.matchPath(includes[i], path)) { + matched = true; + } + } + if ( !matched ) { + return false; + } + } + if ( excludes != null ) { + for(final String pattern:excludes) { + if ( SelectorUtils.matchPath(pattern, path)) { + return false; + } + } + } + return true; + } + }); + } + } diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java index 5640cba..41e45a4 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java @@ -38,7 +38,6 @@ import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.zip.ZipUnArchiver; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.drools.KnowledgeBase; import org.drools.KnowledgeBaseFactory; @@ -293,8 +292,7 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo } // copy own config files if ( this.overlayConfigDir != null && super.getConfigDirectory().exists() ) { - FileUtils.copyDirectory(super.getConfigDirectory(), this.overlayConfigDir, - null, FileUtils.getDefaultExcludesAsString()); + copyDirectory(super.getConfigDirectory(), this.overlayConfigDir, null, FileUtils.getDefaultExcludes()); } } @@ -337,15 +335,20 @@ public abstract class AbstractUsingBundleListMojo extends AbstractBundleListMojo this.tempConfigDir.mkdirs(); this.overlayConfigDir = this.tempConfigDir; } - String excludes = FileUtils.getDefaultExcludesAsString(); + final String[] defaultExcludes = FileUtils.getDefaultExcludes(); + String[] excludes; if ( this.configExcludes != null ) { - excludes = excludes + ',' + StringUtils.join(this.configExcludes, ","); + excludes = new String[defaultExcludes.length + this.configExcludes.length]; + System.arraycopy(defaultExcludes, 0, excludes, 0, defaultExcludes.length); + System.arraycopy(this.configExcludes, 0, excludes, defaultExcludes.length, this.configExcludes.length); + } else { + excludes = defaultExcludes; } - String includes = null; + String[] includes = null; if ( this.configIncludes != null ) { - includes = StringUtils.join(this.configIncludes, ","); + includes = this.configIncludes; } - FileUtils.copyDirectory(configDir, this.overlayConfigDir, + copyDirectory(configDir, this.overlayConfigDir, includes, excludes); } } catch (final ArchiverException ae) { diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java index 6f40dc0..fe9d538 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java @@ -142,8 +142,8 @@ public class AttachBundleListMojo extends AbstractUsingBundleListMojo { if ( this.checkFile(this.getConfigDirectory()) ) { final File configDir = new File(this.configOutputDir, "config"); configDir.mkdirs(); - FileUtils.copyDirectory(this.getConfigDirectory(), configDir, - null, FileUtils.getDefaultExcludesAsString()); + copyDirectory(this.getConfigDirectory(), configDir, + null, FileUtils.getDefaultExcludes()); } final File destFile = new File(this.configOutputDir.getParent(), this.configOutputDir.getName() + ".zip"); zipArchiver.setDestFile(destFile); diff --git a/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java index f909a35..2f4caf5 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java @@ -178,8 +178,8 @@ public class AttachPartialBundleListMojo extends AbstractBundleListMojo { if ( this.checkFile(this.getConfigDirectory()) ) { final File configDir = new File(this.configOutputDir, "config"); configDir.mkdirs(); - FileUtils.copyDirectory(this.getConfigDirectory(), configDir, - null, FileUtils.getDefaultExcludesAsString()); + copyDirectory(this.getConfigDirectory(), configDir, + null, FileUtils.getDefaultExcludes()); } final File destFile = new File(this.configOutputDir.getParent(), this.configOutputDir.getName() + ".zip"); zipArchiver.setDestFile(destFile); diff --git a/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java index 378857c..5a541cd 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java @@ -107,6 +107,7 @@ public class PreparePackageMojo extends AbstractLaunchpadFrameworkMojo { */ private JarArchiver jarArchiver; + @Override public void executeWithArtifacts() throws MojoExecutionException, MojoFailureException { copyBaseArtifact(); copyBundles(getInitializedBundleList(), getOutputDirectory()); @@ -116,6 +117,7 @@ public class PreparePackageMojo extends AbstractLaunchpadFrameworkMojo { } } + @Override protected void initArtifactDefinitions(Properties dependencies) { if (base == null) { base = new ArtifactDefinition(); @@ -278,7 +280,7 @@ public class PreparePackageMojo extends AbstractLaunchpadFrameworkMojo { } private Artifact getBaseDependency() { - return (Artifact) project.getArtifactMap().get( + return project.getArtifactMap().get( base.getGroupId() + ":" + base.getArtifactId()); } @@ -303,7 +305,7 @@ public class PreparePackageMojo extends AbstractLaunchpadFrameworkMojo { private void copyConfigurationFiles() throws MojoExecutionException { try { - FileUtils.copyDirectory(this.getConfigDirectory(), new File(getOutputDirectory(), CONFIG_PATH_PREFIX), null, FileUtils.getDefaultExcludesAsString()); + copyDirectory(this.getConfigDirectory(), new File(getOutputDirectory(), CONFIG_PATH_PREFIX), null, FileUtils.getDefaultExcludes()); } catch (IOException e) { throw new MojoExecutionException("Unable to copy configuration files", e); } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
