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

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

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

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

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

  • Scaling DevOps With NGINX Caching: Reducing Latency and Backend Load
  • Agentic AI for Automated Application Security and Vulnerability Management
  • A Deep Dive Into Firmware Over the Air for IoT Devices
  • Start Coding With Google Cloud Workstations
  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
34.5K 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.

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: