Re: Dealing with maven transitive dependencies
Re: Dealing with maven transitive dependencies
- Subject: Re: Dealing with maven transitive dependencies
- From: Lachlan Deck <email@hidden>
- Date: Thu, 18 Mar 2010 09:07:48 +1100
On 18/03/2010, at 3:48 AM, Henrique Prange wrote:
> Hi Frédéric,
>
> You can use the Maven dependency plug-in to analyze your pom and check which dependencies are required but not declared. Just run the following command:
>
> mvn clean dependency:analyze
>
> Cheers,
>
> Henrique
>
> On 17/03/10 13:30, Frédéric JECKER wrote:
>> Sorry for the little off-topic post, but maybe if I'm lucky, someone on
>> the list already solved the problem.
>> So I'm mavenizing a huge app with a lot of frameworks.
>> Some of them are core frameworks other frameworks rely on.
>> i.e :
>> Framework A depends on commons-lang
>> Framework B depends on Framework A and also on commons-lang
>>
>> If in the pom of Framework B I omit to declare the dependency on
>> commons-lang, the framework will compile without complaining
>> because at compile time, commons-lang will be provided by Framework A.
Naturally. It's a transient dependency, which is good.
>> This works nice but, I'd like my sub-pom to be the more precise as
>> possible so that they declare every dependency they need.
Then if that's what you really want: declare the dependency and put <scope>provided</scope>. The pom serves as intentional documentation also.
>> The problem is that with 42 frameworks to mavenize I'm going nuts.
>> I'd like to configure maven to ignore transitive dependencies so that if
>> a sub-pom is incomplete the build fails.
Seems like a strange requirement. You could temporarily rip out the dependency from framework 'A' and just try packaging or installing 'B', but Henrique's advice is better :)
>> I tried to disable the transitive dependencies using the following
>> configuration but it doesn't seem to work :
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-dependency-plugin</artifactId>
>> <executions>
>> <execution>
>> <id>resolve</id>
>> <phase>compile</phase>
>> <goals>
>> <goal>resolve</goal>
>> </goals>
>> <configuration>
>> <excludeTransitive>true</excludeTransitive>
>> </configuration>
>> </execution>
>> </executions>
>> </plugin>
Why are you doing this? Is this an organisationally pushed requirement?... "What if someone forgets..."
I prefer the minimal approach (it's still carefully considered mind you) that stems from OO principles of inheritance :) Do it once and override only if necessary.
So things you can do instead:
- assuming all your frameworks depend on commons-lang, for example, put all your frameworks under 'frameworks' and in their parent pom, frameworks/pom.xml, declare dependency on commons-lang and in your trunk/pom.xml (or corporate pom) place commons-lang in dependency management with scope compile.
- OR, assuming all your stuff will use commons-lang declare it in the upper-most parent pom. e.g., JUnit with scope test can go there.
- OR, if you have a base framework, BaseFramework, that most other things will use declare it there.
Just like inheritance, it will complain when things are missing that were previously assumed to have been there. Should make your life much easier I would have thought.
with regards,
--
Lachlan Deck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden