You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Clemens Wilding <cw...@access.uzh.ch> on 2008/11/27 16:18:55 UTC

test jars in lib folder

Hello,

To create a bundle, I use the org.apache.felix maven-bundle-plugin and 
the maven-assembly-plugin. As the bundle depends
on another bundle, I specify with the assembly-plugin to install the 
required bundle in a specified folder. This works fine.

Now if I don't use the maven-bundle-plugin, the generated jar is 
included in the specified folder. But if I use the plugin,
only a test jar is installed in this folder. I don't know if this is a 
desired behaviour or maybe a little bug, so I wrote this mail.

As you might need some information about my configuration, I provide 
some information about the pom.xml and the assembly file dist.xml.

Regards, Clemens

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example.trialox.scb</groupId>
    <artifactId>tutorial1</artifactId>
    <packaging>jar</packaging>
    <version>0.7-SNAPSHOT</version>
    <name>tutorial1</name>
    <dependencies>
        <dependency>
            <groupId>org.trialox</groupId>
            <artifactId>org.trialox.rdf.core</artifactId>
            <version>0.4-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>assembly</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                
<descriptor>src/assembly/dist.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            
<mainClass>org.example.trialox.scb.tutorial1.App</mainClass>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
                        <!-- <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                    </instructions>
                </configuration>
            </plugin> -->
        </plugins>
    </build>
</project>

dist.xml:


<assembly>
    <id>dist</id>
    <formats>
        <format>dir</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>target</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
    </fileSets>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/lib</outputDirectory>
            <unpack>false</unpack>
            <scope>runtime</scope>
        </dependencySet>
    </dependencySets>
</assembly>

-- 

--trialox ag--------------------------------------

 Clemens Wilding
 Binzmühlestrasse 14
 CH-8050 Zürich
 Tel: 0041-44-63 57577
 Fax: 0041-44-63 57574
 URL: http://www.trialox.ch



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: test jars in lib folder

Posted by Stuart McCulloch <mc...@gmail.com>.
2008/12/2 Clemens Wilding <cw...@access.uzh.ch>

> Thank you for your reply, but I was unclear about the issue.
>
> My pom isn't actually creating a bundle but a jar and an assembly. The
> presence of the maven-bundle-plugin in the build/plugins section changes
> what the assembly plugin considers part of the runtime-dependencySet,
> without the plugin this includes the main jar built by the maven-jar-plugin
> with the plugin it includes a jar containing the tests instead of the main
> jar.
>

well that sounds like a bug in Maven, we just use the standard Maven API so
afaik there shouldn't be any side-effects

I come across  this because  we are using a parent-pom for all our projects
> (which are mostly of packaging 'bundle') which includes the
> maven-bundle-plugin.
>

if your parent pom includes the maven-bundle-plugin in <build><plugins> then
your pom will most likely be creating a
bundle (as well as the jar) because build plugins are inherited by default -
if you don't want this to happen then you
should use a different parent that doesn't include the maven-bundle-plugin
(note: in Maven the "parent" pom doesn't
have to be the same as the pom directly above you)

this is what we do over in OPS4J for pax-construct generated projects - each
pom includes the relevant parent pom
depending on what it's doing (ie. wrapping, bundling, etc.) that way we
don't have to worry about inheriting all sorts
of plugins via the pom hierarchy

