ops4j/org.ops4j.pax.construct

MANIFEST.MF file is not refreshed (or even recreated after a delete) by the command mvn org.ops4j:maven-pax-plugin:compile [PAXCONSTRUCT-108]

ops4j-issues opened this issue · 9 comments

Charles Moulliard created PAXCONSTRUCT-108

The content of the file MANIFEST.MF is not refreshed (or even recreated after a delete) by the command mvn org.ops4j:maven-pax-plugin:compile


Affects: 1.4
Fixed in: 1.4
Votes: 0, Watches: 0

Stuart McCulloch commented

That's correct - the bundle manifest is created by BND when the bundle is built, which is done in the packaging phase - so you need to at least do "mvn package" to regenerate the manifest. We could perhaps add another goal to re-generate the manifest without building the bundle, but I'd like to understand why such an option would be necessary. Can you explain your use-case?

Charles Moulliard commented

Stuart,
The command mvn package does not work at all.

What I do for the moment is very simple :

  1. create a bundle project: mvn org.ops4j:maven-pax-plugin:create-bundle -Dpackage=demo.service -DbundleGroupId=demo.service -DbundleName=demo.service-bundle -Dversion=0.1

manifest content

Manifest-Version: 1
Bundle-Version: 0.1.0
Bundle-Name: demo.camel-bundle demo.camel
Bundle-ManifestVersion: 2
Bundle-SymbolicName: demo.camel_bundle
Import-Package: org.osgi.framework,org.osgi.util.tracker

  1. Transform it as an eclipse project : mvn org.ops4j:maven-pax-plugin:eclipse

  2. Import it in Eclipse

  3. Modify pom (let say by adding something in <Import-Package>

  4. launch mvn mvn org.ops4j:maven-pax-plugin:compile command

  5. Then I see that the content of the MANIFEST.MF file does not correspond to the one placed in the jar

Manifest-Version: 1.0
Bundle-Version: 0.1
Build-Jdk: 1.6.0_12
Built-By: Charlesm
Tool: Bnd-0.0.255
Bnd-LastModified: 1240326185430
Bundle-Name: demo.camel-bundle demo.camel
Bundle-ManifestVersion: 2
Created-By: Apache Maven Bundle Plugin
Import-Package: demo.service;version="0.1"
Bundle-SymbolicName: demo.camel-bundle

This is why I say that the content of the file is not refreshed.

  1. If I delete the file (accidentally inside Eclipse), then the file is not recreated

Stuart McCulloch commented

OK, here's what I typically do when working with Eclipse:

  1. create a project and add some bundles with the Pax-Construct scripts
    2) at the top-level type "mvn clean install pax:eclipse" from the command-line
    3) import projects into Eclipse as existing Plug-in projects
    4) ... develop / add pom dependencies / etc ...
    5) when I want to refresh the manifests I typically use "mvn clean install pax:eclipse"
    (sometimes I edit them in PDE directly and only use Maven at major milestones)
    6) remember to hit F5 to re-sync the project with the file-system

Note that there's an execution fragment in the top-level pom that's commented
out by default (look for the IDE comment) - if you uncomment this then manifests
will be refreshed on every "mvn package" (note that it's commented out because
not everyone uses Eclipse, and this step can slow down the build)

Otherwise you can use "mvn pax:eclipse" to re-gen the manifest for Eclipse/PDE

(I forgot you were talking about the PDE specific manifest, which has to be in a
specific location and have the correct relative paths - this is a major pain point
about PDE which causes a lot of frustration - very rarely you can also run into
issues on Windows where Eclipse locks the file and you can't update it from
another process...)

FWIW, most of the issues wrt. Eclipse come from the fact that we don't integrate
directly into the IDE (we don't provide an Eclipse plug-in) - if someone can spare
some time to work on this then I'd be happy to advise, but at the moment I don't
have any free time left to do this 🙁

We also have some developers using Pax-Construct with Eclipse, perhaps they
can share some of their experiences and "best-practices"

Charles Moulliard commented

Many thanks for your comment and help 😉

Everything works fine so the ticket can be closed except if you want to keep for eclipse modification

Here is my tutorial updated with Pax maven plugin : http://cwiki.apache.org/confluence/display/CAMEL/tutorial-osgi-camel-part1

Charles Moulliard commented

I have discovered nevertheless an issue. The content of the MANIFEST.MF file created is not the same as the one packaged in the JAR.

META-INF/manifest.mf file

Manifest-Version: 1
Bundle-Version: 0.1.0
Bundle-Name: demo.service-bundle demo.service
Bundle-ManifestVersion: 2
Bundle-SymbolicName: demo.service_bundle
Import-Package: org.osgi.framework,org.osgi.util.tracker

in the jar

Manifest-Version: 1.0
Export-Package: demo.service;version="0.1"
Private-Package: demo.service.impl
Built-By: Charlesm
Tool: Bnd-0.0.255
Bundle-Name: demo.service-bundle demo.service
Created-By: Apache Maven Bundle Plugin
Bundle-Version: 0.1
Build-Jdk: 1.6.0_12
Bnd-LastModified: 1240481907631
Bundle-ManifestVersion: 2
Import-Package: demo.service;version="0.1",org.apache.commons.logging
Bundle-SymbolicName: demo.service-bundle

when the following command is executed :

mvn org.ops4j:maven-pax-plugin:compile org.ops4j:maven-pax-plugin:eclipse install

Stuart McCulloch commented

FYI, the manifest created by the "eclipse" goal is pulled from the bundle, so you must make sure the bundle is at least packaged or installed:

mvn install org.ops4j:maven-pax-plugin:eclipse

Btw, if you use Pax-Construct to create your projects (or you have the pax plugin listed in your build plugins) you can use the shorthand form:

mvn install pax:eclipse

To build the Eclipse manifest automatically on every "mvn install" / "mvn package" you can attach the eclipse goal to the packaging phase:

<plugin>
<groupId>org.ops4j</groupId>
<artifactId>maven-pax-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>ide-support</id>
<goals>
<goal>eclipse</goal>
</goals>
</execution>
</executions>
</plugin>

The projects generated by Pax-Construct have this in the top-level pom (commented out by default)

Charles Moulliard commented

Thanks.

Indeed, using this command works perfectly : mvn install pax:eclipse or mvn clean install pax:eclipse

Question : Is it normal that the content of src/main/resources/META-INF/spring/* is copied to META-INF folder at the root of my project ?

Stuart McCulloch commented

Yes, we copy everything under the bundle's META-INF to the top-level META-INF because then PDE can find it if it needs it.
(this is essential if you want to deploy your bundle project using PDE because basically it runs it using the exploded folder)

basically

"src/main/resources/META-INF/spring/*" (code)

foo.jar "META-INF/spring/*" (mvn package / mvn install)

<project>/META-INF/spring/* (mvn pax:eclipse)

HTH

Stuart McCulloch commented

Closing issue as everything appears to be working as designed, please re-open if this is not the case.