You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lachlan Deck <la...@gmail.com> on 2008/04/24 05:02:19 UTC
dependencyManagement help
Hi there,
I'm trying to utilise dependency management but am obviously missing
something.
I've got
/pom.xml
/frameworks/pom.xml
/frameworks/fwk1
...
/frameworks/fwkN
/app1/pom.xml
-- root parent pom --
<dependencyManagement>
<dependencies>
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<type>...</type>
<version>...</version>
</dependency>
</dependencies>
</dependencyManagement>
-- /frameworks/pom.xml --
<dependencies>
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
And so forth. Previously I had no dependencyManagement at all. So the
only mention of the version of a dependency is in the management
section. However, now when I do a 'mvn clean' I get the following.
What am I missing? Thanks.
Obviously - adding the version to the /frameworks/pom.xml's
dependencies works but I thought that was the whole idea behind the
dependencyManagement declarations in the parent pom? Or is that only
relevant for child poms where the packaging is not of type pom?
$ mvn clean
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: foo.bar:frameworks
POM Location: <...>/foobar/frameworks/pom.xml
Validation Messages:
[0] 'dependencies.dependency.version' is missing for <...>
[1] 'dependencies.dependency.version' is missing for <...>
[2] 'dependencies.dependency.version' is missing for <...>
[3] 'dependencies.dependency.version' is missing for <...>
Reason: Failed to validate POM for project foo.bar:frameworks at <...>/
foobar/frameworks/pom.xml
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.reactor.MavenExecutionException: Failed to validate
POM for project foo.bar:frameworks at <...>/foobar/frameworks/pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:376)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:289)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:
430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
with regards,
--
Lachlan Deck
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: dependencyManagement help
Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
>Then I'm not seeing what purpose the dependencyManagement section
>serves if I've still gotta declare pretty much everything apart from
>'version' in other dependency declarations?
The group/artifact/classifier/type are part of the identifier and those
must match. The scope and version can be centrally controlled in the
depMgt section and this saves you from having potentially conflicting
versions in multiple modules. It also makes it easier to upgrade later.
Additionally, depMgt will also override any transitive dependency
versions (even if you don't directly use them) so it's a way to manage
those as well.
----------------------
Brian Fox
Apache Maven PMC
http://blogs.sonatype.com/brian/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: dependencyManagement help
Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Lachlan Deck wrote:
> Hi there,
>
> On 24/04/2008, at 4:37 PM, Jörg Schaible wrote:
>
>>> -- root parent pom --
>>> <dependencyManagement>
>>> <dependencies>
>>> <dependency>
>>> <groupId>...</groupId>
>>> <artifactId>...</artifactId>
>>> <type>...</type>
>>> <version>...</version>
>>> </dependency>
>>> </dependencies>
>>> </dependencyManagement>
>>>
>>> -- /frameworks/pom.xml --
>>> <dependencies>
>>> <dependency>
>>> <groupId>...</groupId>
>>> <artifactId>...</artifactId>
>>> <scope>provided</scope>
>>> </dependency>
>>> </dependencies>
>>>
>>> And so forth. Previously I had no dependencyManagement at
>>> all. So the
>>> only mention of the version of a dependency is in the management
>>> section. However, now when I do a 'mvn clean' I get the following.
>>
>> The two artifacts to not match. An artifact is defined by groupId,
>> artifactId, type and optional classifier. The type defaults to
>> "jar". This might give you an idea ;-)
>
> Then I'm not seeing what purpose the dependencyManagement section
> serves if I've still gotta declare pretty much everything apart from
> 'version' in other dependency declarations?
You "inherit" version and scope. "scope" ensures that the artifact is used in the proper way and "version" will ensure that it is used everywhere in the right version.
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: dependencyManagement help
Posted by Bernhard David <da...@elca.ch>.
Hello,
I think dep.mgmt. is meant to declare "if an artifact with this groupId/artifactId appears somewhere in the dependency tree, include the version stated here; but don't include it by default".
For instance, if your module A depends on module B which in turn depends on module C 1.0 but you'd like to use C 2.0, you can put it in A's dependencyManagement. This is probably good practice as C is not a direct dependency of A. (In particular, if a new version of B comes out that no longer requires C, C will be dropped altogether and not included from A).
Greetings,
David
> -----Original Message-----
> From: Lachlan Deck [mailto:lachlan.deck@gmail.com]
> Sent: 24 April 2008 08:55
> To: Maven Users List
> Subject: Re: dependencyManagement help
>
> Hi there,
>
> On 24/04/2008, at 4:37 PM, Jörg Schaible wrote:
>
> >> -- root parent pom --
> >> <dependencyManagement>
> >> <dependencies>
> >> <dependency>
> >> <groupId>...</groupId>
> >> <artifactId>...</artifactId>
> >> <type>...</type>
> >> <version>...</version>
> >> </dependency>
> >> </dependencies>
> >> </dependencyManagement>
> >>
> >> -- /frameworks/pom.xml --
> >> <dependencies>
> >> <dependency>
> >> <groupId>...</groupId>
> >> <artifactId>...</artifactId>
> >> <scope>provided</scope>
> >> </dependency>
> >> </dependencies>
> >>
> >> And so forth. Previously I had no dependencyManagement at
> >> all. So the
> >> only mention of the version of a dependency is in the management
> >> section. However, now when I do a 'mvn clean' I get the following.
> >
> > The two artifacts to not match. An artifact is defined by groupId,
> > artifactId, type and optional classifier. The type defaults to
> > "jar". This might give you an idea ;-)
>
> Then I'm not seeing what purpose the dependencyManagement section
> serves if I've still gotta declare pretty much everything apart from
> 'version' in other dependency declarations?
>
> with regards,
> --
>
> Lachlan Deck
>
>
>
>
> ---------------------------------------------------------------------
> 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: dependencyManagement help
Posted by Lachlan Deck <la...@gmail.com>.
Hi there,
On 24/04/2008, at 4:37 PM, Jörg Schaible wrote:
>> -- root parent pom --
>> <dependencyManagement>
>> <dependencies>
>> <dependency>
>> <groupId>...</groupId>
>> <artifactId>...</artifactId>
>> <type>...</type>
>> <version>...</version>
>> </dependency>
>> </dependencies>
>> </dependencyManagement>
>>
>> -- /frameworks/pom.xml --
>> <dependencies>
>> <dependency>
>> <groupId>...</groupId>
>> <artifactId>...</artifactId>
>> <scope>provided</scope>
>> </dependency>
>> </dependencies>
>>
>> And so forth. Previously I had no dependencyManagement at
>> all. So the
>> only mention of the version of a dependency is in the management
>> section. However, now when I do a 'mvn clean' I get the following.
>
> The two artifacts to not match. An artifact is defined by groupId,
> artifactId, type and optional classifier. The type defaults to
> "jar". This might give you an idea ;-)
Then I'm not seeing what purpose the dependencyManagement section
serves if I've still gotta declare pretty much everything apart from
'version' in other dependency declarations?
with regards,
--
Lachlan Deck
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: dependencyManagement help
Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Lachlan Deck wrote:
> Hi there,
>
> I'm trying to utilise dependency management but am obviously missing
> something.
>
> I've got
> /pom.xml
> /frameworks/pom.xml
> /frameworks/fwk1
> ...
> /frameworks/fwkN
> /app1/pom.xml
>
> -- root parent pom --
> <dependencyManagement>
> <dependencies>
> <dependency>
> <groupId>...</groupId>
> <artifactId>...</artifactId>
> <type>...</type>
> <version>...</version>
> </dependency>
> </dependencies>
> </dependencyManagement>
>
> -- /frameworks/pom.xml --
> <dependencies>
> <dependency>
> <groupId>...</groupId>
> <artifactId>...</artifactId>
> <scope>provided</scope>
> </dependency>
> </dependencies>
>
> And so forth. Previously I had no dependencyManagement at
> all. So the
> only mention of the version of a dependency is in the management
> section. However, now when I do a 'mvn clean' I get the following.
The two artifacts to not match. An artifact is defined by groupId, artifactId, type and optional classifier. The type defaults to "jar". This might give you an idea ;-)
[snip]
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org