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

Tamas Cservenak commented on MNG-7842:
--------------------------------------

POM XML is "just" persisted model (oversimplified), and Maven tries to build 
Model from it. 

Think about it like you have invalid XML and you are DOM parsing it: it fails, 
and you will not have "partially parsed" XML... but just an error. Maven as 
well, want's to build "model", but it cannot, as POM is invalid and whole unit 
is tossed.

Maven does not consider "partial models", it considers "model" that is 
successfully built (and validated).

For example, downloaded the POM and tried to _build_ it, Maven clearly says the 
error:
{noformat}
[cstamas@urnebes Downloads]$ mvn -f ApacheJMeter_core-5.6.1.pom.xml  validate
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for 
com.google.auto.service:auto-service-annotations:jar is missing. @ line 134, 
column 17
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.apache.jmeter:ApacheJMeter_core:5.6.1 
(/home/cstamas/Downloads/repo.maven.apache.org_maven2_org_apache_jmeter_ApacheJMeter_core_5.6.1_ApacheJMeter_core-5.6.1.pom.xml)
 has 1 error
[ERROR]     'dependencies.dependency.version' for 
com.google.auto.service:auto-service-annotations:jar is missing. @ line 134, 
column 17
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[cstamas@urnebes Downloads]$ 
{noformat}

> Keep using transitive dependencies even if one of the declarations misses a 
> version
> -----------------------------------------------------------------------------------
>
>                 Key: MNG-7842
>                 URL: https://issues.apache.org/jira/browse/MNG-7842
>             Project: Maven
>          Issue Type: Improvement
>          Components: Core, Dependencies
>            Reporter: Vladimir Sitnikov
>            Priority: Major
>
> I have a problem that Maven discards **all** transitive dependencies when a 
> single of them misses {{<version>}}. It breaks workflows, and it is not clear 
> why Maven behaves like that.
> I'm using Maven 3.8.6.
> Sample:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>org.example</groupId>
>     <artifactId>TestBugMaven</artifactId>
>     <version>1.0-SNAPSHOT</version>
>     <properties>
>         <maven.compiler.source>17</maven.compiler.source>
>         <maven.compiler.target>17</maven.compiler.target>
>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>     </properties>
>     <dependencies>
>         <dependency>
>             <groupId>org.apache.jmeter</groupId>
>             <artifactId>ApacheJMeter_core</artifactId>
>             <version>5.6.1</version>
>         </dependency>
>     </dependencies>
> </project>
> {code}
> Test: {{mvn dependency:tree}}
> Output:
> {noformat}
> [WARNING] The POM for org.apache.jmeter:ApacheJMeter_core:jar:5.6.1 is 
> invalid, transitive dependencies (if any) will not be available, enable debug 
> logging for more details
> [INFO]
> [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ TestBugMaven ---
> [INFO] org.example:TestBugMaven:jar:1.0-SNAPSHOT
> [INFO] \- org.apache.jmeter:ApacheJMeter_core:jar:5.6.1:compile
> {noformat}
> Frankly speaking, I do not understand why Maven discards ALL transitive 
> dependencies in case it observes a single one with "missing version".
> Note: adding {{dependencyManagement}} does not seem to fix the case, so it is 
> even more confusing.
> The following still discards transitive dependencies:
> {code:xml}
> <dependencyManagement>
>   <dependencies>
>     <dependency>
>       <groupId>com.google.auto.service</groupId>
>       <artifactId>auto-service-annotations</artifactId>
>       <scope>compile</scope>
>       <version>1.1.1</version>
>     </dependency>
>   </dependencies>
> </dependencyManagement>
>     <dependencies>
>         <dependency>
>             <groupId>org.apache.jmeter</groupId>
>             <artifactId>ApacheJMeter_core</artifactId>
>             <version>5.6.1</version>
>         </dependency>
>     </dependencies>
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to