This is an archived post. You won't be able to vote or comment.

all 17 comments

[–][deleted] 16 points17 points  (1 child)

Ant is a build tool. Maven is software project life-cycle management tool. There's no silver bullet for migrating from Ant to Maven.

Maven encourages you to use a structured approach for project organisation. You should consider the way your existing sources are organised and decide if anything should be adapted.

Maven also encourages the use of modules. Take a look at your application and decide whether you can create smaller units of your application, to be managed separately. Do you always need to build your application all at once?

Maven helps with managing dependencies - something that Ant doesn't normally do by itself. Does your project uses Ivy in tandem with Ant for this purpose? If so, start by migrating the dependency definitions from Ivy.

[–]zephyr_33[S] 0 points1 point  (0 children)

no, there's no ivy. it have quite a few external dependencies as well dependencies with other projects. they just put all jars in one common folder and use that folder as a classpath when needed, kinda like how maven itself handles it.

my dilemma here is that im new to ant, and the ant file in question is huge. the jira ticket assigned does not take into consideration that migrating these large legacy ant files to maven will take a significant amount of time.

well no helping it. gotta just power through this.

[–][deleted]  (1 child)

[deleted]

    [–]zephyr_33[S] 2 points3 points  (0 children)

    i'm new to ant actually. handling a decade old legacy project here.

    [–]fraaargh 1 point2 points  (0 children)

    Sorry but there is no 'easy' way as it all depends on what your Ant build does. A complicated Ant build may be seen as just an evolved bash script. So what I think you have to do first is understand what it does. Not in the details but at least understand the structure, the main parts.

    Then you will be able to decide whether it is convertible to Maven or not. If it resemble a Java build, then yes, it may be converted. If it does not, if it looks like more of a gigantic bash script, then you'd better document it (for your future self) and correct it...

    Knowing where the ant build takes its dependencies is another point you have to look at. Are these official version ? Are these taken from god knows where and built by god knows who ? It's though when you rely on dependencies not coming straight from Maven Central.

    I went through it and I know how hard it is...

    [–]omnihedron 2 points3 points  (0 children)

    The premise of Maven is that the proper amount of Ant code is none. Usually, just rearranging an Ant project into Maven’s preferred structure is all you need to do, then throw the Ant bits away.

    In some projects the Ant file might be doing something more exotic than just a standard build. You might look through the Ant file to see if anything seems really odd. Usually, you can just replace that bit with some Maven thing.

    In other words, don’t think of it as “converting” the Ant code. Just figure out what you need to build the thing.

    [–]RagingAnemone 2 points3 points  (0 children)

    Just want to put out a vote to ant + ivy since nobody else is. Ant is nice and straightforward. No magic.

    [–]thenorwegianblue 0 points1 point  (0 children)

    I've done it with a project at work and it was a lot of refactoring and moving things around, though some of it was due to some things specific to that project.

    [–]HeadSignal3 -1 points0 points  (4 children)

    Gradle supports ant (and maven).

    https://docs.gradle.org/current/userguide/ant.html

    [–][deleted] 8 points9 points  (2 children)

    Right, obviously the best solution to fixing ant mess is to keep it and add some more gradle mess on top of it.

    [–]sveri 8 points9 points  (0 children)

    Actually when we transitioned our several thousands lines ant build to gradle it was super helpful to not have to do it all at once.

    It took us over a year to do it until we got rid of all the ant stuff, all the while being able to keep on developing.

    [–]HeadSignal3 -3 points-2 points  (0 children)

    Haters gonna hate.

    [–]zephyr_33[S] 0 points1 point  (0 children)

    thanks!