You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Pepe Perez <pp...@yahoo.com> on 2009/10/29 04:59:08 UTC

maven doesn't filter dependencies defined in pom

Hello,

This is the situation I'm in.

I have this structure

pom.xml (root)
|_ pom.xml (module A)
|_ pom.xml (module B)

These are (excerpts) of the poms

pom.xml (root)
    <groupId>rootGroupId</groupId>
    <artifactId>rootArtifactId</artifactId>
    <packaging>pom</packaging>
    <version>${rootGroupId}</version>

    <modules>
      <module>moduleA</module>
      <module>moduleB</module>
   </modules>

<properties>
  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
  <rootGroupId>rootVersion</rootGroupId>
</properties>

pom (module A)

    <parent>
        <groupId>rootGroupId</groupId>
        <artifactId>rootArtifactId</artifactId>
        <version>${rootGroupId}</version>
    </parent>

    <groupId>moduleAGroupId</groupId>
    <artifactId>moduleAArtifactId</artifactId>
    <packaging>pom</packaging>
    <version>${moduleAGroupId}</version>

pom (module B)

    <parent>
        <groupId>rootGroupId</groupId>
        <artifactId>rootArtifactId</artifactId>
        <version>${rootGroupId}</version>
    </parent>

    <groupId>moduleBGroupId</groupId>
    <artifactId>moduleBArtifactId</artifactId>
    <packaging>pom</packaging>
    <version>${moduleBGroupId}</version>

   <dependencies>
     <dependency>
         <groupId>moduleAGroupId</groupId>
         <artifactId>moduleAArtifactId</artifactId>
        <version>${moduleAGroupId}</version>
     <dependency>
  </dependency>

cd root
mvn install

------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------

cd moduleB
mvn install

