You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by PeterNilsson <pe...@gmail.com> on 2007/09/02 18:54:34 UTC
Re: Retrieving version of the pom itself - not the child projects
pom
Won't ${project.version} be resolved to the version of the pom in the project
where the build was invoked?
I want the version of "this" pom, ie the pom which contains the property
reference. It will make a difference in a multi-module build where projects
have different versions.
Peter
Thorsten Heit-3 wrote:
>
> Hi,
>
>> What I would like is a way to refer to the version of "this" pom (ie the
>> same as the reference) not relative to the pom from which the build is
>> invoked.
>
> What about "${project.version}"? AFAIK this should work.
>
>
> HTH
>
> Thorsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Retrieving-version-of-the-pom-itself---not-the-child-projects-pom-tf4359342s177.html#a12451009
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Retrieving version of the pom itself - not the child projects
pom
Posted by PeterNilsson <pe...@gmail.com>.
Hi,
The parent pom belongs to a build config project and contains common build
configuration, ie dependency management, plugin management etc.
The parent pom is common for many projects with different release cycles,
therefore it will have a different version than the child projects.
Some of the plugin definitions in the plugin management section of the
parent pom refer to plugins (or libs that the plugins depend on) within the
build config project and thus have the same version as the parent pom.
It is these references within plugin management that I would like to avoid
having to manually update when doing a release.
The relevant parts of the parent pom:
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.1</version>
<dependencies>
<dependency>
<groupId>com.orc.maven</groupId>
<artifactId>checkstyle_config</artifactId>
<version>1.3-SNAPSHOT</version>
</dependency>
</dependencies>
....
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>1.3-SNAPSHOT</version>
....
</plugin>
The bold parts are the ones I like to replace with a reference to the
version of the pom they reside in.
Peter
Wayne Fay wrote:
>
> You've never said why you need this, so it is possible there are
> better ways to do what you're trying to do that would not require the
> manual step at release. Perhaps you can explain the reason behind this
> whole thing?
>
> Wayne
>
> On 9/5/07, PeterNilsson <pe...@gmail.com> wrote:
>>
>> Yes, that would work. The problem is that the release plugin will not
>> update
>> that property, so
>> we get a manual step when doing a release.
>>
>> Peter
>>
>>
>> Andrew Williams-5 wrote:
>> >
>> > Not entirely certain if this will help or not, but could you define a
>> > property and reference that instead?
>> >
>> > i.e.
>> > <property>
>> > <myversion>1.0-SNAPSHOT</myversion>
>> > </property>
>> >
>> > then using ${myversion} will always return you that version
>> >
>> > Andy
>> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Retrieving-version-of-the-pom-itself---not-the-child-projects-pom-tf4359342s177.html#a12517044
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Retrieving version of the pom itself - not the child projects pom
Posted by Wayne Fay <wa...@gmail.com>.
You've never said why you need this, so it is possible there are
better ways to do what you're trying to do that would not require the
manual step at release. Perhaps you can explain the reason behind this
whole thing?
Wayne
On 9/5/07, PeterNilsson <pe...@gmail.com> wrote:
>
> Yes, that would work. The problem is that the release plugin will not update
> that property, so
> we get a manual step when doing a release.
>
> Peter
>
>
> Andrew Williams-5 wrote:
> >
> > Not entirely certain if this will help or not, but could you define a
> > property and reference that instead?
> >
> > i.e.
> > <property>
> > <myversion>1.0-SNAPSHOT</myversion>
> > </property>
> >
> > then using ${myversion} will always return you that version
> >
> > Andy
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Retrieving version of the pom itself - not the child projects
pom
Posted by PeterNilsson <pe...@gmail.com>.
Yes, that would work. The problem is that the release plugin will not update
that property, so
we get a manual step when doing a release.
Peter
Andrew Williams-5 wrote:
>
> Not entirely certain if this will help or not, but could you define a
> property and reference that instead?
>
> i.e.
> <property>
> <myversion>1.0-SNAPSHOT</myversion>
> </property>
>
> then using ${myversion} will always return you that version
>
> Andy
>
> On 4 Sep 2007, at 08:42, PeterNilsson wrote:
>
>>
>> Hi,
>>
>> Sorry for being unclear.
>> What I need is a way to in the parentpom access the version of the
>> parent
>> pom regardless of where the builld was started from.
>>
>> In your example I want to write something in pom.xml (not my-module/
>> pom.xml)
>> that when the build is run from either parent, child or grandchild
>> will
>> output 1.0-SNAPSHOT.
>>
>> Peter
>>
>>
>> Thorsten Heit-3 wrote:
>>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Hi,
>>>
>>>> Won't ${project.version} be resolved to the version of the pom in
>>>> the
>>>> project
>>>> where the build was invoked?
>>>
>>> No. "${project.version}" in the child indeed contains the child's
>>> version, not the one from the parent. Try this:
>>>
>>>
>>> Parent:
>>>
>>> <project>
>>> <modelVersion>4.0.0</modelVersion>
>>> <groupId>com.mycompany.app</groupId>
>>> <artifactId>my-app</artifactId>
>>> <packaging>pom</packaging>
>>> <version>1.0-SNAPSHOT</version>
>>> <name>my-app</name>
>>>
>>> <modules>
>>> <module>my-module</module>
>>> </modules>
>>> </project>
>>>
>>>
>>> Child (my-module/pom.xml):
>>>
>>> <project>
>>> <modelVersion>4.0.0</modelVersion>
>>> <groupId>com.mycompany.app</groupId>
>>> <artifactId>my-app-test</artifactId>
>>> <packaging>jar</packaging>
>>> <version>2.0-SNAPSHOT</version>
>>> <name>my-app</name>
>>>
>>> <parent>
>>> <groupId>com.mycompany.app</groupId>
>>> <artifactId>my-app</artifactId>
>>> <version>1.0-SNAPSHOT</version>
>>> </parent>
>>>
>>> <build>
>>> <plugins>
>>> <plugin>
>>> <groupId>org.apache.maven.plugins</groupId>
>>> <artifactId>maven-antrun-plugin</artifactId>
>>> <executions>
>>> <execution>
>>> <phase>generate-sources</phase>
>>> <configuration>
>>> <tasks>
>>> <echo message="project.version: $
>>> {project.version}" />
>>> </tasks>
>>> </configuration>
>>> <goals>
>>> <goal>run</goal>
>>> </goals>
>>> </execution>
>>> </executions>
>>> </plugin>
>>> </plugins>
>>> </build>
>>> </project>
>>>
>>>
>>> "mvn compile" outputs
>>>
>>> (...)
>>> [INFO] Building my-app
>>> [INFO] task-segment: [compile]
>>> [INFO]
>>> -
>>> ---------------------------------------------------------------------
>>> -------
>>> [INFO] [antrun:run {execution: default}]
>>> [INFO] Executing tasks
>>> [echo] project.version: 2.0-SNAPSHOT
>>> [INFO] Executed tasks
>>> [INFO] [resources:resources]
>>> (...)
>>>
>>>
>>> Regards
>>>
>>> Thorsten
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.6 (Darwin)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>
>>> iEYEARECAAYFAkbccHkACgkQQvObkgCcDe3rWwCfeMXwqYi4Ouue0RuYmPxi1tNr
>>> dIkAn35t6lya0ChFVKiFnYsD76Cb9Dpc
>>> =47pS
>>> -----END PGP SIGNATURE-----
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/Retrieving-
>> version-of-the-pom-itself---not-the-child-projects-pom-
>> tf4359342s177.html#a12473366
>> Sent from the Maven - Users mailing list archive at Nabble.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
>
>
>
--
View this message in context: http://www.nabble.com/Retrieving-version-of-the-pom-itself---not-the-child-projects-pom-tf4359342s177.html#a12499244
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Retrieving version of the pom itself - not the child projects pom
Posted by Andrew Williams <an...@handyande.co.uk>.
Not entirely certain if this will help or not, but could you define a
property and reference that instead?
i.e.
<property>
<myversion>1.0-SNAPSHOT</myversion>
</property>
then using ${myversion} will always return you that version
Andy
On 4 Sep 2007, at 08:42, PeterNilsson wrote:
>
> Hi,
>
> Sorry for being unclear.
> What I need is a way to in the parentpom access the version of the
> parent
> pom regardless of where the builld was started from.
>
> In your example I want to write something in pom.xml (not my-module/
> pom.xml)
> that when the build is run from either parent, child or grandchild
> will
> output 1.0-SNAPSHOT.
>
> Peter
>
>
> Thorsten Heit-3 wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi,
>>
>>> Won't ${project.version} be resolved to the version of the pom in
>>> the
>>> project
>>> where the build was invoked?
>>
>> No. "${project.version}" in the child indeed contains the child's
>> version, not the one from the parent. Try this:
>>
>>
>> Parent:
>>
>> <project>
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>com.mycompany.app</groupId>
>> <artifactId>my-app</artifactId>
>> <packaging>pom</packaging>
>> <version>1.0-SNAPSHOT</version>
>> <name>my-app</name>
>>
>> <modules>
>> <module>my-module</module>
>> </modules>
>> </project>
>>
>>
>> Child (my-module/pom.xml):
>>
>> <project>
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>com.mycompany.app</groupId>
>> <artifactId>my-app-test</artifactId>
>> <packaging>jar</packaging>
>> <version>2.0-SNAPSHOT</version>
>> <name>my-app</name>
>>
>> <parent>
>> <groupId>com.mycompany.app</groupId>
>> <artifactId>my-app</artifactId>
>> <version>1.0-SNAPSHOT</version>
>> </parent>
>>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-antrun-plugin</artifactId>
>> <executions>
>> <execution>
>> <phase>generate-sources</phase>
>> <configuration>
>> <tasks>
>> <echo message="project.version: $
>> {project.version}" />
>> </tasks>
>> </configuration>
>> <goals>
>> <goal>run</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>> </project>
>>
>>
>> "mvn compile" outputs
>>
>> (...)
>> [INFO] Building my-app
>> [INFO] task-segment: [compile]
>> [INFO]
>> -
>> ---------------------------------------------------------------------
>> -------
>> [INFO] [antrun:run {execution: default}]
>> [INFO] Executing tasks
>> [echo] project.version: 2.0-SNAPSHOT
>> [INFO] Executed tasks
>> [INFO] [resources:resources]
>> (...)
>>
>>
>> Regards
>>
>> Thorsten
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.6 (Darwin)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAkbccHkACgkQQvObkgCcDe3rWwCfeMXwqYi4Ouue0RuYmPxi1tNr
>> dIkAn35t6lya0ChFVKiFnYsD76Cb9Dpc
>> =47pS
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Retrieving-
> version-of-the-pom-itself---not-the-child-projects-pom-
> tf4359342s177.html#a12473366
> Sent from the Maven - Users mailing list archive at Nabble.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: Retrieving version of the pom itself - not the child projects
pom
Posted by PeterNilsson <pe...@gmail.com>.
Hi,
Sorry for being unclear.
What I need is a way to in the parentpom access the version of the parent
pom regardless of where the builld was started from.
In your example I want to write something in pom.xml (not my-module/pom.xml)
that when the build is run from either parent, child or grandchild will
output 1.0-SNAPSHOT.
Peter
Thorsten Heit-3 wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
>> Won't ${project.version} be resolved to the version of the pom in the
>> project
>> where the build was invoked?
>
> No. "${project.version}" in the child indeed contains the child's
> version, not the one from the parent. Try this:
>
>
> Parent:
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.mycompany.app</groupId>
> <artifactId>my-app</artifactId>
> <packaging>pom</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>my-app</name>
>
> <modules>
> <module>my-module</module>
> </modules>
> </project>
>
>
> Child (my-module/pom.xml):
>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.mycompany.app</groupId>
> <artifactId>my-app-test</artifactId>
> <packaging>jar</packaging>
> <version>2.0-SNAPSHOT</version>
> <name>my-app</name>
>
> <parent>
> <groupId>com.mycompany.app</groupId>
> <artifactId>my-app</artifactId>
> <version>1.0-SNAPSHOT</version>
> </parent>
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-antrun-plugin</artifactId>
> <executions>
> <execution>
> <phase>generate-sources</phase>
> <configuration>
> <tasks>
> <echo message="project.version: ${project.version}" />
> </tasks>
> </configuration>
> <goals>
> <goal>run</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> "mvn compile" outputs
>
> (...)
> [INFO] Building my-app
> [INFO] task-segment: [compile]
> [INFO]
> -
> ----------------------------------------------------------------------------
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
> [echo] project.version: 2.0-SNAPSHOT
> [INFO] Executed tasks
> [INFO] [resources:resources]
> (...)
>
>
> Regards
>
> Thorsten
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkbccHkACgkQQvObkgCcDe3rWwCfeMXwqYi4Ouue0RuYmPxi1tNr
> dIkAn35t6lya0ChFVKiFnYsD76Cb9Dpc
> =47pS
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Retrieving-version-of-the-pom-itself---not-the-child-projects-pom-tf4359342s177.html#a12473366
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Retrieving version of the pom itself - not the child projects
pom
Posted by Thorsten Heit <th...@gmx.de>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
> Won't ${project.version} be resolved to the version of the pom in the project
> where the build was invoked?
No. "${project.version}" in the child indeed contains the child's
version, not the one from the parent. Try this:
Parent:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<modules>
<module>my-module</module>
</modules>
</project>
Child (my-module/pom.xml):
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app-test</artifactId>
<packaging>jar</packaging>
<version>2.0-SNAPSHOT</version>
<name>my-app</name>
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<echo message="project.version: ${project.version}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
"mvn compile" outputs
(...)
[INFO] Building my-app
[INFO] task-segment: [compile]
[INFO]
-
----------------------------------------------------------------------------
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
[echo] project.version: 2.0-SNAPSHOT
[INFO] Executed tasks
[INFO] [resources:resources]
(...)
Regards
Thorsten
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkbccHkACgkQQvObkgCcDe3rWwCfeMXwqYi4Ouue0RuYmPxi1tNr
dIkAn35t6lya0ChFVKiFnYsD76Cb9Dpc
=47pS
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org