DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Mastering Git
  • Private Remote Maven Repository With Artipie
  • How To Convert Image Files Into GIF or WebP Format Using Java
  • How To Validate Names Using Java

Trending

  • Your Ultimate Website QA Checklist
  • Platform Engineering for Cloud Teams
  • Build Your First AI Model in Python: A Beginner's Guide (1 of 3)
  • Beyond Linguistics: Real-Time Domain Event Mapping with WebSocket and Spring Boot
  1. DZone
  2. Data Engineering
  3. Databases
  4. Using Maven's -U Command Line Option

Using Maven's -U Command Line Option

My prefered solution was to use the Maven ‘update snapshots’ command line argument.

By 
Roger Hughes user avatar
Roger Hughes
·
Mar. 11, 12 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
104.6K Views

Join the DZone community and get the full member experience.

Join For Free

In my experience when working on a multi-model project, the developers on that project tend to grab hold of all the project’s source code and build it all using some kind of Maven build-all POM project. You know the sort of thing I mean: a build-all module is a module that contains a list of other modules that get built is a specific order. I use one to build the CaptainDebug github samples and it looks like this:

<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>com.captaindebug</groupId>
 <artifactId>build-all</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>pom</packaging>
 <name>The Build All Pom File</name>
 <description>Pom file that co-ordinates the whole build</description>
 <modules>
  <module>../dependency-injection-factory</module>
  <module>../powermock-tips</module>
  <module>../address</module>
  <module>../xml-tips-xmlbeans</module>
  <module>../xml-tips-jaxb</module>
  <module>../xml-tips-blog</module>
 </modules>
</project>

More recently I was working on a project that was organised slightly differently and which relied heavily upon a company wide Maven “remote” repository. The idea here was that developer A worked on Project A. When he/she was happy that the code was okay, it was deployed to the repository for use by other developers. So far, so good. Problems arose when Maven snapshots were used and the snapshot artefacts were modified often.

Developer A would build their project and deploy it to the Maven repository as a snapshot. Developer B would need this latest update for their project, but their build would fail as the required JAR was not automatically downloaded from the remote repository to their local repository and they would be stuck with an old build.

The cause may have been a problem in the way the repository was configured, or a bug somewhere, or even the way Maven is supposed to work, but the fact that developers couldn’t automatically get hold of the right versions of artifacts did cause some unnecessary aggravation and lost time for all concerned.

The fix is, once you’ve discovered it, simple. You can either delete your local repository to force its rebuild, or you can start using proper Maven version numbers instead of snapshots and do the versioning yourself. This is more effort than it’s worth as developers have to talk to one another, sending out unnecessary emails etc.

My prefered solution was to use the Maven ‘update snapshots’ command line argument. To use this argument add either --update-snapshots or -U to your command line. For example:

mvn install -U

 


Once added, this command line arg forces Maven to check all snapshots in a remote repository and update your local repository if it’s out of date.



1The remote repository in this case was Apache Archiva although I prefer Artifactory.

Command (computing) Repository (version control) Apache Maven

Published at DZone with permission of Roger Hughes, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Mastering Git
  • Private Remote Maven Repository With Artipie
  • How To Convert Image Files Into GIF or WebP Format Using Java
  • How To Validate Names Using Java

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!