Will Maven download the new SNAPSHOT jar to replace the jar that was just created in one assembly?

Suppose our assembly is dedicated to creating modules from A to Z. All version elements in the pom files for these projects are set to -SNAPSHOT.

When we create the pom file, maven starts with project A, then goes to B, and then finally reaches project Z. If Z depends on A, does maven execute remote repo for the last A-SNAPSHOT.jar and potentially replace A-SNAPSHOT .jar that was just created as part of the same assembly in the A / target / and / or local Maven repository ?

I think I -ocan avoid the scenario described above, but I just wanted to understand.

Is it possible to set -oIDs for a specific group to avoid unclear errors that may occur in the scenario described above.

Is it possible to configure the assembly in such a way as to load any artifacts not available in the local repo, but not replace the existing ones.

+4
source share
4 answers

No, projects in a reactor will always be preferable to other dependencies.

This is done even regardless of the following circumstances:

  • Running Maven with the flag set -U, which means that checking for updates is mandatory.
  • Installation <updatePolicy>in alwaysin settings.xmlor in POM.
  • Plugin setup installon<installAtEnd>true</installAtEnd>

Maven , .

. Maven , , Maven A (), .

, , POM:

<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>root</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>root</name>
  <modules>
    <module>A</module>
    <module>B</module>
    ...
    <module>Z</module>
  </modules>
</project>

:

<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>
  <parent>
    <groupId>org.example</groupId>
    <artifactId>root</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <name>...</name>
  <artifactId>...</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
</project>

:

<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>
  <parent>
    <groupId>org.example</groupId>
    <artifactId>root</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <artifactId>Z</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>Z</name>
  <dependencies>
    <dependency>
      <groupId>org.example</groupId>
      <artifactId>A</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
</project>

, A .

+2

Daniel, Maven 2 3, :

  • () , " " "",
  • , ,
  • , , .

, , , , : no, Maven SNAPSHOT, .

: MavenProject, DefaultArtifactResolver, DefaultArtifactResolver.

+1

question, :

Maven . , ( settings.xml pom.xml) . , .

, foo-1.0.jar , Maven , .

, foo-1.0-SNAPSHOT.jar, Maven , . Maven , . . , foo-1.0-20110506.110000-1.jar(.. 2011/05/06 11:00:00) , Maven, Maven .

, . updatePolicy, snapshot.

:

updatePolicy

- "", "" ( ), ": XXX" ( ) "", ( ).

Julien Carsique .

0

, , SNAPSHOTS, , , . ,

  • maven , .m2/repository . ( , . :))
  • API A, Z
  • Run assembly. It should crash when building Z if my line of thinking is correct. You have not changed the remote artifact, and there is nothing in the repository (since you moved it in the previous step). If it succeeds, this (my) answer is incorrect. Please leave a comment and / or skip my answer, so I will also find out.
  • Restore the original repository folder if you need to
  • Revert API change to A.

Hope this helps.

0
source

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


All Articles