Adding Maven to an ANT project

For this addition, I had the following stipulations:

  1. Leave existing structure alone. Source/resource/etc directories must be left alone
  2. This won’t be the primary build method so the output, target, directory can be anywhere
  3. No existing test directory so this can be anywhere

I opted to create a new empty Maven project using IntelliJ and then copied over the existing source directory.

Create new Project

  • groupId“, this is your primary object path. Something like: “com.yourcompany”, “org.mozilla”, or “org.apache.maven.plugins”
  • artifactId“, this is the name of the project. Apache’s compiler plugin is “maven-compiler-plugin”.

This will generate an empty project with a src/main/, and src/test directories. This is the default Maven structure and for my project these aren’t going to work. I have to keep the existing object structure so existing scripts will continue to function correctly after this addition. If you open the pom.xml file you’ll see something like this:


Copy Over Source

After the empty project was created I needed to delete the conflicting source directory “src”. Then I copied over the one I has all the important stuff in it.

To use a non default Maven source directory I had to add a build section under project and then two tags to specify the build source and test source directories. The resulting pom.xml file looked like this:



Exclude files from build

It was fairly easy to ignore files and directories once I used the maven compiler plugin. For the regular expressions, the paths are relative to the src directory, so if you want to ignore something in “”, you can put “**”. Here’s the pom addition, note this goes inside “<plugins>” which is inside the “<build>” tag.



  • Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
    • Fixed by removing MAVEN_OPTS environment variable. Reference