Is it possible to override the imported Maven dependency in the same pom.xml?

I work in an application server environment in which I use bom to collect dependency information, for example:

        <dependency>
            <groupId>org.jboss.bom.eap</groupId>
            <artifactId>jboss-javaee-6.0-with-security</artifactId>
            <version>${jboss.bom.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

However, this particular bom indicates the dependency as "compilation", which I want to cover with all my projects as "provided". However, when I try to override the area in the same folder from which I import the dependency, for example:

        <dependency>
            <groupId>org.picketlink</groupId>
            <artifactId>picketlink-federation</artifactId>
            <scope>provided</scope>
        </dependency>

Maven complains that it cannot find the version, or if I use the version property specified in bom, the property cannot be found.

I am sure that this is a problem with import + overriding in the same pom, because I can perfectly undo scope in child projects. Is there a way to import and redefine a region in one pom?

* .

+4
1

, , :

<dependencyManagement>
   ...
   <dependency>
     <groupId>org.jboss.bom.eap</groupId>
     <artifactId>jboss-javaee-6.0-with-security</artifactId>
     <version>${jboss.bom.version}</version>
     <type>pom</type>
     <scope>import</scope>
   </dependency>
   ...
</dependencyManagement>
<dependencies>
   ...
   <dependency>
     <groupId>org.picketlink</groupId>
     <artifactId>picketlink-federation</artifactId>
     <scope>provided</scope>
   </dependency>
</dependencies>

, <dependencies> <dependencyManagement>.

, , POM, .

0

Source: https://habr.com/ru/post/1614489/


All Articles