Regards, Clemens
>
> Stuart McCulloch wrote:
>
>> 2008/11/27 Clemens Wilding <cw...@access.uzh.ch>
>>
>>
>>
>>> Hello,
>>>
>>> To create a bundle, I use the org.apache.felix maven-bundle-plugin and
>>> the
>>> maven-assembly-plugin. As the bundle depends
>>> on another bundle, I specify with the assembly-plugin to install the
>>> required bundle in a specified folder. This works fine.
>>>
>>> Now if I don't use the maven-bundle-plugin, the generated jar is included
>>> in the specified folder. But if I use the plugin,
>>> only a test jar is installed in this folder. I don't know if this is a
>>> desired behaviour or maybe a little bug, so I wrote this mail.
>>>
>>>
>>>
>>
>> this is working as designed...
>>
>> the maven-bundle-plugin is different to the maven-jar-plugin in that it
>> does
>> not simply
>> jar up the contents of "target/classes" - instead it follows a recipe of
>> instructions that
>> define the desired content (ie.
>> Export-Package/Private-Package/Include-Resource)
>>
>>   http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
>>
>> this is because we use the Bnd tool to generate the bundle, and this tool
>> is
>> designed
>> to pull classes and resources from a classpath into one or more bundles,
>> effectively
>> slicing the classpath into different bundles
>>
>> the maven-bundle-plugin will try to map certain Maven conventions into the
>> relevant
>> Bnd instructions (for example src/main/resources -> Include-Resource)
>> automatically
>> and there are instructions that work on Maven dependencies
>> (Embed-Dependency)
>> - but it cannot know in this situation that it needs to include the file
>> unless you tell it
>>
>> so if you want to add dependencies to the bundle you can use
>> Embed-Dependency:
>>
>>   <Embed-Dependency>*;scope=runtime;inline=false</Embed-Dependency>
>>   <Embed-Directory>lib</Embed-Directory>
>>
>> or you can continue with the assembly plugin and use Include-Resource to
>> add
>> them
>> (see http://www.aqute.biz/Code/Bnd#include-resource for more detailed
>> instructions)
>>
>> HTH
>>
>> As you might need some information about my configuration, I provide some
>>
>>
>>> information about the pom.xml and the assembly file dist.xml.
>>>
>>> Regards, Clemens
>>>
>>> pom.xml:
>>>
>>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>>> http://www.w3.org/2001/XMLSchema-instance"
>>>  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>>> http://maven.apache.org/maven-v4_0_0.xsd">
>>>  <modelVersion>4.0.0</modelVersion>
>>>  <groupId>org.example.trialox.scb</groupId>
>>>  <artifactId>tutorial1</artifactId>
>>>  <packaging>jar</packaging>
>>>  <version>0.7-SNAPSHOT</version>
>>>  <name>tutorial1</name>
>>>  <dependencies>
>>>      <dependency>
>>>          <groupId>org.trialox</groupId>
>>>          <artifactId>org.trialox.rdf.core</artifactId>
>>>          <version>0.4-SNAPSHOT</version>
>>>      </dependency>
>>>  </dependencies>
>>>  <build>
>>>      <plugins>
>>>          <plugin>
>>>              <groupId>org.apache.maven.plugins</groupId>
>>>              <artifactId>maven-compiler-plugin</artifactId>
>>>              <configuration>
>>>                  <source>1.6</source>
>>>                  <target>1.6</target>
>>>              </configuration>
>>>          </plugin>
>>>          <plugin>
>>>              <artifactId>maven-assembly-plugin</artifactId>
>>>              <executions>
>>>                  <execution>
>>>                      <id>assembly</id>
>>>                      <phase>package</phase>
>>>                      <goals>
>>>                          <goal>assembly</goal>
>>>                      </goals>
>>>                      <configuration>
>>>                          <descriptors>
>>>
>>> <descriptor>src/assembly/dist.xml</descriptor>
>>>                          </descriptors>
>>>                      </configuration>
>>>                  </execution>
>>>              </executions>
>>>          </plugin>
>>>          <plugin>
>>>              <groupId>org.apache.maven.plugins</groupId>
>>>              <artifactId>maven-jar-plugin</artifactId>
>>>              <configuration>
>>>                  <archive>
>>>                      <manifest>
>>>
>>> <mainClass>org.example.trialox.scb.tutorial1.App</mainClass>
>>>                          <addClasspath>true</addClasspath>
>>>                          <classpathPrefix>lib</classpathPrefix>
>>>                      </manifest>
>>>                  </archive>
>>>              </configuration>
>>>          </plugin>
>>>                      <!-- <plugin>
>>>              <groupId>org.apache.felix</groupId>
>>>              <artifactId>maven-bundle-plugin</artifactId>
>>>              <extensions>true</extensions>
>>>              <configuration>
>>>                  <instructions>
>>>
>>> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
>>>                  </instructions>
>>>              </configuration>
>>>          </plugin> -->
>>>      </plugins>
>>>  </build>
>>> </project>
>>>
>>> dist.xml:
>>>
>>>
>>> <assembly>
>>>  <id>dist</id>
>>>  <formats>
>>>      <format>dir</format>
>>>  </formats>
>>>  <includeBaseDirectory>false</includeBaseDirectory>
>>>  <fileSets>
>>>      <fileSet>
>>>          <directory>target</directory>
>>>          <outputDirectory></outputDirectory>
>>>          <includes>
>>>              <include>*.jar</include>
>>>          </includes>
>>>      </fileSet>
>>>  </fileSets>
>>>  <dependencySets>
>>>      <dependencySet>
>>>          <outputDirectory>/lib</outputDirectory>
>>>          <unpack>false</unpack>
>>>          <scope>runtime</scope>
>>>      </dependencySet>
>>>  </dependencySets>
>>> </assembly>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart

