Convert Ivy To: Maven
If you are maintaining a legacy Ant+Ivy project, you’ve likely felt the pain: verbose XML, manual classpath management, and the struggle to integrate with modern tools like Maven Central or GitHub Actions. Converting from Ivy to Maven is not just about swapping XML files; it’s about adopting a new philosophy of build management.
: Since Ivy features like custom configurations don't always translate perfectly to Maven's rigid scopes, you may need to manually adjust the generated dependencies. IDE-Based Conversion
<target name="build"> <ivy:retrieve pattern="lib/[artifact]-[revision].[ext]"/> <javac srcdir="src" destdir="build/classes" classpathref="compile.classpath"/> <copy todir="build/classes"> <fileset dir="config" includes="*.properties"/> </copy> <jar destfile="dist/app.jar" basedir="build/classes"/> </target>
If you are currently using Apache Ivy , you can leverage the built-in makepom task to generate a pom.xml directly from your existing ivy.xml . This is the most efficient way to capture your current dependency list. convert ivy to maven
The most efficient way to generate a baseline Maven configuration is using Ivy’s built-in makepom task .
This maps your Ivy configurations to standard Maven scopes like compile and runtime .
<repositories> <repository> <id>internal-repo</id> <name>Corporate Ivy Repository</name> <url>https://artifacts.mycompany.com/maven-repo</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> If you are maintaining a legacy Ant+Ivy project,
Maven is rigid about directory layout. Ivy/Ant projects can put source code anywhere. You have two choices:
Use code with caution. Copied to clipboard
<ivy-module version="2.0"> <info organisation="com.example" module="myapp"/> <configurations> <conf name="compile" visibility="public"/> <conf name="runtime" extends="compile"/> <conf name="test" extends="runtime"/> </configurations> <dependencies> <!-- Dependency with dynamic revision --> <dependency org="org.springframework" name="spring-core" rev="5.3.+"/> <dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.19.0"/> <dependency org="junit" name="junit" rev="4.13.2" conf="test->compile"/> <!-- Transitive exclusion --> <dependency org="commons-logging" name="commons-logging" rev="1.2"> <exclude org="log4j" module="log4j"/> </dependency> </dependencies> </ivy-module> This maps your Ivy configurations to standard Maven
<properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <spring.version>5.3.31</spring.version> <!-- Locked latest as of migration --> </properties>
Keep a README.md migration note explaining the new directory structure and common Maven commands ( mvn compile , mvn test , mvn package ).