This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag maven-launchpad-plugin-2.1.2 in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git
commit c3a7120571654dbf48d1fbd5be2d9f18a54ca8cd Author: Carsten Ziegeler <[email protected]> AuthorDate: Wed Nov 30 14:03:21 2011 +0000 SLING-2310 : Attach bundle list goal should also add configuration artifact git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@1208441 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/projectsupport/AttachBundleListMojo.java | 94 +++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) 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 e7d9977..ea21b3a 100644 --- a/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java +++ b/src/main/java/org/apache/sling/maven/projectsupport/AttachBundleListMojo.java @@ -17,12 +17,16 @@ package org.apache.sling.maven.projectsupport; import java.io.File; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.io.xpp3.BundleListXpp3Writer; +import org.codehaus.plexus.archiver.ArchiverException; +import org.codehaus.plexus.archiver.zip.ZipArchiver; +import org.codehaus.plexus.util.FileUtils; /** * Attaches the bundle list as a project artifact. @@ -43,7 +47,19 @@ public class AttachBundleListMojo extends AbstractUsingBundleListMojo { */ private File outputFile; - private BundleListXpp3Writer writer = new BundleListXpp3Writer(); + /** + * @parameter default-value="${project.build.directory}/bundleListconfig" + */ + private File configOutputDir; + + /** + * The zip archiver. + * + * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="zip" + */ + private ZipArchiver zipArchiver; + + private final BundleListXpp3Writer writer = new BundleListXpp3Writer(); @Override protected void executeWithArtifacts() throws MojoExecutionException, MojoFailureException { @@ -62,6 +78,82 @@ public class AttachBundleListMojo extends AbstractUsingBundleListMojo { } } } + this.getLog().info("Attaching bundle list configuration"); + try { + this.attachConfigurations(); + } catch (final IOException ioe) { + throw new MojoExecutionException("Unable to attach configuration.", ioe); + } catch (final ArchiverException ioe) { + throw new MojoExecutionException("Unable to attach configuration.", ioe); + } } + private boolean checkFile(final File f) { + return f != null && f.exists(); + } + + private void attachConfigurations() throws MojoExecutionException, IOException, ArchiverException { + if ( this.ignoreBundleListConfig ) { + this.getLog().debug("ignoreBundleListConfig is set to true, therefore not attaching configurations."); + return; + } + // check if we have configurations + boolean hasConfigs = this.checkFile(this.getConfigDirectory()); + hasConfigs |= this.getSlingBootstrap(true) != null; + hasConfigs |= this.getSlingBootstrap(false) != null; + hasConfigs |= this.getSlingProperties(true) != null; + hasConfigs |= this.getSlingProperties(false) != null; + + if ( !hasConfigs ) { + this.getLog().debug("No configurations to attach."); + return; + } + // copy configuration, as this project might use different names we have to copy everything! + this.configOutputDir.mkdirs(); + if ( this.getSlingBootstrap(false) != null ) { + final File slingDir = new File(this.configOutputDir, "sling"); + slingDir.mkdirs(); + FileUtils.fileWrite(new File(slingDir, AttachPartialBundleListMojo.SLING_WEBAPP_BOOTSTRAP).getAbsolutePath(), + "UTF-8", this.getSlingBootstrap(false)); + } + if ( this.getSlingProperties(false) != null ) { + final File slingDir = new File(this.configOutputDir, "sling"); + slingDir.mkdirs(); + final FileOutputStream fos = new FileOutputStream(new File(slingDir, AttachPartialBundleListMojo.SLING_WEBAPP_PROPS)); + try { + this.getSlingProperties(false).store(fos, null); + } finally { + try { fos.close(); } catch (final IOException ioe) {} + } + } + if ( this.getSlingBootstrap(true) != null ) { + final File slingDir = new File(this.configOutputDir, "sling"); + slingDir.mkdirs(); + FileUtils.fileWrite(new File(slingDir, AttachPartialBundleListMojo.SLING_STANDALONE_BOOTSTRAP).getAbsolutePath(), + "UTF-8", this.getSlingBootstrap(true)); + } + if ( this.getSlingProperties(true) != null ) { + final File slingDir = new File(this.configOutputDir, "sling"); + slingDir.mkdirs(); + final FileOutputStream fos = new FileOutputStream(new File(slingDir, AttachPartialBundleListMojo.SLING_STANDALONE_PROPS)); + try { + this.getSlingProperties(true).store(fos, null); + } finally { + try { fos.close(); } catch (final IOException ioe) {} + } + } + if ( this.checkFile(this.getConfigDirectory()) ) { + final File configDir = new File(this.configOutputDir, "config"); + configDir.mkdirs(); + FileUtils.copyDirectory(this.getConfigDirectory(), configDir, + null, FileUtils.getDefaultExcludesAsString()); + } + final File destFile = new File(this.configOutputDir.getParent(), this.configOutputDir.getName() + ".zip"); + zipArchiver.setDestFile(destFile); + zipArchiver.addDirectory(this.configOutputDir); + zipArchiver.createArchive(); + + projectHelper.attachArtifact(project, AttachPartialBundleListMojo.CONFIG_TYPE, + AttachPartialBundleListMojo.CONFIG_CLASSIFIER, destFile); + } } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
