Peter Friese

Developer Advocate / Mobile Developer / Public Speaker

Integrating Maven in Eclipse

I am currently writing an Eclipse wizard that helps with creating a new AndroMDA project. AndroMDA already has two wizards that help with creating a new project – they are both commandline based: one for ANT, the other one for Maven (AndroMDApp Maven Plug-in).

One of the biggest problems with integrating Maven is that there doesn’t seem to be something like a main entry class that provides some method one can call and hand in some parameters to get things going. Instead, the only way to start maven is to start a new VM and run the main class. Which turns out to be quite annyoing. Here is an extract of the code that is needed to do the trick:


        // VM runner
        VMRunnerConfiguration vmConfig = new VMRunnerConfiguration(
                "com.werken.forehead.Forehead", foreheadClasspath);


        String launchMode = ILaunchManager.RUN_MODE;
        IVMRunner vmRunner = getJRE().getVMRunner(launchMode);

        if (vmRunner != null)
            // launch manager
            ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
            ILaunchConfigurationType type = manager

            ILaunchConfigurationWorkingCopy launchWorkingCopy = type.newInstance(null,
                    "Create AndroMDA project.");
            launchWorkingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);

            monitor.subTask("Starting maven.");

            ILaunch newLaunch = new Launch(launchWorkingCopy, ILaunchManager.RUN_MODE, null);
  , newLaunch, monitor);


Right at the start you can see something called “forehead”. This some funky launcher the Maven guys use to set up the class path and start the main class. I wonder why they are making things so complicated. One drawback of running a tool like this is that you cannot get feedback about how far processing has proceeded. I would have liked to provide a real progress monitor for the wizard, but unfortunately this is not possible. Maybe I’ll take a look at Maven 2.