Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Ant project to Maven project

How to convert a Ant project to Maven project? A sample project that would link (a Wicket project)

Thanks

like image 322
adelarsq Avatar asked Oct 27 '10 02:10

adelarsq


People also ask

Can we use Maven and Ant together?

You can use the maven-antrun-plugin to invoke the ant build. Then use the build-helper-maven-plugin to attach the jar produced by ant to the project. The attached artifact will be installed/deployed alongside the pom. If you specify your project with packaging pom , Maven will not conflict with the ant build.

Is Ant better than Maven?

Maven archetype is powerful feature, which allows you to quickly create project. Ant is better for controlling of build process.


3 Answers

The nice part of using maven is that most standard stuff works automatically once you do things the maven way. For a simple webapp:

  1. Create a pom with groupId, artifactId and version (packaging: war)
  2. Add the required dependencies to the pom
  3. move the
    • java sources to src/main/java,
    • resources to src/main/resources,
    • webapp content to src/main/webapp,
    • test content to src/test/java and src/test/resources
  4. set the compiler compliance version using the maven compiler plugin

That should get you up 'n' running.

like image 149
Sean Patrick Floyd Avatar answered Oct 03 '22 20:10

Sean Patrick Floyd


http://www.sonatype.com/people/2009/04/how-to-convert-from-ant-to-maven-in-5-minutes/

I don't know what your ant script looks like, but assuming its a basic script for building, you will need to create a pom.xml file for your project, add your dependencies, and then build it via maven.

like image 22
Steven Benitez Avatar answered Oct 03 '22 21:10

Steven Benitez


For anyone who lands here in future, there is an easier way to find dependencies for maven using the file hashes. So, you won't have to guess artifact versions.

As per the below article, the idea is to generate a SHA1 checksum of the dependency that you want to find the information, then do a reverse search in Nexus repository manager using that hash. For the checksum generation, you can use Microsoft's FCIV (free) utility.

https://devreads.xyz/ant-to-maven-conversion-the-painless-method/

like image 44
DinushaNT Avatar answered Oct 03 '22 20:10

DinushaNT