From 42944b0571af7212c6d4dd776de100e73faff862 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 4 Jun 2009 15:41:25 +0000 Subject: [PATCH] Prepare releasing git-svn-id: https://svn.argeo.org/slc/trunk/maven@2462 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- maven-argeo-osgi-plugin/pom.xml | 2 +- .../osgi/AbstractBundlesPackagerMojo.java | 38 ++++++++++++------- .../maven/plugins/osgi/EquinoxExecMojo.java | 7 +++- .../plugins/osgi/PackageBundlesMojo.java | 13 +++++-- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/maven-argeo-osgi-plugin/pom.xml b/maven-argeo-osgi-plugin/pom.xml index a4a8db4d6..137de4b62 100644 --- a/maven-argeo-osgi-plugin/pom.xml +++ b/maven-argeo-osgi-plugin/pom.xml @@ -7,7 +7,7 @@ .. maven-argeo-osgi-plugin - 0.1.10 + 0.1.11 maven-plugin Argeo OSGi Plugin diff --git a/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java b/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java index 53f686099..ee3cd28a3 100644 --- a/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java +++ b/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java @@ -61,6 +61,15 @@ public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo { */ protected boolean strictManifestVersion; + /** + * Whether the manifest should be updated with the release version. + * + * @parameter expression="${updateManifestWhenReleasing}" + * default-value="true" + * @required + */ + protected boolean updateManifestWhenReleasing; + /** * Whether should fail if symbolic name does not match artifact id. * @@ -146,7 +155,7 @@ public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo { } else { versionMain = project.getVersion(); // buildId = "R_" + sdf.format(new Date());// R for release - buildId = ""; + buildId = "R" + sdf.format(new Date()); } if (!versionMain.equals(versionMfMain)) { @@ -220,20 +229,21 @@ public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo { pom.append("\t" + artifactId + "\n"); pom.append("\t" + packaging + "\n"); return pom; - + // TODO: use the Model object e.g.: (from install plugin) -// Model model = new Model(); -// model.setModelVersion( "4.0.0" ); -// model.setGroupId( groupId ); -// model.setArtifactId( artifactId ); -// model.setVersion( version ); -// model.setPackaging( packaging ); -// model.setDescription( "POM was created from install:install-file" ); -// fw = new FileWriter( tempFile ); -// tempFile.deleteOnExit(); -// new MavenXpp3Writer().write( fw, model ); -// ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, tempFile ); -// artifact.addMetadata( metadata ); + // Model model = new Model(); + // model.setModelVersion( "4.0.0" ); + // model.setGroupId( groupId ); + // model.setArtifactId( artifactId ); + // model.setVersion( version ); + // model.setPackaging( packaging ); + // model.setDescription( "POM was created from install:install-file" ); + // fw = new FileWriter( tempFile ); + // tempFile.deleteOnExit(); + // new MavenXpp3Writer().write( fw, model ); + // ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, + // tempFile ); + // artifact.addMetadata( metadata ); } diff --git a/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/EquinoxExecMojo.java b/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/EquinoxExecMojo.java index d218100ea..ef849a5d6 100644 --- a/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/EquinoxExecMojo.java +++ b/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/EquinoxExecMojo.java @@ -205,13 +205,18 @@ public class EquinoxExecMojo extends AbstractOsgiMojo { List cmdList = new ArrayList(); // System properties - if (!systemProperties.containsKey("osgi.bundles")) + if (!systemProperties.containsKey("osgi.bundles")) { + if (locationsStruct.osgiBootArtifact == null) + throw new Exception("No SLC OSGi boot bundle available."); System.setProperty("osgi.bundles", locationsStruct.osgiBootArtifact .getFile().getCanonicalPath() + "@start"); + } + if (!systemProperties.containsKey("slc.osgi.locations")) System.setProperty("slc.osgi.locations", locationsStruct.osgiLocations); + for (Iterator keys = systemProperties.keySet().iterator(); keys .hasNext();) { Object key = keys.next(); diff --git a/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/PackageBundlesMojo.java b/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/PackageBundlesMojo.java index 46598ead6..80074cb2e 100644 --- a/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/PackageBundlesMojo.java +++ b/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/PackageBundlesMojo.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.jar.Attributes; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.codehaus.plexus.archiver.jar.JarArchiver; @@ -44,12 +45,14 @@ public class PackageBundlesMojo extends AbstractBundlesPackagerMojo { String[] excludes = { "**/.svn", "**/.svn/**" }; fileSet.setIncludes(includes); fileSet.setExcludes(excludes); + + FileOutputStream manifestOut = null; try { File manifestFile = bundlePackage.getManifestFile(); jarArchiver.addFileSet(fileSet); // Write manifest - FileOutputStream out = new FileOutputStream(manifestFile); + manifestOut = new FileOutputStream(manifestFile); System.out.println("\n# BUNDLE " + bundlePackage.getArtifact().getArtifactId()); @@ -61,14 +64,16 @@ public class PackageBundlesMojo extends AbstractBundlesPackagerMojo { System.out.println(key + ": " + value); } - bundlePackage.getManifest().write(out); - out.close(); - jarArchiver.setManifest(manifestFile); + bundlePackage.getManifest().write(manifestOut); + // Write jar + jarArchiver.setManifest(manifestFile); jarArchiver.createArchive(); } catch (Exception e) { throw new MojoExecutionException("Could not package bundle " + bundlePackage.getBundleDir(), e); + }finally{ + IOUtils.closeQuietly(manifestOut); } // Write bundle POM -- 2.39.2