Re: test jars in lib folder

Posted by Clemens Wilding <cw...@access.uzh.ch>.
Thank you for your reply, but I was unclear about the issue.

My pom isn't actually creating a bundle but a jar and an assembly. The 
presence of the maven-bundle-plugin in the build/plugins section changes 
what the assembly plugin considers part of the runtime-dependencySet, 
without the plugin this includes the main jar built by the 
maven-jar-plugin with the plugin it includes a jar containing the tests 
instead of the main jar.

I come across  this because  we are using a parent-pom for all our 
projects (which are mostly of packaging 'bundle') which includes the 
maven-bundle-plugin.

Regards, Clemens


Stuart McCulloch wrote:
> 2008/11/27 Clemens Wilding <cw...@access.uzh.ch>
>
>   
>> Hello,
>>
>> To create a bundle, I use the org.apache.felix maven-bundle-plugin and the
>> maven-assembly-plugin. As the bundle depends
>> on another bundle, I specify with the assembly-plugin to install the
>> required bundle in a specified folder. This works fine.
>>
>> Now if I don't use the maven-bundle-plugin, the generated jar is included
>> in the specified folder. But if I use the plugin,
>> only a test jar is installed in this folder. I don't know if this is a
>> desired behaviour or maybe a little bug, so I wrote this mail.
>>
>>     
>
> this is working as designed...
>
> the maven-bundle-plugin is different to the maven-jar-plugin in that it does
> not simply
> jar up the contents of "target/classes" - instead it follows a recipe of
> instructions that
> define the desired content (ie.
> Export-Package/Private-Package/Include-Resource)
>
>    http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
>
> this is because we use the Bnd tool to generate the bundle, and this tool is
> designed
> to pull classes and resources from a classpath into one or more bundles,
> effectively
> slicing the classpath into different bundles
>
> the maven-bundle-plugin will try to map certain Maven conventions into the
> relevant
> Bnd instructions (for example src/main/resources -> Include-Resource)
> automatically
> and there are instructions that work on Maven dependencies
> (Embed-Dependency)
> - but it cannot know in this situation that it needs to include the file
> unless you tell it
>
> so if you want to add dependencies to the bundle you can use
> Embed-Dependency:
>
>    <Embed-Dependency>*;scope=runtime;inline=false</Embed-Dependency>
>    <Embed-Directory>lib</Embed-Directory>
>
> or you can continue with the assembly plugin and use Include-Resource to add
> them
> (see http://www.aqute.biz/Code/Bnd#include-resource for more detailed
> instructions)
>
> HTH
>
> As you might need some information about my configuration, I provide some
>   
>> information about the pom.xml and the assembly file dist.xml.
>>
>> Regards, Clemens
>>
>> pom.xml:
>>
>> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
>> http://www.w3.org/2001/XMLSchema-instance"
>>  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>>   <modelVersion>4.0.0</modelVersion>
>>   <groupId>org.example.trialox.scb</groupId>
>>   <artifactId>tutorial1</artifactId>
>>   <packaging>jar</packaging>
>>   <version>0.7-SNAPSHOT</version>
>>   <name>tutorial1</name>
>>   <dependencies>
>>       <dependency>
>>           <groupId>org.trialox</groupId>
>>           <artifactId>org.trialox.rdf.core</artifactId>
>>           <version>0.4-SNAPSHOT</version>
>>       </dependency>
>>   </dependencies>
>>   <build>
>>       <plugins>
>>           <plugin>
>>               <groupId>org.apache.maven.plugins</groupId>
>>               <artifactId>maven-compiler-plugin</artifactId>
>>               <configuration>
>>                   <source>1.6</source>
>>                   <target>1.6</target>
>>               </configuration>
>>           </plugin>
>>           <plugin>
>>               <artifactId>maven-assembly-plugin</artifactId>
>>               <executions>
>>                   <execution>
>>                       <id>assembly</id>
>>                       <phase>package</phase>
>>                       <goals>
>>                           <goal>assembly</goal>
>>                       </goals>
>>                       <configuration>
>>                           <descriptors>
>>
>> <descriptor>src/assembly/dist.xml</descriptor>
>>                           </descriptors>
>>                       </configuration>
>>                   </execution>
>>               </executions>
>>           </plugin>
>>           <plugin>
>>               <groupId>org.apache.maven.plugins</groupId>
>>               <artifactId>maven-jar-plugin</artifactId>
>>               <configuration>
>>                   <archive>
>>                       <manifest>
>>
>> <mainClass>org.example.trialox.scb.tutorial1.App</mainClass>
>>                           <addClasspath>true</addClasspath>
>>                           <classpathPrefix>lib</classpathPrefix>
>>                       </manifest>
>>                   </archive>
>>               </configuration>
>>           </plugin>
>>                       <!-- <plugin>
>>               <groupId>org.apache.felix</groupId>
>>               <artifactId>maven-bundle-plugin</artifactId>
>>               <extensions>true</extensions>
>>               <configuration>
>>                   <instructions>
>>
>> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
>>                   </instructions>
>>               </configuration>
>>           </plugin> -->
>>       </plugins>
>>   </build>
>> </project>
>>
>> dist.xml:
>>
>>
>> <assembly>
>>   <id>dist</id>
>>   <formats>
>>       <format>dir</format>
>>   </formats>
>>   <includeBaseDirectory>false</includeBaseDirectory>
>>   <fileSets>
>>       <fileSet>
>>           <directory>target</directory>
>>           <outputDirectory></outputDirectory>
>>           <includes>
>>               <include>*.jar</include>
>>           </includes>
>>       </fileSet>
>>   </fileSets>
>>   <dependencySets>
>>       <dependencySet>
>>           <outputDirectory>/lib</outputDirectory>
>>           <unpack>false</unpack>
>>           <scope>runtime</scope>
>>       </dependencySet>
>>   </dependencySets>
>> </assembly>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: test jars in lib folder

Posted by Stuart McCulloch <mc...@gmail.com>.
2008/11/27 Clemens Wilding <cw...@access.uzh.ch>

> Hello,
>
> To create a bundle, I use the org.apache.felix maven-bundle-plugin and the
> maven-assembly-plugin. As the bundle depends
> on another bundle, I specify with the assembly-plugin to install the
> required bundle in a specified folder. This works fine.
>
> Now if I don't use the maven-bundle-plugin, the generated jar is included
> in the specified folder. But if I use the plugin,
> only a test jar is installed in this folder. I don't know if this is a
> desired behaviour or maybe a little bug, so I wrote this mail.
>

this is working as designed...

the maven-bundle-plugin is different to the maven-jar-plugin in that it does
not simply
jar up the contents of "target/classes" - instead it follows a recipe of
instructions that
define the desired content (ie.
Export-Package/Private-Package/Include-Resource)

   http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

this is because we use the Bnd tool to generate the bundle, and this tool is
designed
to pull classes and resources from a classpath into one or more bundles,
effectively
slicing the classpath into different bundles

the maven-bundle-plugin will try to map certain Maven conventions into the
relevant
Bnd instructions (for example src/main/resources -> Include-Resource)
automatically
and there are instructions that work on Maven dependencies
(Embed-Dependency)
- but it cannot know in this situation that it needs to include the file
unless you tell it

