cnu
cnu

Reputation: 477

How to update Maven3 dependencies in a jenkins Continuous integration environment?

I am using Maven 3 to build my java EAR and Jenkins as CI tool. My maven project is multi-module project that builds a jar, war and EAR. I am using maven-version-plugin:use-latest-versions goal to update the war dependency in my EAR POM during clean phase. This updates war dependency version to latest(19.3) version in EAR POM but fails to package the latest WAR(19.3) to EAR. Maven is using the old version(19.2) of WAR during EAR packaging.How do I configure maven to use latest built dependency? Thank you in advance

Jenkins Console Output

 --- maven-clean-plugin:2.5:clean (default-clean) @ EAR ---
    [INFO] Deleting EAR\target
    [INFO] 
    [INFO] --- versions-maven-plugin:2.1:use-latest-versions (update-dependency-versions) @ EAR ---
    [INFO] Major version changes allowed
    Props: {project.version=19.3-SNAPSHOT, project.artifactId=EAR, project.groupId=gov.dwd.uplink}

   **Updating dependency version from 19.2 to 19.3 in EAR POM**

    **[INFO] Updated groupId:App:war:19.2-SNAPSHOT to version 19.3-SNAPSHOT**
    [INFO] 
    [INFO] --- maven-ear-plugin:2.8:generate-application-xml (default-generate-application-xml) @ AppEAR ---
    [INFO] Generating application.xml
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ AppEAR ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory EAR\src\main\resources
    [INFO] 
    [INFO] --- maven-ear-plugin:2.8:ear (default-ear) @ AppEAR ---

    **[INFO]Copying artifact [war:groupid:App:19.2-SNAPSHOT] to [App.war]**

         This should copy 19.3 not 19.2 version

    [INFO] Could not find manifest file: AppEAR\target\AppEAR-19.3-SNAPSHOT\META-INF\MANIFEST.MF - Generatingone
    [INFO] Building jar: AppEAR\target\App.ear
    [INFO] 
    [INFO] --- maven-install-plugin:2.4:install (default-install) @ AppEAR ---
    [INFO] Installing AppEAR\target\App.ear to maven_repo2\GroupID\AppEAR\19.3-SNAPSHOT\AppEAR-19.3-SNAPSHOT.ear
    [INFO] Installing AppEAR\pom.xml to D:\CCViews\maven_repo2\GroupID\AppEAR\19.3-SNAPSHOT\AppEAR-19.3-SNAPSHOT.pom
    [INFO] 
    [JENKINS] Archiving disabled
    [JENKINS] Archiving disabled
    [JENKINS] Archiving disabled
    [JENKINS] Archiving disabled

Upvotes: 0

Views: 2075

Answers (1)

cnu
cnu

Reputation: 477

Here is how I fixed my issue with incrementing dependency versions.

I used maven-version-plugin:update-versions to increment the POM version number. Then for dependencies version I used ${project.version}. This keeps POM versions's and dependencies always in sync which helps in CI environment.

Please post if you have a better solution.

Upvotes: 0

Related Questions