[ 
https://issues.apache.org/jira/browse/MNG-5415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14952053#comment-14952053
 ] 

Michael Osipov commented on MNG-5415:
-------------------------------------

I have tested this with 3.3.7-SNAPSHOT and here are my results: During the 
build, the POM is read, validator runs, interpolation is applied and 
dependencies are merged. The actually problem is that if you have 
{{${my.type}}}, the validator operates on a static model. Passes this 
through interpolation and models are merged. Now during that all dependencies 
pass through a map where the key is {{groupId:artifactId:type:classifier}} 
{{optional}} is not relevant. Since both deps have the same key, the last one 
wins and the first has no version set. You lose. If you use literals, both 
dependencies are merged because they have the same IDs ({{mergeDuplicates}}). 
You lose too.

You have found a corner case. What do you expect to happen here? {{optional}} 
does not qualify the dependency itself.

> Duplicate dependency with property causes the build to fail
> -----------------------------------------------------------
>
>                 Key: MNG-5415
>                 URL: https://issues.apache.org/jira/browse/MNG-5415
>             Project: Maven
>          Issue Type: Bug
>          Components: Plugins and Lifecycle
>    Affects Versions: 3.0.3, 3.0.4
>         Environment: $ mvn -version
> Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
> Maven home: /usr/share/maven
> Java version: 1.7.0_09, vendor: Oracle Corporation
> Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "mac os x", version: "10.8.2", arch: "x86_64", family: "mac"
>            Reporter: Tarje Killingberg
>         Attachments: my-app.zip
>
>
> The following excerpt from a _pom.xml_ file causes just about any maven 
> command (e.g. {{mvn package}}) to fail with the error 
> _'dependencies.dependency.version' for junit:junit:jar is missing_:
> {code}
> <properties>
>     <my.type>jar</my.type>
>     <my.other.type>jar</my.other.type>
> </properties>
> <dependencyManagement>
>     <dependencies>
>         <dependency>
>             <groupId>junit</groupId>
>             <artifactId>junit</artifactId>
>             <version>4.10</version>
>             <type>${my.type}</type>
>         </dependency>
>         <dependency>
>             <artifactId>junit</artifactId>
>             <groupId>junit</groupId>
>             <version>4.10</version>
>             <type>${my.other.type}</type>
>         </dependency>
>     </dependencies>
> </dependencyManagement>
> <dependencies>
>     <dependency>
>         <artifactId>junit</artifactId>
>         <groupId>junit</groupId>
>         <type>${my.type}</type>
>     </dependency>
>     <dependency>
>         <artifactId>junit</artifactId>
>         <groupId>junit</groupId>
>         <type>${my.other.type}</type>
>         <optional>true</optional>
>     </dependency>
> </dependencies>
> {code}
> If the string _jar_ is used instead of the properties, the build succeeds 
> with warnings.
> A SSCCE is attached. Running the command {{mvn validate}} inside the 
> _my-app_-folder should show the symptom.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to