You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Thomas Darbois <Th...@edifixio.com> on 2008/04/22 10:30:33 UTC
Maven Jar plugin 2.0 : ClassPath in manifest
Hello
I'm having trouble with a multi module project that I m working on.
I need a class path inside the manifest of the built jar (plugin maven jar and configuration <addClasspath>true</addClasspath> in my parent pom defined in pluginManagement).
The classpath is perfectly formatted when I'm running the project from the parent pom, but when I'm running maven from one of the module the class path is not well formatted: it add a version tag at the end of the name of the library the module depends on.
Example:
.
|-- pom.xml
|
|-- test
| `-- pom.xml
`-- toto
`-- pom.xml
A module toto (packaging: jar, version: 0.1) dependending on an other module test (packaging: jar, version: 0.1) both are called by the pom parent (packaging: pom, version: 0.1) using <modules> and both are inheriting from him (<parent><artifactId>parent</artifactId><groupId>com.edifixio.sample</groupId><version>0.1</version></parent>)=> fully project inheritance and aggregation.
The parent pom.xml look likes:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.edifixio.sample</groupId>
<artifactId>parent</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<modules>
<module>toto</module>
<module>test</module>
</modules>
<build>
<finalName>${artifactId}</finalName>
<pluginManagement><plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<!-- use of the newest version of the plugin in usual plugin repository -->
<executions>
<execution><!-- Copy yourself in outputDirectory -->
<id>copy</id>
<phase>install</phase><!-- add this step in install lifecycle -->
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>
${project.groupId}
</groupId>
<artifactId>
${project.artifactId}
</artifactId>
<version>
${project.version}
</version>
<overWrite>true</overWrite>
<type>
${project.packaging}
</type>
<destFileName>
${artifactId}.${project.packaging}
</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>
${projectOutput}
</outputDirectory>
</configuration>
</execution>
<execution><!-- Copy dependency of the artefact in outputDirectory -->
<id>copy-dependencies</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<outputDirectory>
${projectOutput}
</outputDirectory>
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
The directory test contains a pom.xml :
<project>
<parent><!-- inherit from parent -->
<groupId>com.edifixio.sample</groupId>
<artifactId>parent</artifactId>
<version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>
com.edifixio.sample
</groupId>
<artifactId>test</artifactId>
</project>
The directory toto contains a pom.xml :
<project>
<parent><!-- inherit from parent -->
<groupId>com.edifixio.sample</groupId>
<artifactId>parent</artifactId>
<version>0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>
com.edifixio.sample
</groupId>
<artifactId>toto</artifactId>
<dependencies>
<dependency>
<groupId>
com.edifixio.sample
</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
<build> <!-- Normal build + call of maven-dependency-plugin defined in the superPom -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I m packaging from the parent pom the classpath inside of the manifest of toto.jar looks like:
Class-Path: test.jar
When I'm packaging from toto the classpath inside the manifest of toto.jar looks like:
Class-Path: test-0.1.jar
I need to have a classpath that is perfectly predictable because I'm using those in order to run some of those standalone jars, and I'm getting the libraries they are depending on with maven-dependency-plugin and formatting them with a certain name format (actually <stripVersion>true</stripVersion> remove version tag) (mvn install). And so the classpath can't be resolved in case the version tag is in the manifest classpath.
Is there anywhere to format the name of the libraries inside the class-path? I know we can alter the directory where to find the library (with <classpathPrefix>) but the name I can't find any information?
Thanks for your time.
Tomas
PS: In reality the project is much more complex (with generic poms) but it's behaving just the same. I've reproduced the problem with this example.
RE: Maven Jar plugin 2.0 : ClassPath in manifest
Posted by Thomas Darbois <Th...@edifixio.com>.
Well i ve found the Jira that is linked to that problem :
Tomas Darbois
Edifixio Grenoble - Projet ScorWare
04 76 29 89 27
thomas.darbois@edifixio.com
-----Message d'origine-----
De : Thomas Darbois [mailto:Thomas.Darbois@edifixio.com]
Envoyé : mercredi 23 avril 2008 10:10
À : Maven Users List
Objet : RE: Maven Jar plugin 2.0 : ClassPath in manifest
Thanks for replying :)
I've tried to put <finalName> to the pom for test, it didn't change anything. I ve check the exported-pom and indeed the tag was already set to <finalName>${artifactId}<finalName> even without adding your suggestion (it inherits that part of the build from his parent pom). It seems that he doesn't read finalName tag in the exported-pom(s) that are inside the jar of his dependencies, but when you are generating the entire modules from the parent module, it keeps in memory all their finalname.
I don't know what you mean with your alternative solution (I might understand it but if it's the case it didn't work either).
I'll check the Jira if I see such a problem, but I've done several search and I didn't see anything like that (one solution might be working with full name: ${artifactId}-${version} as finalname instead of just artifactId, but I would prefer to avoid that).
And indeed I forget yesterday to put the maven version I'm using.
It's maven 2.0.8.
Tomas Darbois
-----Message d'origine-----
De : leemeador76018@gmail.com [mailto:leemeador76018@gmail.com] De la part de Lee Meador
Envoyé : mardi 22 avril 2008 19:34
À : Maven Users List
Objet : Re: Maven Jar plugin 2.0 : ClassPath in manifest
I'm not real familiar with that part of maven, but ...
Did you try adding a <finalName> to the pom for "test" to give it the name
without the version number included?
Alternatively, there might be a problem inheriting the dependency plugin
configurations in the toto project. You could try copying them from the
parent.
You might also look in the Jira to see if one of the plugins or maven itself
has such a problem already reported. You didn't mention which maven version
you are using.
-- Lee
On Tue, Apr 22, 2008 at 3:30 AM, Thomas Darbois <Th...@edifixio.com>
wrote:
> Hello
>
> I'm having trouble with a multi module project that I m working on.
>
>
> I need a class path inside the manifest of the built jar (plugin maven jar
> and configuration <addClasspath>true</addClasspath> in my parent pom defined
> in pluginManagement).
>
> The classpath is perfectly formatted when I'm running the project from the
> parent pom, but when I'm running maven from one of the module the class path
> is not well formatted: it add a version tag at the end of the name of the
> library the module depends on.
>
> Example:
>
>
>
> .
>
> |-- pom.xml
>
> |
>
> |-- test
>
> | `-- pom.xml
>
> `-- toto
>
> `-- pom.xml
>
>
> A module toto (packaging: jar, version: 0.1) dependending on an other
> module test (packaging: jar, version: 0.1) both are called by the pom parent
> (packaging: pom, version: 0.1) using <modules> and both are inheriting from
> him
> (<parent><artifactId>parent</artifactId><groupId>com.edifixio.sample</groupId><version>0.1</version></parent>)=>
> fully project inheritance and aggregation.
>
> The parent pom.xml look likes:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> <packaging>pom</packaging>
> <modules>
> <module>toto</module>
> <module>test</module>
> </modules>
> <build>
> <finalName>${artifactId}</finalName>
> <pluginManagement><plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <version>2.0</version>
> <configuration>
> <archive>
> <manifest>
>
> <addClasspath>true</addClasspath>
>
> <mainClass>${mainClass}</mainClass>
> </manifest>
> </archive>
> </configuration>
> <executions>
> <execution>
> <phase>compile</phase>
> <goals>
> <goal>jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-dependency-plugin</artifactId>
> <!-- use of the newest version of the plugin
> in usual plugin repository -->
> <executions>
> <execution><!-- Copy yourself in
> outputDirectory -->
> <id>copy</id>
> <phase>install</phase><!-- add
> this step in install lifecycle -->
> <goals>
> <goal>copy</goal>
> </goals>
> <configuration>
> <artifactItems>
> <artifactItem>
> <groupId>
>
> ${project.groupId}
> </groupId>
> <artifactId>
>
> ${project.artifactId}
> </artifactId>
> <version>
>
> ${project.version}
> </version>
>
> <overWrite>true</overWrite>
> <type>
>
> ${project.packaging}
> </type>
> <destFileName>
>
> ${artifactId}.${project.packaging}
> </destFileName>
> </artifactItem>
> </artifactItems>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
> </configuration>
> </execution>
> <execution><!-- Copy dependency of the
> artefact in outputDirectory -->
> <id>copy-dependencies</id>
> <phase>install</phase>
> <goals>
>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
>
> <stripVersion>true</stripVersion>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
>
> <excludeScope>provided</excludeScope>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
> </project>
>
>
>
> The directory test contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> </project>
>
> The directory toto contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>toto</artifactId>
> <dependencies>
> <dependency>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> <version>0.1</version>
> </dependency>
> </dependencies>
> <build> <!-- Normal build + call of maven-dependency-plugin defined
> in the superPom -->
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
> </plugin>
> </plugins>
> </build>
>
> </project>
>
>
>
> When I m packaging from the parent pom the classpath inside of the
> manifest of toto.jar looks like:
> Class-Path: test.jar
>
> When I'm packaging from toto the classpath inside the manifest of toto.jar
> looks like:
> Class-Path: test-0.1.jar
>
>
> I need to have a classpath that is perfectly predictable because I'm using
> those in order to run some of those standalone jars, and I'm getting the
> libraries they are depending on with maven-dependency-plugin and formatting
> them with a certain name format (actually <stripVersion>true</stripVersion>
> remove version tag) (mvn install). And so the classpath can't be resolved in
> case the version tag is in the manifest classpath.
>
>
> Is there anywhere to format the name of the libraries inside the
> class-path? I know we can alter the directory where to find the library
> (with <classpathPrefix>) but the name I can't find any information?
>
>
> Thanks for your time.
>
> Tomas
>
> PS: In reality the project is much more complex (with generic poms) but
> it's behaving just the same. I've reproduced the problem with this example.
>
--
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Maven Jar plugin 2.0 : ClassPath in manifest
Posted by Thomas Darbois <Th...@edifixio.com>.
Clicked on send before pasting the link:
http://jira.codehaus.org/browse/MJAR-61
Tomas Darbois
-----Message d'origine-----
De : Thomas Darbois
Envoyé : mercredi 23 avril 2008 11:00
À : 'Maven Users List'
Objet : RE: Maven Jar plugin 2.0 : ClassPath in manifest
Well i ve found the Jira that is linked to that problem :
Tomas Darbois
-----Message d'origine-----
De : Thomas Darbois [mailto:Thomas.Darbois@edifixio.com]
Envoyé : mercredi 23 avril 2008 10:10
À : Maven Users List
Objet : RE: Maven Jar plugin 2.0 : ClassPath in manifest
Thanks for replying :)
I've tried to put <finalName> to the pom for test, it didn't change anything. I ve check the exported-pom and indeed the tag was already set to <finalName>${artifactId}<finalName> even without adding your suggestion (it inherits that part of the build from his parent pom). It seems that he doesn't read finalName tag in the exported-pom(s) that are inside the jar of his dependencies, but when you are generating the entire modules from the parent module, it keeps in memory all their finalname.
I don't know what you mean with your alternative solution (I might understand it but if it's the case it didn't work either).
I'll check the Jira if I see such a problem, but I've done several search and I didn't see anything like that (one solution might be working with full name: ${artifactId}-${version} as finalname instead of just artifactId, but I would prefer to avoid that).
And indeed I forget yesterday to put the maven version I'm using.
It's maven 2.0.8.
Tomas Darbois
-----Message d'origine-----
De : leemeador76018@gmail.com [mailto:leemeador76018@gmail.com] De la part de Lee Meador
Envoyé : mardi 22 avril 2008 19:34
À : Maven Users List
Objet : Re: Maven Jar plugin 2.0 : ClassPath in manifest
I'm not real familiar with that part of maven, but ...
Did you try adding a <finalName> to the pom for "test" to give it the name
without the version number included?
Alternatively, there might be a problem inheriting the dependency plugin
configurations in the toto project. You could try copying them from the
parent.
You might also look in the Jira to see if one of the plugins or maven itself
has such a problem already reported. You didn't mention which maven version
you are using.
-- Lee
On Tue, Apr 22, 2008 at 3:30 AM, Thomas Darbois <Th...@edifixio.com>
wrote:
> Hello
>
> I'm having trouble with a multi module project that I m working on.
>
>
> I need a class path inside the manifest of the built jar (plugin maven jar
> and configuration <addClasspath>true</addClasspath> in my parent pom defined
> in pluginManagement).
>
> The classpath is perfectly formatted when I'm running the project from the
> parent pom, but when I'm running maven from one of the module the class path
> is not well formatted: it add a version tag at the end of the name of the
> library the module depends on.
>
> Example:
>
>
>
> .
>
> |-- pom.xml
>
> |
>
> |-- test
>
> | `-- pom.xml
>
> `-- toto
>
> `-- pom.xml
>
>
> A module toto (packaging: jar, version: 0.1) dependending on an other
> module test (packaging: jar, version: 0.1) both are called by the pom parent
> (packaging: pom, version: 0.1) using <modules> and both are inheriting from
> him
> (<parent><artifactId>parent</artifactId><groupId>com.edifixio.sample</groupId><version>0.1</version></parent>)=>
> fully project inheritance and aggregation.
>
> The parent pom.xml look likes:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> <packaging>pom</packaging>
> <modules>
> <module>toto</module>
> <module>test</module>
> </modules>
> <build>
> <finalName>${artifactId}</finalName>
> <pluginManagement><plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <version>2.0</version>
> <configuration>
> <archive>
> <manifest>
>
> <addClasspath>true</addClasspath>
>
> <mainClass>${mainClass}</mainClass>
> </manifest>
> </archive>
> </configuration>
> <executions>
> <execution>
> <phase>compile</phase>
> <goals>
> <goal>jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-dependency-plugin</artifactId>
> <!-- use of the newest version of the plugin
> in usual plugin repository -->
> <executions>
> <execution><!-- Copy yourself in
> outputDirectory -->
> <id>copy</id>
> <phase>install</phase><!-- add
> this step in install lifecycle -->
> <goals>
> <goal>copy</goal>
> </goals>
> <configuration>
> <artifactItems>
> <artifactItem>
> <groupId>
>
> ${project.groupId}
> </groupId>
> <artifactId>
>
> ${project.artifactId}
> </artifactId>
> <version>
>
> ${project.version}
> </version>
>
> <overWrite>true</overWrite>
> <type>
>
> ${project.packaging}
> </type>
> <destFileName>
>
> ${artifactId}.${project.packaging}
> </destFileName>
> </artifactItem>
> </artifactItems>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
> </configuration>
> </execution>
> <execution><!-- Copy dependency of the
> artefact in outputDirectory -->
> <id>copy-dependencies</id>
> <phase>install</phase>
> <goals>
>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
>
> <stripVersion>true</stripVersion>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
>
> <excludeScope>provided</excludeScope>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
> </project>
>
>
>
> The directory test contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> </project>
>
> The directory toto contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>toto</artifactId>
> <dependencies>
> <dependency>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> <version>0.1</version>
> </dependency>
> </dependencies>
> <build> <!-- Normal build + call of maven-dependency-plugin defined
> in the superPom -->
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
> </plugin>
> </plugins>
> </build>
>
> </project>
>
>
>
> When I m packaging from the parent pom the classpath inside of the
> manifest of toto.jar looks like:
> Class-Path: test.jar
>
> When I'm packaging from toto the classpath inside the manifest of toto.jar
> looks like:
> Class-Path: test-0.1.jar
>
>
> I need to have a classpath that is perfectly predictable because I'm using
> those in order to run some of those standalone jars, and I'm getting the
> libraries they are depending on with maven-dependency-plugin and formatting
> them with a certain name format (actually <stripVersion>true</stripVersion>
> remove version tag) (mvn install). And so the classpath can't be resolved in
> case the version tag is in the manifest classpath.
>
>
> Is there anywhere to format the name of the libraries inside the
> class-path? I know we can alter the directory where to find the library
> (with <classpathPrefix>) but the name I can't find any information?
>
>
> Thanks for your time.
>
> Tomas
>
> PS: In reality the project is much more complex (with generic poms) but
> it's behaving just the same. I've reproduced the problem with this example.
>
--
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Maven Jar plugin 2.0 : ClassPath in manifest
Posted by Thomas Darbois <Th...@edifixio.com>.
Thanks for replying :)
I've tried to put <finalName> to the pom for test, it didn't change anything. I ve check the exported-pom and indeed the tag was already set to <finalName>${artifactId}<finalName> even without adding your suggestion (it inherits that part of the build from his parent pom). It seems that he doesn't read finalName tag in the exported-pom(s) that are inside the jar of his dependencies, but when you are generating the entire modules from the parent module, it keeps in memory all their finalname.
I don't know what you mean with your alternative solution (I might understand it but if it's the case it didn't work either).
I'll check the Jira if I see such a problem, but I've done several search and I didn't see anything like that (one solution might be working with full name: ${artifactId}-${version} as finalname instead of just artifactId, but I would prefer to avoid that).
And indeed I forget yesterday to put the maven version I'm using.
It's maven 2.0.8.
Tomas Darbois
-----Message d'origine-----
De : leemeador76018@gmail.com [mailto:leemeador76018@gmail.com] De la part de Lee Meador
Envoyé : mardi 22 avril 2008 19:34
À : Maven Users List
Objet : Re: Maven Jar plugin 2.0 : ClassPath in manifest
I'm not real familiar with that part of maven, but ...
Did you try adding a <finalName> to the pom for "test" to give it the name
without the version number included?
Alternatively, there might be a problem inheriting the dependency plugin
configurations in the toto project. You could try copying them from the
parent.
You might also look in the Jira to see if one of the plugins or maven itself
has such a problem already reported. You didn't mention which maven version
you are using.
-- Lee
On Tue, Apr 22, 2008 at 3:30 AM, Thomas Darbois <Th...@edifixio.com>
wrote:
> Hello
>
> I'm having trouble with a multi module project that I m working on.
>
>
> I need a class path inside the manifest of the built jar (plugin maven jar
> and configuration <addClasspath>true</addClasspath> in my parent pom defined
> in pluginManagement).
>
> The classpath is perfectly formatted when I'm running the project from the
> parent pom, but when I'm running maven from one of the module the class path
> is not well formatted: it add a version tag at the end of the name of the
> library the module depends on.
>
> Example:
>
>
>
> .
>
> |-- pom.xml
>
> |
>
> |-- test
>
> | `-- pom.xml
>
> `-- toto
>
> `-- pom.xml
>
>
> A module toto (packaging: jar, version: 0.1) dependending on an other
> module test (packaging: jar, version: 0.1) both are called by the pom parent
> (packaging: pom, version: 0.1) using <modules> and both are inheriting from
> him
> (<parent><artifactId>parent</artifactId><groupId>com.edifixio.sample</groupId><version>0.1</version></parent>)=>
> fully project inheritance and aggregation.
>
> The parent pom.xml look likes:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> <packaging>pom</packaging>
> <modules>
> <module>toto</module>
> <module>test</module>
> </modules>
> <build>
> <finalName>${artifactId}</finalName>
> <pluginManagement><plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <version>2.0</version>
> <configuration>
> <archive>
> <manifest>
>
> <addClasspath>true</addClasspath>
>
> <mainClass>${mainClass}</mainClass>
> </manifest>
> </archive>
> </configuration>
> <executions>
> <execution>
> <phase>compile</phase>
> <goals>
> <goal>jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-dependency-plugin</artifactId>
> <!-- use of the newest version of the plugin
> in usual plugin repository -->
> <executions>
> <execution><!-- Copy yourself in
> outputDirectory -->
> <id>copy</id>
> <phase>install</phase><!-- add
> this step in install lifecycle -->
> <goals>
> <goal>copy</goal>
> </goals>
> <configuration>
> <artifactItems>
> <artifactItem>
> <groupId>
>
> ${project.groupId}
> </groupId>
> <artifactId>
>
> ${project.artifactId}
> </artifactId>
> <version>
>
> ${project.version}
> </version>
>
> <overWrite>true</overWrite>
> <type>
>
> ${project.packaging}
> </type>
> <destFileName>
>
> ${artifactId}.${project.packaging}
> </destFileName>
> </artifactItem>
> </artifactItems>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
> </configuration>
> </execution>
> <execution><!-- Copy dependency of the
> artefact in outputDirectory -->
> <id>copy-dependencies</id>
> <phase>install</phase>
> <goals>
>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
>
> <stripVersion>true</stripVersion>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
>
> <excludeScope>provided</excludeScope>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
> </project>
>
>
>
> The directory test contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> </project>
>
> The directory toto contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>toto</artifactId>
> <dependencies>
> <dependency>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> <version>0.1</version>
> </dependency>
> </dependencies>
> <build> <!-- Normal build + call of maven-dependency-plugin defined
> in the superPom -->
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
> </plugin>
> </plugins>
> </build>
>
> </project>
>
>
>
> When I m packaging from the parent pom the classpath inside of the
> manifest of toto.jar looks like:
> Class-Path: test.jar
>
> When I'm packaging from toto the classpath inside the manifest of toto.jar
> looks like:
> Class-Path: test-0.1.jar
>
>
> I need to have a classpath that is perfectly predictable because I'm using
> those in order to run some of those standalone jars, and I'm getting the
> libraries they are depending on with maven-dependency-plugin and formatting
> them with a certain name format (actually <stripVersion>true</stripVersion>
> remove version tag) (mvn install). And so the classpath can't be resolved in
> case the version tag is in the manifest classpath.
>
>
> Is there anywhere to format the name of the libraries inside the
> class-path? I know we can alter the directory where to find the library
> (with <classpathPrefix>) but the name I can't find any information?
>
>
> Thanks for your time.
>
> Tomas
>
> PS: In reality the project is much more complex (with generic poms) but
> it's behaving just the same. I've reproduced the problem with this example.
>
--
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Maven Jar plugin 2.0 : ClassPath in manifest
Posted by Lee Meador <le...@leemeador.com>.
I'm not real familiar with that part of maven, but ...
Did you try adding a <finalName> to the pom for "test" to give it the name
without the version number included?
Alternatively, there might be a problem inheriting the dependency plugin
configurations in the toto project. You could try copying them from the
parent.
You might also look in the Jira to see if one of the plugins or maven itself
has such a problem already reported. You didn't mention which maven version
you are using.
-- Lee
On Tue, Apr 22, 2008 at 3:30 AM, Thomas Darbois <Th...@edifixio.com>
wrote:
> Hello
>
> I'm having trouble with a multi module project that I m working on.
>
>
> I need a class path inside the manifest of the built jar (plugin maven jar
> and configuration <addClasspath>true</addClasspath> in my parent pom defined
> in pluginManagement).
>
> The classpath is perfectly formatted when I'm running the project from the
> parent pom, but when I'm running maven from one of the module the class path
> is not well formatted: it add a version tag at the end of the name of the
> library the module depends on.
>
> Example:
>
>
>
> .
>
> |-- pom.xml
>
> |
>
> |-- test
>
> | `-- pom.xml
>
> `-- toto
>
> `-- pom.xml
>
>
> A module toto (packaging: jar, version: 0.1) dependending on an other
> module test (packaging: jar, version: 0.1) both are called by the pom parent
> (packaging: pom, version: 0.1) using <modules> and both are inheriting from
> him
> (<parent><artifactId>parent</artifactId><groupId>com.edifixio.sample</groupId><version>0.1</version></parent>)=>
> fully project inheritance and aggregation.
>
> The parent pom.xml look likes:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> <packaging>pom</packaging>
> <modules>
> <module>toto</module>
> <module>test</module>
> </modules>
> <build>
> <finalName>${artifactId}</finalName>
> <pluginManagement><plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <version>2.0</version>
> <configuration>
> <archive>
> <manifest>
>
> <addClasspath>true</addClasspath>
>
> <mainClass>${mainClass}</mainClass>
> </manifest>
> </archive>
> </configuration>
> <executions>
> <execution>
> <phase>compile</phase>
> <goals>
> <goal>jar</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
>
> <artifactId>maven-dependency-plugin</artifactId>
> <!-- use of the newest version of the plugin
> in usual plugin repository -->
> <executions>
> <execution><!-- Copy yourself in
> outputDirectory -->
> <id>copy</id>
> <phase>install</phase><!-- add
> this step in install lifecycle -->
> <goals>
> <goal>copy</goal>
> </goals>
> <configuration>
> <artifactItems>
> <artifactItem>
> <groupId>
>
> ${project.groupId}
> </groupId>
> <artifactId>
>
> ${project.artifactId}
> </artifactId>
> <version>
>
> ${project.version}
> </version>
>
> <overWrite>true</overWrite>
> <type>
>
> ${project.packaging}
> </type>
> <destFileName>
>
> ${artifactId}.${project.packaging}
> </destFileName>
> </artifactItem>
> </artifactItems>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
> </configuration>
> </execution>
> <execution><!-- Copy dependency of the
> artefact in outputDirectory -->
> <id>copy-dependencies</id>
> <phase>install</phase>
> <goals>
>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
>
> <stripVersion>true</stripVersion>
> <outputDirectory>
> ${projectOutput}
> </outputDirectory>
>
> <excludeScope>provided</excludeScope>
> </configuration>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </pluginManagement>
> </build>
> </project>
>
>
>
> The directory test contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> </project>
>
> The directory toto contains a pom.xml :
>
> <project>
> <parent><!-- inherit from parent -->
> <groupId>com.edifixio.sample</groupId>
> <artifactId>parent</artifactId>
> <version>0.1</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>toto</artifactId>
> <dependencies>
> <dependency>
> <groupId>
> com.edifixio.sample
> </groupId>
> <artifactId>test</artifactId>
> <version>0.1</version>
> </dependency>
> </dependencies>
> <build> <!-- Normal build + call of maven-dependency-plugin defined
> in the superPom -->
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
> </plugin>
> </plugins>
> </build>
>
> </project>
>
>
>
> When I m packaging from the parent pom the classpath inside of the
> manifest of toto.jar looks like:
> Class-Path: test.jar
>
> When I'm packaging from toto the classpath inside the manifest of toto.jar
> looks like:
> Class-Path: test-0.1.jar
>
>
> I need to have a classpath that is perfectly predictable because I'm using
> those in order to run some of those standalone jars, and I'm getting the
> libraries they are depending on with maven-dependency-plugin and formatting
> them with a certain name format (actually <stripVersion>true</stripVersion>
> remove version tag) (mvn install). And so the classpath can't be resolved in
> case the version tag is in the manifest classpath.
>
>
> Is there anywhere to format the name of the libraries inside the
> class-path? I know we can alter the directory where to find the library
> (with <classpathPrefix>) but the name I can't find any information?
>
>
> Thanks for your time.
>
> Tomas
>
> PS: In reality the project is much more complex (with generic poms) but
> it's behaving just the same. I've reproduced the problem with this example.
>
--
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.com