[WARNING] Unable to get resource
'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
from repository central (http://repo1.maven.org/maven2): Error
transferring file: Server returned HTTP response code: 500 for URL:
http://<pom_maven_repo_location>
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: moduleB

Reason: Cannot find parent: moduleA pom for project: moduleB

This is happening because when building moduleA its pom file is 
installed in the maven repo without filtering, i.e, as it is with ${}. 
When the pom is retrieved to satisfy moduleB dependency on moduleA it's 
retrieved as

<groupId>moduleAGroupId</groupId>
<artifactId>moduleAArtifactId</artifactId>
<packaging>pom</packaging>
<version>${moduleAGroupId}</version>

where ${moduleAGroupId} is not instanciated, hence the error.

My question is:
1. Could I force maven to store the pom files **filtered** or
2. How can maven be forced to instantiate ${moduleAGroupId} upon 
retrieval from the maven repo so moduleB dependency can be satisfied
3. What other alternative do I have to solve this scenario without 
giving up using ${} in <version>


      


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


Re: maven doesn't filter dependencies defined in pom

Posted by Stephen Connolly <st...@gmail.com>.
2009/10/29 Pepe Perez <pp...@yahoo.com>

> using dependencyManagement would solve my problem for the dependencies, but
> due to my project requirements I still need to use a property in the parent
> <version>, which is not managed by dependencyManagement.
>
> From what I can see maven doesn't have any problem in replacing properties
> in the <parent> block of the current pom, but it does when it retrieves the
> pom of a dependency from the repo to which it was previously downloaded when
> building from the root. This pom taken from


It would appear that you do need the longer and more technical explanation.

When maven builds a project tree it first hast to construct the models.

In any one build plan, you can only have one and only one version of a
groupId:artifactId coordinate.  (This is where things can get a bit
confusing, so to clarify, I am talking about projects and not depedencies)

So that the end result of this is that maven never even looks at the
/project/parent/version field because it says, hang on a sec, I have
rootGroupId:rootArtifactId already in the reactor and its location is where
/project/parent/relativePath says it should be (i.e. ../pom.xml) so I will
use that as the parent.

Only after it has constructed the interpolated model does maven go back and
check that the parent version matches the parent version.  (Note that this
later checking should properly be considered a bug in Maven)


> the repo has a property in the <parent> section, and contrary to what maven
> does for the current pom maven doesn't replace properties here.
>
> My issue would be solve if the poms where installed into the maven repo
> with the properties already replaced by their value, or if it replaced
> properties in the poms retrieved from the repo to calculate transitive
> dependencies.
>

How can maven retrieve the parent pom from the repository if it does not
have a definitive coordinate for that parent pom?

The only solution is to deploy pom files to the repository with properties
replaced... but it is not quite that simple because you'd only want certain
properties to be replaced and others to be left as is.

For example, if I have a parent pom with

<project>
  ...
  <properties>
    <foo-version>1.0</foo-version>
  </properties>
  ...
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.manchu</groupId>
        <artifactId>foo-api</artifactId>
        <version>${foo-version}</version>
      </dependency>
      <dependency>
        <groupId>com.manchu</groupId>
        <artifactId>foo-core</artifactId>
        <version>${foo-version}</version>
      </dependency>
      <dependency>
        <groupId>com.manchu</groupId>
        <artifactId>foo-bar</artifactId>
        <version>${foo-version}</version>
      </dependency>
      <dependency>
        <groupId>com.manchu</groupId>
        <artifactId>foo-manchu</artifactId>
        <version>${foo-version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>
  ...
</project>

A project which inherits from this parent pom can then switch the entire foo
suite of dependencies over to version 1.1 just by overriding the property
foo-version.  This is a very powerful concept... it is also a fricking
nightmare... if you don't know about it

To see this in action, unzip the attached file and run

mvn help:effective-pom

************************************************************************************
> Effective POM for project 'localhost:parent:pom:1-SNAPSHOT'
>
> ************************************************************************************
> *[snip]*
>   <dependencyManagement>
>     <dependencies>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-api</artifactId>
>         <version>1.0</version>
>       </dependency>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-core</artifactId>
>         <version>1.0</version>
>       </dependency>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-bar</artifactId>
>         <version>1.0</version>
>       </dependency>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-manchu</artifactId>
>         <version>1.0</version>
>       </dependency>
>     </dependencies>
>   </dependencyManagement>
> *[snip]*
>
> ************************************************************************************
> Effective POM for project 'localhost:child:jar:1-SNAPSHOT'
>
> ************************************************************************************
> *[snip]*
>   <dependencyManagement>
>     <dependencies>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-api</artifactId>
>         <version>1.1</version>
>       </dependency>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-core</artifactId>
>         <version>1.1</version>
>       </dependency>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-bar</artifactId>
>         <version>1.1</version>
>       </dependency>
>       <dependency>
>         <groupId>com.manchu</groupId>
>         <artifactId>foo-manchu</artifactId>
>         <version>1.1</version>
>       </dependency>
>     </dependencies>
>   </dependencyManagement>
>

So the short answer is that we would not be replacing every ${...} in the
deployed model... we would only be replacing very specific places...

-Stephen


>
>
> ----- Original Message ----
> From: Stephen Connolly <st...@gmail.com>
> To: Maven Users List <us...@maven.apache.org>
> Sent: Wed, October 28, 2009 11:30:37 PM
> Subject: Re: maven doesn't filter dependencies defined in pom
>
> 2009/10/29 Stephen Connolly <st...@gmail.com>
>
> > property substitution is not supported in
> >
> > /project(/parent)?/version
> >
> > 2009/10/29 Pepe Perez <pp...@yahoo.com>
> >
> > Hello,
> >>
> >> This is the situation I'm in.
> >>
> >> I have this structure
> >>
> >> pom.xml (root)
> >> |_ pom.xml (module A)
> >> |_ pom.xml (module B)
> >>
> >> These are (excerpts) of the poms
> >>
> >> pom.xml (root)
> >>    <groupId>rootGroupId</groupId>
> >>    <artifactId>rootArtifactId</artifactId>
> >>    <packaging>pom</packaging>
> >>    <version>${rootGroupId}</version>
> >>
> >>    <modules>
> >>      <module>moduleA</module>
> >>      <module>moduleB</module>
> >>   </modules>
> >>
> >> <properties>
> >>  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
> >>  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
> >>  <rootGroupId>rootVersion</rootGroupId>
> >> </properties>
> >>
> >> pom (module A)
> >>
> >>    <parent>
> >>        <groupId>rootGroupId</groupId>
> >>        <artifactId>rootArtifactId</artifactId>
> >>        <version>${rootGroupId}</version>
> >>    </parent>
> >>
> >>
> because maven does not know rootGroupId until it fetches the parent, it
> does
> not know what parent to fetch, so it does not know moduleAGroupId either
>
>
> >    <groupId>moduleAGroupId</groupId>
> >>    <artifactId>moduleAArtifactId</artifactId>
> >>    <packaging>pom</packaging>
> >>    <version>${moduleAGroupId}</version>
> >>
> >> pom (module B)
> >>
> >>    <parent>
> >>        <groupId>rootGroupId</groupId>
> >>        <artifactId>rootArtifactId</artifactId>
> >>        <version>${rootGroupId}</version>
> >>    </parent>
> >>
> >>    <groupId>moduleBGroupId</groupId>
> >>    <artifactId>moduleBArtifactId</artifactId>
> >>    <packaging>pom</packaging>
> >>    <version>${moduleBGroupId}</version>
> >>
> >>   <dependencies>
> >>     <dependency>
> >>         <groupId>moduleAGroupId</groupId>
> >>         <artifactId>moduleAArtifactId</artifactId>
> >>        <version>${moduleAGroupId}</version>
> >>     <dependency>
> >>  </dependency>
> >>
> >> cd root
> >> mvn install
> >>
> >> ------------------------------------------------------------------------
> >> [INFO] BUILD SUCCESSFUL
> >> [INFO]
> >> ------------------------------------------------------------------------
> >>
> >> cd moduleB
> >> mvn install
> >>
> >> [WARNING] Unable to get resource
> >> 'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
> >> from repository central (http://repo1.maven.org/maven2): Error
> >> transferring file: Server returned HTTP response code: 500 for URL:
> >> http://<pom_maven_repo_location>
> >> ------------------------------------------------------------------------
> >> [ERROR] BUILD ERROR
> >> [INFO]
> >> ------------------------------------------------------------------------
> >> [INFO] Error building POM (may not be this project's POM).
> >>
> >>
> >> Project ID: moduleB
> >>
> >> Reason: Cannot find parent: moduleA pom for project: moduleB
> >>
> >> This is happening because when building moduleA its pom file is
> >> installed in the maven repo without filtering, i.e, as it is with ${}.
> >> When the pom is retrieved to satisfy moduleB dependency on moduleA it's
> >> retrieved as
> >>
> >> <groupId>moduleAGroupId</groupId>
> >> <artifactId>moduleAArtifactId</artifactId>
> >> <packaging>pom</packaging>
> >> <version>${moduleAGroupId}</version>
> >>
> >> where ${moduleAGroupId} is not instanciated, hence the error.
> >>
> >> My question is:
> >> 1. Could I force maven to store the pom files **filtered** or
> >> 2. How can maven be forced to instantiate ${moduleAGroupId} upon
> >> retrieval from the maven repo so moduleB dependency can be satisfied
> >> 3. What other alternative do I have to solve this scenario without
> >> giving up using ${} in <version>
> >>
> >
> why do you need to use properties for /project(/parent)?/version
>
> if you use the release plugin, it will update those correctly, and as well
> will likely update the dependencies for you.  It would seem to me that your
> use case would be better served with a dependencyManagement section in the
> root pom. then you can omit the version in the dependency sections of each
> child pom such that the only versions specified are
> in /project(/parent)?/version
>
> Also, if you are going to release all of them in the same go, you should
> note that /project/version is inherited from /project/parent/version
>
> my solution would be as follows:
>
> pom.xml (root)
> <project>
>   <groupId>rootGroupId</groupId>
>   <artifactId>rootArtifactId</artifactId>
>   <packaging>pom</packaging>
>   <version>1.0-SNAPSHOT</version>
>
>   <modules>
>      <module>moduleA</module>
>      <module>moduleB</module>
>   </modules>
>
>   <dependencyManagement>
>      <dependencies>
>         <dependency>
>            <groupId>moduleAGroupId</groupId>
>            <artifactId>moduleAArtifactId</artifactId>
>            <version>1.0-SNAPSHOT</version>
>         </dependency>
>      </dependencies>
>   </dependencyManagement>
> </project
>
>
> pom.xml (module A)
> <project>
>   <parent>
>      <groupId>rootGroupId</groupId>
>      <artifactId>rootArtifactId</artifactId>
>      <version>1.0-SNAPSHOT</version>
>   </parent>
>   <groupId>moduleAGroupId</groupId>
>   <artifactId>moduleAArtifactId</artifactId>
> </project
>
>
> pom.xml (module B)
> <project>
>   <parent>
>      <groupId>rootGroupId</groupId>
>      <artifactId>rootArtifactId</artifactId>
>      <version>1.0-SNAPSHOT</version>
>   </parent>
>   <groupId>moduleBGroupId</groupId>
>   <artifactId>moduleBArtifactId</artifactId>
>
>   <dependencies>
>      <dependency>
>         <groupId>moduleAGroupId</groupId>
>         <artifactId>moduleAArtifactId</artifactId>
>         <version>1.0-SNAPSHOT</version>
>      </dependency>
>   </dependencies>
> </project
>
>
>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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 doesn't filter dependencies defined in pom

Posted by Pepe Perez <pp...@yahoo.com>.
using dependencyManagement would solve my problem for the dependencies, but due to my project requirements I still need to use a property in the parent <version>, which is not managed by dependencyManagement.

>From what I can see maven doesn't have any problem in replacing properties in the <parent> block of the current pom, but it does when it retrieves the pom of a dependency from the repo to which it was previously downloaded when building from the root. This pom taken from the repo has a property in the <parent> section, and contrary to what maven does for the current pom maven doesn't replace properties here.

My issue would be solve if the poms where installed into the maven repo with the properties already replaced by their value, or if it replaced properties in the poms retrieved from the repo to calculate transitive dependencies.



----- Original Message ----
From: Stephen Connolly <st...@gmail.com>
To: Maven Users List <us...@maven.apache.org>
Sent: Wed, October 28, 2009 11:30:37 PM
Subject: Re: maven doesn't filter dependencies defined in pom

2009/10/29 Stephen Connolly <st...@gmail.com>

> property substitution is not supported in
>
> /project(/parent)?/version
>
> 2009/10/29 Pepe Perez <pp...@yahoo.com>
>
> Hello,
>>
>> This is the situation I'm in.
>>
>> I have this structure
>>
>> pom.xml (root)
>> |_ pom.xml (module A)
>> |_ pom.xml (module B)
>>
>> These are (excerpts) of the poms
>>
>> pom.xml (root)
>>    <groupId>rootGroupId</groupId>
>>    <artifactId>rootArtifactId</artifactId>
>>    <packaging>pom</packaging>
>>    <version>${rootGroupId}</version>
>>
>>    <modules>
>>      <module>moduleA</module>
>>      <module>moduleB</module>
>>   </modules>
>>
>> <properties>
>>  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
>>  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
>>  <rootGroupId>rootVersion</rootGroupId>
>> </properties>
>>
>> pom (module A)
>>
>>    <parent>
>>        <groupId>rootGroupId</groupId>
>>        <artifactId>rootArtifactId</artifactId>
>>        <version>${rootGroupId}</version>
>>    </parent>
>>
>>
because maven does not know rootGroupId until it fetches the parent, it does
not know what parent to fetch, so it does not know moduleAGroupId either


>    <groupId>moduleAGroupId</groupId>
>>    <artifactId>moduleAArtifactId</artifactId>
>>    <packaging>pom</packaging>
>>    <version>${moduleAGroupId}</version>
>>
>> pom (module B)
>>
>>    <parent>
>>        <groupId>rootGroupId</groupId>
>>        <artifactId>rootArtifactId</artifactId>
>>        <version>${rootGroupId}</version>
>>    </parent>
>>
>>    <groupId>moduleBGroupId</groupId>
>>    <artifactId>moduleBArtifactId</artifactId>
>>    <packaging>pom</packaging>
>>    <version>${moduleBGroupId}</version>
>>
>>   <dependencies>
>>     <dependency>
>>         <groupId>moduleAGroupId</groupId>
>>         <artifactId>moduleAArtifactId</artifactId>
>>        <version>${moduleAGroupId}</version>
>>     <dependency>
>>  </dependency>
>>
>> cd root
>> mvn install
>>
>> ------------------------------------------------------------------------
>> [INFO] BUILD SUCCESSFUL
>> [INFO]
>> ------------------------------------------------------------------------
>>
>> cd moduleB
>> mvn install
>>
>> [WARNING] Unable to get resource
>> 'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
>> from repository central (http://repo1.maven.org/maven2): Error
>> transferring file: Server returned HTTP response code: 500 for URL:
>> http://<pom_maven_repo_location>
>> ------------------------------------------------------------------------
>> [ERROR] BUILD ERROR
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Error building POM (may not be this project's POM).
>>
>>
>> Project ID: moduleB
>>
>> Reason: Cannot find parent: moduleA pom for project: moduleB
>>
>> This is happening because when building moduleA its pom file is
>> installed in the maven repo without filtering, i.e, as it is with ${}.
>> When the pom is retrieved to satisfy moduleB dependency on moduleA it's
>> retrieved as
>>
>> <groupId>moduleAGroupId</groupId>
>> <artifactId>moduleAArtifactId</artifactId>
>> <packaging>pom</packaging>
>> <version>${moduleAGroupId}</version>
>>
>> where ${moduleAGroupId} is not instanciated, hence the error.
>>
>> My question is:
>> 1. Could I force maven to store the pom files **filtered** or
>> 2. How can maven be forced to instantiate ${moduleAGroupId} upon
>> retrieval from the maven repo so moduleB dependency can be satisfied
>> 3. What other alternative do I have to solve this scenario without
>> giving up using ${} in <version>
>>
>
why do you need to use properties for /project(/parent)?/version

if you use the release plugin, it will update those correctly, and as well
will likely update the dependencies for you.  It would seem to me that your
use case would be better served with a dependencyManagement section in the
root pom. then you can omit the version in the dependency sections of each
child pom such that the only versions specified are
in /project(/parent)?/version

Also, if you are going to release all of them in the same go, you should
note that /project/version is inherited from /project/parent/version

my solution would be as follows:

pom.xml (root)
<project>
   <groupId>rootGroupId</groupId>
   <artifactId>rootArtifactId</artifactId>
   <packaging>pom</packaging>
   <version>1.0-SNAPSHOT</version>

   <modules>
      <module>moduleA</module>
      <module>moduleB</module>
   </modules>

   <dependencyManagement>
      <dependencies>
         <dependency>
            <groupId>moduleAGroupId</groupId>
            <artifactId>moduleAArtifactId</artifactId>
            <version>1.0-SNAPSHOT</version>
         </dependency>
      </dependencies>
   </dependencyManagement>
</project


pom.xml (module A)
<project>
   <parent>
      <groupId>rootGroupId</groupId>
      <artifactId>rootArtifactId</artifactId>
      <version>1.0-SNAPSHOT</version>
   </parent>
   <groupId>moduleAGroupId</groupId>
   <artifactId>moduleAArtifactId</artifactId>
</project


pom.xml (module B)
<project>
   <parent>
      <groupId>rootGroupId</groupId>
      <artifactId>rootArtifactId</artifactId>
      <version>1.0-SNAPSHOT</version>
   </parent>
   <groupId>moduleBGroupId</groupId>
   <artifactId>moduleBArtifactId</artifactId>

   <dependencies>
      <dependency>
         <groupId>moduleAGroupId</groupId>
         <artifactId>moduleAArtifactId</artifactId>
         <version>1.0-SNAPSHOT</version>
      </dependency>
   </dependencies>
</project



>>
>>
>>
>> ---------------------------------------------------------------------
>> 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 doesn't filter dependencies defined in pom

Posted by Stephen Connolly <st...@gmail.com>.
2009/10/29 Stephen Connolly <st...@gmail.com>

> property substitution is not supported in
>
> /project(/parent)?/version
>
> 2009/10/29 Pepe Perez <pp...@yahoo.com>
>
> Hello,
>>
>> This is the situation I'm in.
>>
>> I have this structure
>>
>> pom.xml (root)
>> |_ pom.xml (module A)
>> |_ pom.xml (module B)
>>
>> These are (excerpts) of the poms
>>
>> pom.xml (root)
>>    <groupId>rootGroupId</groupId>
>>    <artifactId>rootArtifactId</artifactId>
>>    <packaging>pom</packaging>
>>    <version>${rootGroupId}</version>
>>
>>    <modules>
>>      <module>moduleA</module>
>>      <module>moduleB</module>
>>   </modules>
>>
>> <properties>
>>  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
>>  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
>>  <rootGroupId>rootVersion</rootGroupId>
>> </properties>
>>
>> pom (module A)
>>
>>    <parent>
>>        <groupId>rootGroupId</groupId>
>>        <artifactId>rootArtifactId</artifactId>
>>        <version>${rootGroupId}</version>
>>    </parent>
>>
>>
because maven does not know rootGroupId until it fetches the parent, it does
not know what parent to fetch, so it does not know moduleAGroupId either


>    <groupId>moduleAGroupId</groupId>
>>    <artifactId>moduleAArtifactId</artifactId>
>>    <packaging>pom</packaging>
>>    <version>${moduleAGroupId}</version>
>>
>> pom (module B)
>>
>>    <parent>
>>        <groupId>rootGroupId</groupId>
>>        <artifactId>rootArtifactId</artifactId>
>>        <version>${rootGroupId}</version>
>>    </parent>
>>
>>    <groupId>moduleBGroupId</groupId>
>>    <artifactId>moduleBArtifactId</artifactId>
>>    <packaging>pom</packaging>
>>    <version>${moduleBGroupId}</version>
>>
>>   <dependencies>
>>     <dependency>
>>         <groupId>moduleAGroupId</groupId>
>>         <artifactId>moduleAArtifactId</artifactId>
>>        <version>${moduleAGroupId}</version>
>>     <dependency>
>>  </dependency>
>>
>> cd root
>> mvn install
>>
>> ------------------------------------------------------------------------
>> [INFO] BUILD SUCCESSFUL
>> [INFO]
>> ------------------------------------------------------------------------
>>
>> cd moduleB
>> mvn install
>>
>> [WARNING] Unable to get resource
>> 'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
>> from repository central (http://repo1.maven.org/maven2): Error
>> transferring file: Server returned HTTP response code: 500 for URL:
>> http://<pom_maven_repo_location>
>> ------------------------------------------------------------------------
>> [ERROR] BUILD ERROR
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Error building POM (may not be this project's POM).
>>
>>
>> Project ID: moduleB
>>
>> Reason: Cannot find parent: moduleA pom for project: moduleB
>>
>> This is happening because when building moduleA its pom file is
>> installed in the maven repo without filtering, i.e, as it is with ${}.
>> When the pom is retrieved to satisfy moduleB dependency on moduleA it's
>> retrieved as
>>
>> <groupId>moduleAGroupId</groupId>
>> <artifactId>moduleAArtifactId</artifactId>
>> <packaging>pom</packaging>
>> <version>${moduleAGroupId}</version>
>>
>> where ${moduleAGroupId} is not instanciated, hence the error.
>>
>> My question is:
>> 1. Could I force maven to store the pom files **filtered** or
>> 2. How can maven be forced to instantiate ${moduleAGroupId} upon
>> retrieval from the maven repo so moduleB dependency can be satisfied
>> 3. What other alternative do I have to solve this scenario without
>> giving up using ${} in <version>
>>
>
why do you need to use properties for /project(/parent)?/version

if you use the release plugin, it will update those correctly, and as well
will likely update the dependencies for you.  It would seem to me that your
use case would be better served with a dependencyManagement section in the
root pom. then you can omit the version in the dependency sections of each
child pom such that the only versions specified are
in /project(/parent)?/version

Also, if you are going to release all of them in the same go, you should
note that /project/version is inherited from /project/parent/version

my solution would be as follows:

pom.xml (root)
<project>
   <groupId>rootGroupId</groupId>
   <artifactId>rootArtifactId</artifactId>
   <packaging>pom</packaging>
   <version>1.0-SNAPSHOT</version>

   <modules>
      <module>moduleA</module>
      <module>moduleB</module>
   </modules>

   <dependencyManagement>
      <dependencies>
         <dependency>
            <groupId>moduleAGroupId</groupId>
            <artifactId>moduleAArtifactId</artifactId>
            <version>1.0-SNAPSHOT</version>
         </dependency>
      </dependencies>
   </dependencyManagement>
</project


pom.xml (module A)
<project>
   <parent>
      <groupId>rootGroupId</groupId>
      <artifactId>rootArtifactId</artifactId>
      <version>1.0-SNAPSHOT</version>
   </parent>
   <groupId>moduleAGroupId</groupId>
   <artifactId>moduleAArtifactId</artifactId>
</project


pom.xml (module B)
<project>
   <parent>
      <groupId>rootGroupId</groupId>
      <artifactId>rootArtifactId</artifactId>
      <version>1.0-SNAPSHOT</version>
   </parent>
   <groupId>moduleBGroupId</groupId>
   <artifactId>moduleBArtifactId</artifactId>

   <dependencies>
      <dependency>
         <groupId>moduleAGroupId</groupId>
         <artifactId>moduleAArtifactId</artifactId>
         <version>1.0-SNAPSHOT</version>
      </dependency>
   </dependencies>
</project



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

Re: maven doesn't filter dependencies defined in pom

Posted by Stephen Connolly <st...@gmail.com>.
2009/10/29 Pepe Perez <pp...@yahoo.com>

> Stephen,
>
> I think it is... to some extent at least
>
> Both moduleA and moduleB have this parent block
>
> <parent>
>        <groupId>rootGroupId</groupId>
>        <artifactId>rootArtifactId</artifactId>
>        <version>${rootGroupId}</version>
> </parent>
>
> That following property <rootGroupId>rootVersion</rootGroupId> is correctly
> parsed into
>

actually that property is not parsed when building from the root...

(short answer, there is a more long and technical answer which you are not
interested in) ;-)

<parent>
>        <groupId>rootGroupId</groupId>
>        <artifactId>rootArtifactId</artifactId>
>         <version>rootVersion</version>
> </parent>
>
> which makes the build be successful if started from the root.
>
>
>
>
>
> ----- Original Message ----
> From: Stephen Connolly <st...@gmail.com>
> To: Maven Users List <us...@maven.apache.org>
> Sent: Wed, October 28, 2009 11:19:17 PM
> Subject: Re: maven doesn't filter dependencies defined in pom
>
> property substitution is not supported in
>
> /project(/parent)?/version
>
> 2009/10/29 Pepe Perez <pp...@yahoo.com>
>
> > Hello,
> >
> > This is the situation I'm in.
> >
> > I have this structure
> >
> > pom.xml (root)
> > |_ pom.xml (module A)
> > |_ pom.xml (module B)
> >
> > These are (excerpts) of the poms
> >
> > pom.xml (root)
> >    <groupId>rootGroupId</groupId>
> >    <artifactId>rootArtifactId</artifactId>
> >    <packaging>pom</packaging>
> >    <version>${rootGroupId}</version>
> >
> >    <modules>
> >      <module>moduleA</module>
> >      <module>moduleB</module>
> >   </modules>
> >
> > <properties>
> >  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
> >  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
> >  <rootGroupId>rootVersion</rootGroupId>
> > </properties>
> >
> > pom (module A)
> >
> >    <parent>
> >        <groupId>rootGroupId</groupId>
> >        <artifactId>rootArtifactId</artifactId>
> >        <version>${rootGroupId}</version>
> >    </parent>
> >
> >    <groupId>moduleAGroupId</groupId>
> >    <artifactId>moduleAArtifactId</artifactId>
> >    <packaging>pom</packaging>
> >    <version>${moduleAGroupId}</version>
> >
> > pom (module B)
> >
> >    <parent>
> >        <groupId>rootGroupId</groupId>
> >        <artifactId>rootArtifactId</artifactId>
> >        <version>${rootGroupId}</version>
> >    </parent>
> >
> >    <groupId>moduleBGroupId</groupId>
> >    <artifactId>moduleBArtifactId</artifactId>
> >    <packaging>pom</packaging>
> >    <version>${moduleBGroupId}</version>
> >
> >   <dependencies>
> >     <dependency>
> >         <groupId>moduleAGroupId</groupId>
> >         <artifactId>moduleAArtifactId</artifactId>
> >        <version>${moduleAGroupId}</version>
> >     <dependency>
> >  </dependency>
> >
> > cd root
> > mvn install
> >
> > ------------------------------------------------------------------------
> > [INFO] BUILD SUCCESSFUL
> > [INFO]
> > ------------------------------------------------------------------------
> >
> > cd moduleB
> > mvn install
> >
> > [WARNING] Unable to get resource
> > 'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
> > from repository central (http://repo1.maven.org/maven2): Error
> > transferring file: Server returned HTTP response code: 500 for URL:
> > http://<pom_maven_repo_location>
> > ------------------------------------------------------------------------
> > [ERROR] BUILD ERROR
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Error building POM (may not be this project's POM).
> >
> >
> > Project ID: moduleB
> >
> > Reason: Cannot find parent: moduleA pom for project: moduleB
> >
> > This is happening because when building moduleA its pom file is
> > installed in the maven repo without filtering, i.e, as it is with ${}.
> > When the pom is retrieved to satisfy moduleB dependency on moduleA it's
> > retrieved as
> >
> > <groupId>moduleAGroupId</groupId>
> > <artifactId>moduleAArtifactId</artifactId>
> > <packaging>pom</packaging>
> > <version>${moduleAGroupId}</version>
> >
> > where ${moduleAGroupId} is not instanciated, hence the error.
> >
> > My question is:
> > 1. Could I force maven to store the pom files **filtered** or
> > 2. How can maven be forced to instantiate ${moduleAGroupId} upon
> > retrieval from the maven repo so moduleB dependency can be satisfied
> > 3. What other alternative do I have to solve this scenario without
> > giving up using ${} in <version>
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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 doesn't filter dependencies defined in pom

Posted by Pepe Perez <pp...@yahoo.com>.
Stephen,

I think it is... to some extent at least

Both moduleA and moduleB have this parent block

<parent>
        <groupId>rootGroupId</groupId>
        <artifactId>rootArtifactId</artifactId>
        <version>${rootGroupId}</version>
</parent>

That following property <rootGroupId>rootVersion</rootGroupId> is correctly parsed into
<parent>
        <groupId>rootGroupId</groupId>
        <artifactId>rootArtifactId</artifactId>
        <version>rootVersion</version>
</parent>

which makes the build be successful if started from the root.





----- Original Message ----
From: Stephen Connolly <st...@gmail.com>
To: Maven Users List <us...@maven.apache.org>
Sent: Wed, October 28, 2009 11:19:17 PM
Subject: Re: maven doesn't filter dependencies defined in pom

property substitution is not supported in

/project(/parent)?/version

2009/10/29 Pepe Perez <pp...@yahoo.com>

> Hello,
>
> This is the situation I'm in.
>
> I have this structure
>
> pom.xml (root)
> |_ pom.xml (module A)
> |_ pom.xml (module B)
>
> These are (excerpts) of the poms
>
> pom.xml (root)
>    <groupId>rootGroupId</groupId>
>    <artifactId>rootArtifactId</artifactId>
>    <packaging>pom</packaging>
>    <version>${rootGroupId}</version>
>
>    <modules>
>      <module>moduleA</module>
>      <module>moduleB</module>
>   </modules>
>
> <properties>
>  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
>  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
>  <rootGroupId>rootVersion</rootGroupId>
> </properties>
>
> pom (module A)
>
>    <parent>
>        <groupId>rootGroupId</groupId>
>        <artifactId>rootArtifactId</artifactId>
>        <version>${rootGroupId}</version>
>    </parent>
>
>    <groupId>moduleAGroupId</groupId>
>    <artifactId>moduleAArtifactId</artifactId>
>    <packaging>pom</packaging>
>    <version>${moduleAGroupId}</version>
>
> pom (module B)
>
>    <parent>
>        <groupId>rootGroupId</groupId>
>        <artifactId>rootArtifactId</artifactId>
>        <version>${rootGroupId}</version>
>    </parent>
>
>    <groupId>moduleBGroupId</groupId>
>    <artifactId>moduleBArtifactId</artifactId>
>    <packaging>pom</packaging>
>    <version>${moduleBGroupId}</version>
>
>   <dependencies>
>     <dependency>
>         <groupId>moduleAGroupId</groupId>
>         <artifactId>moduleAArtifactId</artifactId>
>        <version>${moduleAGroupId}</version>
>     <dependency>
>  </dependency>
>
> cd root
> mvn install
>
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO]
> ------------------------------------------------------------------------
>
> cd moduleB
> mvn install
>
> [WARNING] Unable to get resource
> 'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
> from repository central (http://repo1.maven.org/maven2): Error
> transferring file: Server returned HTTP response code: 500 for URL:
> http://<pom_maven_repo_location>
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Error building POM (may not be this project's POM).
>
>
> Project ID: moduleB
>
> Reason: Cannot find parent: moduleA pom for project: moduleB
>
> This is happening because when building moduleA its pom file is
> installed in the maven repo without filtering, i.e, as it is with ${}.
> When the pom is retrieved to satisfy moduleB dependency on moduleA it's
> retrieved as
>
> <groupId>moduleAGroupId</groupId>
> <artifactId>moduleAArtifactId</artifactId>
> <packaging>pom</packaging>
> <version>${moduleAGroupId}</version>
>
> where ${moduleAGroupId} is not instanciated, hence the error.
>
> My question is:
> 1. Could I force maven to store the pom files **filtered** or
> 2. How can maven be forced to instantiate ${moduleAGroupId} upon
> retrieval from the maven repo so moduleB dependency can be satisfied
> 3. What other alternative do I have to solve this scenario without
> giving up using ${} in <version>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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 doesn't filter dependencies defined in pom

Posted by Stephen Connolly <st...@gmail.com>.
property substitution is not supported in

/project(/parent)?/version

2009/10/29 Pepe Perez <pp...@yahoo.com>

> Hello,
>
> This is the situation I'm in.
>
> I have this structure
>
> pom.xml (root)
> |_ pom.xml (module A)
> |_ pom.xml (module B)
>
> These are (excerpts) of the poms
>
> pom.xml (root)
>    <groupId>rootGroupId</groupId>
>    <artifactId>rootArtifactId</artifactId>
>    <packaging>pom</packaging>
>    <version>${rootGroupId}</version>
>
>    <modules>
>      <module>moduleA</module>
>      <module>moduleB</module>
>   </modules>
>
> <properties>
>  <moduleAGroupId>1.0-SNAPSHOT</moduleAGroupId>
>  <moduleBGroupId>1.0-SNAPSHOT</moduleBGroupId>
>  <rootGroupId>rootVersion</rootGroupId>
> </properties>
>
> pom (module A)
>
>    <parent>
>        <groupId>rootGroupId</groupId>
>        <artifactId>rootArtifactId</artifactId>
>        <version>${rootGroupId}</version>
>    </parent>
>
>    <groupId>moduleAGroupId</groupId>
>    <artifactId>moduleAArtifactId</artifactId>
>    <packaging>pom</packaging>
>    <version>${moduleAGroupId}</version>
>
> pom (module B)
>
>    <parent>
>        <groupId>rootGroupId</groupId>
>        <artifactId>rootArtifactId</artifactId>
>        <version>${rootGroupId}</version>
>    </parent>
>
>    <groupId>moduleBGroupId</groupId>
>    <artifactId>moduleBArtifactId</artifactId>
>    <packaging>pom</packaging>
>    <version>${moduleBGroupId}</version>
>
>   <dependencies>
>     <dependency>
>         <groupId>moduleAGroupId</groupId>
>         <artifactId>moduleAArtifactId</artifactId>
>        <version>${moduleAGroupId}</version>
>     <dependency>
>  </dependency>
>
> cd root
> mvn install
>
> ------------------------------------------------------------------------
> [INFO] BUILD SUCCESSFUL
> [INFO]
> ------------------------------------------------------------------------
>
> cd moduleB
> mvn install
>
> [WARNING] Unable to get resource
> 'moduleAGroupId:moduleAArtifactId:${moduleAGroupId}'
> from repository central (http://repo1.maven.org/maven2): Error
> transferring file: Server returned HTTP response code: 500 for URL:
> http://<pom_maven_repo_location>
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Error building POM (may not be this project's POM).
>
>
> Project ID: moduleB
>
> Reason: Cannot find parent: moduleA pom for project: moduleB
>
> This is happening because when building moduleA its pom file is
> installed in the maven repo without filtering, i.e, as it is with ${}.
> When the pom is retrieved to satisfy moduleB dependency on moduleA it's
> retrieved as
>
> <groupId>moduleAGroupId</groupId>
> <artifactId>moduleAArtifactId</artifactId>
> <packaging>pom</packaging>
> <version>${moduleAGroupId}</version>
>
> where ${moduleAGroupId} is not instanciated, hence the error.
>
> My question is:
> 1. Could I force maven to store the pom files **filtered** or
> 2. How can maven be forced to instantiate ${moduleAGroupId} upon
> retrieval from the maven repo so moduleB dependency can be satisfied
> 3. What other alternative do I have to solve this scenario without
> giving up using ${} in <version>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>