How do I configure Xcode to use Maven

Jody Garnett picture Jody Garnett · Apr 24, 2011 · Viewed 7.5k times · Source

XCode comes out of the box with support for Ant (with several sample projects you can generate).

How can I configure XCode to use maven pom.xml files?

Fore reference the project I am trying to set up is here:

It makes use of nested folders, each with their own pom.xml, all controlled with the usual maven build targets of:

  • mvn clean install
  • mvn install -o
  • mvn install -o -DskipTests

What makes this a challenge is the nested modules; each of which installs into the local ~/.m2/repository.

For comparison: The eclipse build system references jars in the ~/.m2/repository for external dependencies, while still allowing modules in the project to refer to each other.

I would like a way to set up something similar for XCode.

Answer

sal picture sal · Nov 21, 2011

You can use do this:

mvn ant:ant 

to create a full ant build and then use that from xcode. You'll need to re-run that task every time you change the pom. You can add a shell task to do run that as the first step in your build.

You could also try to turn the $M2_HOME/bin/mvn into a shell task in the build. That might work but you'll never be able to debug issues with it without lots of black magic.

I would try the prior before the later.