X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=maven%2Fmaven-argeo-osgi-plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fmaven%2Fplugins%2Fosgi%2FAbstractBundlesPackagerMojo.java;fp=maven%2Fmaven-argeo-osgi-plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fmaven%2Fplugins%2Fosgi%2FAbstractBundlesPackagerMojo.java;h=f3b15fe768b618211b21aaba3db547727e582d76;hb=dabf4d12e20271de3b705b91eeda442396305d7d;hp=5fc37a7765549a8bd3ce6cc4d6487c846e4322d2;hpb=bcf9acae2d02e6f4c36f8c6ead3bc895a6675cc1;p=gpl%2Fargeo-slc.git diff --git a/maven/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java b/maven/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java index 5fc37a776..f3b15fe76 100644 --- a/maven/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java +++ b/maven/maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/AbstractBundlesPackagerMojo.java @@ -6,8 +6,11 @@ import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.jar.Attributes; import java.util.jar.Manifest; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; @@ -18,15 +21,6 @@ import org.apache.maven.project.MavenProject; */ public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo { - /** - * The maven project. - * - * @parameter expression="${project}" - * @required - * @readonly - */ - protected MavenProject project; - /** * Directory of the simple bundles * @@ -70,6 +64,14 @@ public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo { File destFile = new File(packagedBundlesDir.getPath() + File.separator + artifactId + ".jar"); try { + String manifestStr = FileUtils.readFileToString(manifestFile); + char lastChar = manifestStr.charAt(manifestStr.length() - 1); + if (lastChar != '\n') + throw new RuntimeException( + "Manifest " + + manifestFile + + " is not valid, it does not end with and endline character."); + Manifest manifest = readManifest(manifestFile); // Symbolic name String symbolicNameMf = manifest.getMainAttributes().getValue( @@ -122,10 +124,13 @@ public abstract class AbstractBundlesPackagerMojo extends AbstractOsgiMojo { manifest.getMainAttributes().putValue("Bundle-Version", newVersionMf); + manifest.getMainAttributes().put( + Attributes.Name.MANIFEST_VERSION, "1.0"); + Artifact artifact = artifactFactory.createBuildArtifact(project .getGroupId(), artifactId, newVersionArt, "jar"); BundlePackage bundlePackage = new BundlePackage(artifact, dir, - manifest, destFile); + new Manifest(manifest), destFile); list.add(bundlePackage); } catch (Exception e) { throw new MojoExecutionException("Could not analyze " + dir, e);