so if you want to add dependencies to the bundle you can use
Embed-Dependency:

   <Embed-Dependency>*;scope=runtime;inline=false</Embed-Dependency>
   <Embed-Directory>lib</Embed-Directory>

or you can continue with the assembly plugin and use Include-Resource to add
them
(see http://www.aqute.biz/Code/Bnd#include-resource for more detailed
instructions)

HTH

As you might need some information about my configuration, I provide some
> information about the pom.xml and the assembly file dist.xml.
>
> Regards, Clemens
>
> pom.xml:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>org.example.trialox.scb</groupId>
>   <artifactId>tutorial1</artifactId>
>   <packaging>jar</packaging>
>   <version>0.7-SNAPSHOT</version>
>   <name>tutorial1</name>
>   <dependencies>
>       <dependency>
>           <groupId>org.trialox</groupId>
>           <artifactId>org.trialox.rdf.core</artifactId>
>           <version>0.4-SNAPSHOT</version>
>       </dependency>
>   </dependencies>
>   <build>
>       <plugins>
>           <plugin>
>               <groupId>org.apache.maven.plugins</groupId>
>               <artifactId>maven-compiler-plugin</artifactId>
>               <configuration>
>                   <source>1.6</source>
>                   <target>1.6</target>
>               </configuration>
>           </plugin>
>           <plugin>
>               <artifactId>maven-assembly-plugin</artifactId>
>               <executions>
>                   <execution>
>                       <id>assembly</id>
>                       <phase>package</phase>
>                       <goals>
>                           <goal>assembly</goal>
>                       </goals>
>                       <configuration>
>                           <descriptors>
>
> <descriptor>src/assembly/dist.xml</descriptor>
>                           </descriptors>
>                       </configuration>
>                   </execution>
>               </executions>
>           </plugin>
>           <plugin>
>               <groupId>org.apache.maven.plugins</groupId>
>               <artifactId>maven-jar-plugin</artifactId>
>               <configuration>
>                   <archive>
>                       <manifest>
>
> <mainClass>org.example.trialox.scb.tutorial1.App</mainClass>
>                           <addClasspath>true</addClasspath>
>                           <classpathPrefix>lib</classpathPrefix>
>                       </manifest>
>                   </archive>
>               </configuration>
>           </plugin>
>                       <!-- <plugin>
>               <groupId>org.apache.felix</groupId>
>               <artifactId>maven-bundle-plugin</artifactId>
>               <extensions>true</extensions>
>               <configuration>
>                   <instructions>
>
> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
>                   </instructions>
>               </configuration>
>           </plugin> -->
>       </plugins>
>   </build>
> </project>
>
> dist.xml:
>
>
> <assembly>
>   <id>dist</id>
>   <formats>
>       <format>dir</format>
>   </formats>
>   <includeBaseDirectory>false</includeBaseDirectory>
>   <fileSets>
>       <fileSet>
>           <directory>target</directory>
>           <outputDirectory></outputDirectory>
>           <includes>
>               <include>*.jar</include>
>           </includes>
>       </fileSet>
>   </fileSets>
>   <dependencySets>
>       <dependencySet>
>           <outputDirectory>/lib</outputDirectory>
>           <unpack>false</unpack>
>           <scope>runtime</scope>
>       </dependencySet>
>   </dependencySets>
> </assembly>
>
> --
>
> --trialox ag--------------------------------------
>
> Clemens Wilding
> Binzmühlestrasse 14
> CH-8050 Zürich
> Tel: 0041-44-63 57577
> Fax: 0041-44-63 57574
> URL: http://www.trialox.ch
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

-- 
Cheers, Stuart