Make m2e work in eclipse indigo for android project

My primary OS is Kubuntu 11.04, the default eclipse installed at the moment is Galileo (3.5.2) . I had a really hard time to make maven work in an Android project in Galileo. A couple days ago, I finally had enough. I knew newer version of Eclipse has maven eembedded, I figured embedded maven should be integrated better, so I installed Eclipse Indigo (3.7). And like what some other folks said: “What a mess!”.  I spend 2 days to make it work and I am not exactly sure what did right.  Here I will post what I did, hopefully you don’t have to waste as much time as I did.

I load one of my Android projects in to Indigo, when run it as Android project, it complains something like “Plugin execution not covered by lifecycle configuration … …”. This is because newer version of Maven require lifecycle configuration for plugins, otherwise the project will refuse to build.  Add something like below to your pom.xml, inside build

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>some-group-id</groupId>
                <artifactId>some-artifact-id</artifactId>
                <versionRange>[1.0.0,)</versionRange>
                <goals>
                  <goal>some-goal</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <ignore />
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>

please see more details on this page. You have to make sure groupId, artifactId, versionRange match the plugins you have, otherwise it will complain something like “Error resolving version for plugin ‘org.eclipse.m2e:lifecycle-mapping’ from the repositories…”. After all that, if it still has errors, try to fix it using Eclipse’s build-in hint. My project constantly complain about “/myproject/gen already exists but is not a source folder. Convert to a source folder or rename it”, I had to do Project->clean to make it go away every time, do a Maven->update dependencies may also help, I don’t know exactly what I did to make it work.

Above was what worked for me, it sounds easy, but it took many hours for a noob like me to get it right.

This entry was posted in eclipse, maven. Bookmark the permalink.

Leave a comment