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
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Private Remote Maven Repository With Artipie
  • How To Convert Image Files Into GIF or WebP Format Using Java
  • How To Validate Names Using Java
  • How to Convert a PDF to Text (TXT) Using Java

Trending

  • Smart Deployment Strategies for Modern Applications
  • You Don't Get to Retrofit Trust: Why API Security Must Be Designed In, Not Bolted On
  • AWS vs GCP Security: Best Practices for Protecting Infrastructure, Data, and Networks
  • A Scalable Framework for Enterprise Salesforce Optimization: Turning Outcomes Into an Operating System
  1. DZone
  2. Data Engineering
  3. Databases
  4. Ant-to-Maven Conversions: The Painless Method

Ant-to-Maven Conversions: The Painless Method

You no longer need to sweat it over Ant-to-Maven conversions. We've got you covered.

By 
Dinusha Nirmal user avatar
Dinusha Nirmal
·
Aug. 23, 19 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
35.4K Views

Join the DZone community and get the full member experience.

Join For Free

If you've ever come across a situation to convert your grandfathers' Java project (which he used to build with Ant) to Maven, you know my pain. Maybe you are reading this because it's time to do that. So, here is a definitive guide to doing that without getting lost in dependency hell (RIP grandpa)!

Create the Directory Structure

Execute the following commands in order to create the standard Maven directory structure.

For Web Apps

mvn archetype:generate -DgroupId={project-packaging} \
-DartifactId={project-name} \
-DarchetypeArtifactId=maven-archetype-webapp \
-DinteractiveMode=false


For Standalone Apps

mvn archetype:generate -DarchetypeGroupId={project-packaging} \
 -DarchetypeArtifactId=={project-name} \
 -DarchetypeVersion=1.4


Declare Dependencies

  1. Declare the groupId, arifactId, and version for the project
<project>
 <modelVersion> 4.0.0 </modelVersion>
 <groupId> com.mycompany.app </groupId>
 <artifactId> my-app </artifactId>
 <version> 1.0.1 </version>
</project>
<project>
 <modelVersion> 4.0.0 </modelVersion>
 <groupId> com.mycompany.app </groupId>
 <artifactId> my-app </artifactId>
 <version> 1.0.1 </version>
</project>


2. Find the dependencies for each jar file linked to the project.

  • Jars having pom.xml files inside - Extract the from the pom file.
  • Jars not having a pom.xml file - Refer to the signature-based artifact search method explained below.
  • Jars which cannot find using the above 2 methods - Install to your local maven repository or your companies artifact repository.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<myGroup> \
 -DartifactId=<myArtifactId> -Dversion=<myVersion> \
 -Dpackaging=jar


mvn install:install-file -Dfile=<path-to-file> -DgroupId=<myGroup> \
 -DartifactId=<myArtifactId> -Dversion=<myVersion> \
 -Dpackaging=jar


Signature-Based Artifact Search

Now, we have come into the best part.

  1. If you are on Windows, download the File Checksum Integrity Verifier utility from Microsoft's site.
  2. Execute the following from command line to generate a SHA1 signature for the jar file we need to find.
  3. For a single jar file:
    checksum generation with fciv toolAbove, we have checksum generation using the FCIV tool.
  4. For a directory of jars, go to Nexus repository manager and click Advanced search
    Nexus repository manager
    Search Nexus repository using the generated checksum value
  5. Find the matching artifact details using the SHA1 hash obtained from the above step.

Now, you should be able to find all the dependency information referred from old Ant project in this way. So go ahead and get your hands dirty.

JAR (file format) Dependency Repository (version control) Artifact (UML) Dependency hell Web apps app Directory Apache Maven

Published at DZone with permission of Dinusha Nirmal. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Private Remote Maven Repository With Artipie
  • How To Convert Image Files Into GIF or WebP Format Using Java
  • How To Validate Names Using Java
  • How to Convert a PDF to Text (TXT) Using Java

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook