Author: cziegeler
Date: Thu Nov 15 08:04:01 2012
New Revision: 1409683
URL: http://svn.apache.org/viewvc?rev=1409683&view=rev
Log:
SLING-2662 : Enhance run mode handling
Modified:
sling/trunk/maven/maven-launchpad-plugin/pom.xml
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
Modified: sling/trunk/maven/maven-launchpad-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/pom.xml?rev=1409683&r1=1409682&r2=1409683&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/pom.xml (original)
+++ sling/trunk/maven/maven-launchpad-plugin/pom.xml Thu Nov 15 08:04:01 2012
@@ -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>
Modified:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java?rev=1409683&r1=1409682&r2=1409683&view=diff
==============================================================================
---
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
(original)
+++
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
Thu Nov 15 08:04:01 2012
@@ -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.AbstractM
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 AbstractBundleList
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;
+ }
+ });
+ }
+
}
Modified:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java?rev=1409683&r1=1409682&r2=1409683&view=diff
==============================================================================
---
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
(original)
+++
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractUsingBundleListMojo.java
Thu Nov 15 08:04:01 2012
@@ -38,7 +38,6 @@ import org.apache.sling.maven.projectsup
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 AbstractUsingBundl
}
// 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 AbstractUsingBundl
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) {
Modified:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java?rev=1409683&r1=1409682&r2=1409683&view=diff
==============================================================================
---
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
(original)
+++
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java
Thu Nov 15 08:04:01 2012
@@ -142,8 +142,8 @@ public class AttachBundleListMojo extend
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);
Modified:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java?rev=1409683&r1=1409682&r2=1409683&view=diff
==============================================================================
---
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
(original)
+++
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AttachPartialBundleListMojo.java
Thu Nov 15 08:04:01 2012
@@ -178,8 +178,8 @@ public class AttachPartialBundleListMojo
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);
Modified:
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
URL:
http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java?rev=1409683&r1=1409682&r2=1409683&view=diff
==============================================================================
---
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
(original)
+++
sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
Thu Nov 15 08:04:01 2012
@@ -107,6 +107,7 @@ public class PreparePackageMojo extends
*/
private JarArchiver jarArchiver;
+ @Override
public void executeWithArtifacts() throws MojoExecutionException,
MojoFailureException {
copyBaseArtifact();
copyBundles(getInitializedBundleList(), getOutputDirectory());
@@ -116,6 +117,7 @@ public class PreparePackageMojo extends
}
}
+ @Override
protected void initArtifactDefinitions(Properties dependencies) {
if (base == null) {
base = new ArtifactDefinition();
@@ -278,7 +280,7 @@ public class PreparePackageMojo extends
}
private Artifact getBaseDependency() {
- return (Artifact) project.getArtifactMap().get(
+ return project.getArtifactMap().get(
base.getGroupId() + ":" + base.getArtifactId());
}
@@ -303,7 +305,7 @@ public class PreparePackageMojo extends
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);
}