versions:use-latest-versions and dependency:copy-dependencies

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

versions:use-latest-versions and dependency:copy-dependencies

Anders Nyström
Hi,

I am using versions:use-latest-versions in an early phase
(generate-sources) in my maven build and it works nice. It updates the
versions I want, but when I use it together with
dependency:copy-dependencies that I have in a later phase
(process-resources) of my maven build something gets wrong. The dependency
copied is the dependency version used before it was updated with
versions:use-latest-versions. Its impossible to fix this in the pom and the
only way to solve it is to have it in two different commandes. like for eg
mvn clean versions:use-latest-versions && mvn install, this is not good
because its needs to be done in two different steps. I want the simplest
possible command like mvn clean install only.

In pom:
<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.7</version>
            <configuration>

<rulesUri>file:///${session.executionRootDirectory}/config/maven-version-rules.xml</rulesUri>

            </configuration>
            <executions>
               <execution>
                  <phase>generate-sources</phase>
                  <goals>
                     <goal>use-latest-versions</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
.....
        <plugin>
            <version>3.1.1</version>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
               <execution>
                  <id>copy-dependencies</id>
                  <phase>process-resources</phase>
                  <goals>
                     <goal>copy-dependencies</goal>
                  </goals>
                  <configuration>

<outputDirectory>${project.distribution.directory}</outputDirectory>
                     <overWriteReleases>true</overWriteReleases>
                     <overWriteSnapshots>true</overWriteSnapshots>
                  </configuration>
               </execution>
            </executions>
         </plugin>
...
Output:
[INFO] --- versions-maven-plugin:2.7:use-latest-versions (default) @ kalle
---
[INFO] Major version changes allowed
[INFO] artifact se.apa:olle: checking for updates from development
[INFO] Updated se.apa:olle:jar:2019.1.9559-280 to version 2019.1.9572-287
.....
Later in output:
[INFO] --- maven-dependency-plugin:3.1.1:copy-dependencies
(copy-dependencies) @ kalle ---
[INFO] Copying olle-2019.1.9559-280.jar to
/home/pelle/workspace/develop2/kalle/distribution/olle-2019.1.9559-280.jar

As you can see its copying the old version (2019.1.9559-280) and not the
new one (2019.1.9572-287). My guess is that maven-dependency-plugin reads
the pom to earlie? It should read it first in the phase its executed in. So
the correct dependencies is copied. Or is there any other way to solve this?

Regards
Anders