You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by rsteppac <ra...@vivates.ch> on 2014/07/23 14:23:17 UTC
How to generate bundle jar and feature.xml in same Maven build
I am trying to use the karaf-maven-plugin (v 3.0.1) to dynamically build the
feature.xml required to deploy my bundle in Karaf. The only setup I got to
work is to have a separate maven project that declares the bundle project as
a dependency. Doing so will create a feature.xml that contains my bundle and
all its dependencies.
I was hoping to be able to do away with the additional project by generating
the feature.xml in the bundle project itself and then adding it as a
resource to the installation/deployment phase like so:
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-features-descriptor</id>
<phase>generate-resources</phase>
<goals>
<goal>features-generate-descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/feature/feature.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I bound the "features-generate-descriptor" goal to different phases, but the
resulting feature.xml always only contains the dependencies of my bundle,
but not the bundle itself.
How would I have to configure the plugin to create both artifacts,
feature.xml and bundle jar, in the same project build?
Thanks!
Ralf
--
View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: How to generate bundle jar and feature.xml in same Maven build
Posted by rsteppac <ra...@vivates.ch>.
Stuart, thanks again for the input.
Ralf
On 23.07.2014, at 16:26, Stuart McCulloch [via Karaf] <ml...@n3.nabble.com> wrote:
> In the meantime we’re using this as a workaround:
>
> <!-- src/main/feature/feature.xml -->
> <features>
> <feature name="${project.artifactId}">
> <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
> </feature>
> </features>
>
> along with this plugin execution:
>
> <plugin>
> <groupId>org.apache.karaf.tooling</groupId>
> <artifactId>karaf-maven-plugin</artifactId>
> <executions>
> <execution>
> <id>plugin-feature</id>
> <goals>
> <goal>features-generate-descriptor</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> This generates a feature that includes the bundle’s dependencies - it also merges in the snippet from src/main/feature/feature.xml which adds the bundle itself.
>
> BTW, you don’t need to use the build-helper-maven-plugin to attach the feature because it’s automatically attached by the features-generate-descriptor goal.
>
> On 23 Jul 2014, at 14:07, rsteppac <[hidden email]> wrote:
>
>> Excellent. I have up-voted the ticket.
>>
>> Ralf
>>
>> On 23.07.2014, at 14:45, Stuart McCulloch [via Karaf] <[hidden email]> wrote:
>>
>>> It is possible with the proposed patch in https://issues.apache.org/jira/browse/KARAF-2961(the pull-request includes an example test project)
>>>
>>> Maven supports additional attachments to a project by using classifiers - and since a karaf feature already uses a classifier there's no issue there either with it conflicting with the main artifact.
>>>
>>> --
>>> Cheers, Stuart
>>>
>>> On 23 Jul 2014, at 13:28, Achim Nierbeck <[hidden email]> wrote:
>>>
>>>> Nope, not possible, and not really a solution to long for.
>>>> As your bundle is a maven artifact while the feature file itself is also an artifact.
>>>> In that case it also makes much more sense to have two separate maven modules.
>>>>
>>>> Regards, Achim
>>>>
>>>>
>>>> 2014-07-23 14:23 GMT+02:00 rsteppac <[hidden email]>:
>>>> I am trying to use the karaf-maven-plugin (v 3.0.1) to dynamically build the
>>>> feature.xml required to deploy my bundle in Karaf. The only setup I got to
>>>> work is to have a separate maven project that declares the bundle project as
>>>> a dependency. Doing so will create a feature.xml that contains my bundle and
>>>> all its dependencies.
>>>>
>>>> I was hoping to be able to do away with the additional project by generating
>>>> the feature.xml in the bundle project itself and then adding it as a
>>>> resource to the installation/deployment phase like so:
>>>>
>>>> <build>
>>>> <plugins>
>>>> <plugin>
>>>> <groupId>org.apache.karaf.tooling</groupId>
>>>> <artifactId>karaf-maven-plugin</artifactId>
>>>> <executions>
>>>> <execution>
>>>> <id>generate-features-descriptor</id>
>>>> <phase>generate-resources</phase>
>>>> <goals>
>>>> <goal>features-generate-descriptor</goal>
>>>> </goals>
>>>> </execution>
>>>> </executions>
>>>> </plugin>
>>>> <plugin>
>>>> <groupId>org.codehaus.mojo</groupId>
>>>> <artifactId>build-helper-maven-plugin</artifactId>
>>>> <executions>
>>>> <execution>
>>>> <id>attach-artifacts</id>
>>>> <phase>package</phase>
>>>> <goals>
>>>> <goal>attach-artifact</goal>
>>>> </goals>
>>>> <configuration>
>>>> <artifacts>
>>>> <artifact>
>>>> <file>target/feature/feature.xml</file>
>>>> <type>xml</type>
>>>> <classifier>features</classifier>
>>>> </artifact>
>>>> </artifacts>
>>>> </configuration>
>>>> </execution>
>>>> </executions>
>>>> </plugin>
>>>> </plugins>
>>>> </build>
>>>>
>>>> I bound the "features-generate-descriptor" goal to different phases, but the
>>>> resulting feature.xml always only contains the dependencies of my bundle,
>>>> but not the bundle itself.
>>>> How would I have to configure the plugin to create both artifacts,
>>>> feature.xml and bundle jar, in the same project build?
>>>>
>>>>
>>>> Thanks!
>>>> Ralf
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402.html
>>>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Apache Member
>>>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>>>> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
>>>> blog <http://notizblog.nierbeck.de/>
>>>>
>>>> Software Architect / Project Manager / Scrum Master
>>>>
>>>
>>>
>>> If you reply to this email, your message will be added to the discussion below:
>>> http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034406.html
>>> To unsubscribe from How to generate bundle jar and feature.xml in same Maven build, click here.
>>> NAML
>>
>>
>>
>> smime.p7s (5K) <http://karaf.922171.n3.nabble.com/attachment/4034410/0/smime.p7s>
>>
>>
>>
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034410.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034411.html
> To unsubscribe from How to generate bundle jar and feature.xml in same Maven build, click here.
> NAML
smime.p7s (5K) <http://karaf.922171.n3.nabble.com/attachment/4034420/0/smime.p7s>
--
View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034420.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: How to generate bundle jar and feature.xml in same Maven build
Posted by Stuart McCulloch <mc...@gmail.com>.
In the meantime we’re using this as a workaround:
<!-- src/main/feature/feature.xml -->
<features>
<feature name="${project.artifactId}">
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
</feature>
</features>
along with this plugin execution:
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<id>plugin-feature</id>
<goals>
<goal>features-generate-descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
This generates a feature that includes the bundle’s dependencies - it also merges in the snippet from src/main/feature/feature.xml which adds the bundle itself.
BTW, you don’t need to use the build-helper-maven-plugin to attach the feature because it’s automatically attached by the features-generate-descriptor goal.
On 23 Jul 2014, at 14:07, rsteppac <ra...@vivates.ch> wrote:
> Excellent. I have up-voted the ticket.
>
> Ralf
>
> On 23.07.2014, at 14:45, Stuart McCulloch [via Karaf] <ml...@n3.nabble.com> wrote:
>
>> It is possible with the proposed patch in https://issues.apache.org/jira/browse/KARAF-2961(the pull-request includes an example test project)
>>
>> Maven supports additional attachments to a project by using classifiers - and since a karaf feature already uses a classifier there's no issue there either with it conflicting with the main artifact.
>>
>> --
>> Cheers, Stuart
>>
>> On 23 Jul 2014, at 13:28, Achim Nierbeck <[hidden email]> wrote:
>>
>>> Nope, not possible, and not really a solution to long for.
>>> As your bundle is a maven artifact while the feature file itself is also an artifact.
>>> In that case it also makes much more sense to have two separate maven modules.
>>>
>>> Regards, Achim
>>>
>>>
>>> 2014-07-23 14:23 GMT+02:00 rsteppac <[hidden email]>:
>>> I am trying to use the karaf-maven-plugin (v 3.0.1) to dynamically build the
>>> feature.xml required to deploy my bundle in Karaf. The only setup I got to
>>> work is to have a separate maven project that declares the bundle project as
>>> a dependency. Doing so will create a feature.xml that contains my bundle and
>>> all its dependencies.
>>>
>>> I was hoping to be able to do away with the additional project by generating
>>> the feature.xml in the bundle project itself and then adding it as a
>>> resource to the installation/deployment phase like so:
>>>
>>> <build>
>>> <plugins>
>>> <plugin>
>>> <groupId>org.apache.karaf.tooling</groupId>
>>> <artifactId>karaf-maven-plugin</artifactId>
>>> <executions>
>>> <execution>
>>> <id>generate-features-descriptor</id>
>>> <phase>generate-resources</phase>
>>> <goals>
>>> <goal>features-generate-descriptor</goal>
>>> </goals>
>>> </execution>
>>> </executions>
>>> </plugin>
>>> <plugin>
>>> <groupId>org.codehaus.mojo</groupId>
>>> <artifactId>build-helper-maven-plugin</artifactId>
>>> <executions>
>>> <execution>
>>> <id>attach-artifacts</id>
>>> <phase>package</phase>
>>> <goals>
>>> <goal>attach-artifact</goal>
>>> </goals>
>>> <configuration>
>>> <artifacts>
>>> <artifact>
>>> <file>target/feature/feature.xml</file>
>>> <type>xml</type>
>>> <classifier>features</classifier>
>>> </artifact>
>>> </artifacts>
>>> </configuration>
>>> </execution>
>>> </executions>
>>> </plugin>
>>> </plugins>
>>> </build>
>>>
>>> I bound the "features-generate-descriptor" goal to different phases, but the
>>> resulting feature.xml always only contains the dependencies of my bundle,
>>> but not the bundle itself.
>>> How would I have to configure the plugin to create both artifacts,
>>> feature.xml and bundle jar, in the same project build?
>>>
>>>
>>> Thanks!
>>> Ralf
>>>
>>>
>>>
>>> --
>>> View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402.html
>>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>>
>>>
>>>
>>> --
>>>
>>> Apache Member
>>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>>> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
>>> blog <http://notizblog.nierbeck.de/>
>>>
>>> Software Architect / Project Manager / Scrum Master
>>>
>>
>>
>> If you reply to this email, your message will be added to the discussion below:
>> http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034406.html
>> To unsubscribe from How to generate bundle jar and feature.xml in same Maven build, click here.
>> NAML
>
>
>
> smime.p7s (5K) <http://karaf.922171.n3.nabble.com/attachment/4034410/0/smime.p7s>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034410.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
Re: How to generate bundle jar and feature.xml in same Maven build
Posted by rsteppac <ra...@vivates.ch>.
Excellent. I have up-voted the ticket.
Ralf
On 23.07.2014, at 14:45, Stuart McCulloch [via Karaf] <ml...@n3.nabble.com> wrote:
> It is possible with the proposed patch in https://issues.apache.org/jira/browse/KARAF-2961 (the pull-request includes an example test project)
>
> Maven supports additional attachments to a project by using classifiers - and since a karaf feature already uses a classifier there's no issue there either with it conflicting with the main artifact.
>
> --
> Cheers, Stuart
>
> On 23 Jul 2014, at 13:28, Achim Nierbeck <[hidden email]> wrote:
>
>> Nope, not possible, and not really a solution to long for.
>> As your bundle is a maven artifact while the feature file itself is also an artifact.
>> In that case it also makes much more sense to have two separate maven modules.
>>
>> Regards, Achim
>>
>>
>> 2014-07-23 14:23 GMT+02:00 rsteppac <[hidden email]>:
>> I am trying to use the karaf-maven-plugin (v 3.0.1) to dynamically build the
>> feature.xml required to deploy my bundle in Karaf. The only setup I got to
>> work is to have a separate maven project that declares the bundle project as
>> a dependency. Doing so will create a feature.xml that contains my bundle and
>> all its dependencies.
>>
>> I was hoping to be able to do away with the additional project by generating
>> the feature.xml in the bundle project itself and then adding it as a
>> resource to the installation/deployment phase like so:
>>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>org.apache.karaf.tooling</groupId>
>> <artifactId>karaf-maven-plugin</artifactId>
>> <executions>
>> <execution>
>> <id>generate-features-descriptor</id>
>> <phase>generate-resources</phase>
>> <goals>
>> <goal>features-generate-descriptor</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> <plugin>
>> <groupId>org.codehaus.mojo</groupId>
>> <artifactId>build-helper-maven-plugin</artifactId>
>> <executions>
>> <execution>
>> <id>attach-artifacts</id>
>> <phase>package</phase>
>> <goals>
>> <goal>attach-artifact</goal>
>> </goals>
>> <configuration>
>> <artifacts>
>> <artifact>
>> <file>target/feature/feature.xml</file>
>> <type>xml</type>
>> <classifier>features</classifier>
>> </artifact>
>> </artifacts>
>> </configuration>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>>
>> I bound the "features-generate-descriptor" goal to different phases, but the
>> resulting feature.xml always only contains the dependencies of my bundle,
>> but not the bundle itself.
>> How would I have to configure the plugin to create both artifacts,
>> feature.xml and bundle jar, in the same project build?
>>
>>
>> Thanks!
>> Ralf
>>
>>
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>>
>>
>> --
>>
>> Apache Member
>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
>> blog <http://notizblog.nierbeck.de/>
>>
>> Software Architect / Project Manager / Scrum Master
>>
>
>
> If you reply to this email, your message will be added to the discussion below:
> http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034406.html
> To unsubscribe from How to generate bundle jar and feature.xml in same Maven build, click here.
> NAML
smime.p7s (5K) <http://karaf.922171.n3.nabble.com/attachment/4034410/0/smime.p7s>
--
View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402p4034410.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: How to generate bundle jar and feature.xml in same Maven build
Posted by Stuart McCulloch <mc...@gmail.com>.
It is possible with the proposed patch in https://issues.apache.org/jira/browse/KARAF-2961 (the pull-request includes an example test project)
Maven supports additional attachments to a project by using classifiers - and since a karaf feature already uses a classifier there's no issue there either with it conflicting with the main artifact.
--
Cheers, Stuart
On 23 Jul 2014, at 13:28, Achim Nierbeck <bc...@googlemail.com> wrote:
> Nope, not possible, and not really a solution to long for.
> As your bundle is a maven artifact while the feature file itself is also an artifact.
> In that case it also makes much more sense to have two separate maven modules.
>
> Regards, Achim
>
>
> 2014-07-23 14:23 GMT+02:00 rsteppac <ra...@vivates.ch>:
> I am trying to use the karaf-maven-plugin (v 3.0.1) to dynamically build the
> feature.xml required to deploy my bundle in Karaf. The only setup I got to
> work is to have a separate maven project that declares the bundle project as
> a dependency. Doing so will create a feature.xml that contains my bundle and
> all its dependencies.
>
> I was hoping to be able to do away with the additional project by generating
> the feature.xml in the bundle project itself and then adding it as a
> resource to the installation/deployment phase like so:
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.karaf.tooling</groupId>
> <artifactId>karaf-maven-plugin</artifactId>
> <executions>
> <execution>
> <id>generate-features-descriptor</id>
> <phase>generate-resources</phase>
> <goals>
> <goal>features-generate-descriptor</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>build-helper-maven-plugin</artifactId>
> <executions>
> <execution>
> <id>attach-artifacts</id>
> <phase>package</phase>
> <goals>
> <goal>attach-artifact</goal>
> </goals>
> <configuration>
> <artifacts>
> <artifact>
> <file>target/feature/feature.xml</file>
> <type>xml</type>
> <classifier>features</classifier>
> </artifact>
> </artifacts>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
>
> I bound the "features-generate-descriptor" goal to different phases, but the
> resulting feature.xml always only contains the dependencies of my bundle,
> but not the bundle itself.
> How would I have to configure the plugin to create both artifacts,
> feature.xml and bundle jar, in the same project build?
>
>
> Thanks!
> Ralf
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
>
>
> --
>
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
> blog <http://notizblog.nierbeck.de/>
>
> Software Architect / Project Manager / Scrum Master
>
Re: How to generate bundle jar and feature.xml in same Maven build
Posted by Achim Nierbeck <bc...@googlemail.com>.
Nope, not possible, and not really a solution to long for.
As your bundle is a maven artifact while the feature file itself is also an
artifact.
In that case it also makes much more sense to have two separate maven
modules.
Regards, Achim
2014-07-23 14:23 GMT+02:00 rsteppac <ra...@vivates.ch>:
> I am trying to use the karaf-maven-plugin (v 3.0.1) to dynamically build
> the
> feature.xml required to deploy my bundle in Karaf. The only setup I got to
> work is to have a separate maven project that declares the bundle project
> as
> a dependency. Doing so will create a feature.xml that contains my bundle
> and
> all its dependencies.
>
> I was hoping to be able to do away with the additional project by
> generating
> the feature.xml in the bundle project itself and then adding it as a
> resource to the installation/deployment phase like so:
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.karaf.tooling</groupId>
> <artifactId>karaf-maven-plugin</artifactId>
> <executions>
> <execution>
> <id>generate-features-descriptor</id>
> <phase>generate-resources</phase>
> <goals>
> <goal>features-generate-descriptor</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>build-helper-maven-plugin</artifactId>
> <executions>
> <execution>
> <id>attach-artifacts</id>
> <phase>package</phase>
> <goals>
> <goal>attach-artifact</goal>
> </goals>
> <configuration>
> <artifacts>
> <artifact>
> <file>target/feature/feature.xml</file>
> <type>xml</type>
> <classifier>features</classifier>
> </artifact>
> </artifacts>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
>
> I bound the "features-generate-descriptor" goal to different phases, but
> the
> resulting feature.xml always only contains the dependencies of my bundle,
> but not the bundle itself.
> How would I have to configure the plugin to create both artifacts,
> feature.xml and bundle jar, in the same project build?
>
>
> Thanks!
> Ralf
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/How-to-generate-bundle-jar-and-feature-xml-in-same-Maven-build-tp4034402.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Software Architect / Project Manager / Scrum Master