You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2022/02/20 19:15:00 UTC

[jira] [Commented] (MNG-6564) Lack of ability to overwrite properties of specified dependencies

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

Michael Osipov commented on MNG-6564:
-------------------------------------

This is basically explained in MNG-7417. The issue is here is that you want a model property to be propagated to {{DefaultArtifactDescriptorReader}} which builds the {{ModelBuildingRequest}}. This is not possible because the "caller" model is not available in this context, thus its model properties aren't. The session is created here: {{org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory.newRepositorySession(MavenExecutionRequest)}} which you can see is the {{MavenExecutionRequest}}, thus no model exists here. Moreover, Resolver knows nothing about Maven models, it knows about artifacts and dependencies, so no notion available. I have currently no idea how to solve this cleanly. A hack would be to merge the model properties into the user properties. A viable alternative you have now with MNG-7417 to put these versions into {{.mvn/maven.config}} and it will resolve what you want.

[~cstamas], do you see a clean way to pass on model properties?

> Lack of ability to overwrite properties of specified dependencies
> -----------------------------------------------------------------
>
>                 Key: MNG-6564
>                 URL: https://issues.apache.org/jira/browse/MNG-6564
>             Project: Maven
>          Issue Type: New Feature
>          Components: Dependencies
>    Affects Versions: 3.3.9
>            Reporter: Rik Schaaf
>            Priority: Major
>
> For example, if I want to update the flyway version to 4.2.0 in spring boot 1.5 (by default Flyway 3.2.1) I want to do something like this: 
> {code:xml}
> <properties>
>   <flyway.version>4.2.0</flyway.version>
>   <springboot.version>1.5.17.RELEASE</springboot.version>
> </properties>
> <dependencyManagement>
>   <dependencies>
>     <dependency>
>       <groupId>org.springframework.boot</groupId>
>       <artifactId>spring-boot-dependencies</artifactId>
>       <version>${springboot.version}</version>
>       <type>pom</type>
>       <scope>import</scope>
>     </dependency>
>   <dependencies>
> </dependencyManagement>
> {code}
> The flyway dependency is already defined in the dependency management of spring-boot-dependencies:
> {code:xml}
> <dependency>
>   <groupId>org.flywaydb</groupId>
>   <artifactId>flyway-core</artifactId>
>   <version>${flyway.version}</version>
> </dependency>
> {code}
> But that same pom also defines flyway.version to be 3.2.1. When I include the flyway dependency in my own dependency management, my application does correctly use Flyway 4.2.0, but if I only provide the property, it incorrectly uses version 3.2.1, meaning that my property was ignored. I have heard from others that you can forcefully override a property by using a commandline parameter or an environment variable, but I would prefer to use a property in my pom file instead.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)