Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] [m2eclipse-dev] m2eclipse extensions that modify project classpath

As I mentioned, NPE are caused by MNGECLIPSE-2555. You need to specify
versions of all Maven plugins used by the project, which is a good thing
regardless of m2e the bug. I've attached pom.xml diff to save you some
typing.

In order to avoid adding explicit lifecycle mapping to all apk projects,
you need to provide ILifecycleMapping implementation like [1] and
register it as default mapping via an extension point (see
m2eclipse-tycho plugin.xml for details).

[1] https://github.com/sonatype/m2eclipse-tycho/blob/master/org.sonatype.tycho.m2e/src/org/sonatype/tycho/m2e/internal/TychoLifecycleMapping.java

--
Regards,
Igor

On 10-11-21 07:26 AM, Ricardo Gladwell wrote:
Hi Igor

Thanks for the feedback, I really appreciate your help. I'm still
getting some problems, unfortunately:

On Sun, 2010-11-14 at 18:08 -0500, Igor Fedorenko wrote:
Depending on what changes you need to make to raw classpath, you may
need to use m2e 0.12.0, which is currently available from staged
repository [1]. See MNGECLIPSE-2313 [2] for details.

I installed the 0.12.0 version of the m2eclipse plugin, but the
configureRawClasspath method on my IJavaProjectConfigurator is still not
being called. The configureClasspath is being called, but the changes to
the classpath here do not seem to be taking.

There are currently couple of ways to make this work. You can setup
custom build lifecycle mapping using pom.xml snippet like below.
Alternatively, you can provide default lifecycle mapping for projects
with packaging=apk (I can provide pointers if you are interested).

Interesting, any advice you can provide here would be useful.

    <profiles>
      <profile>
        <id>m2e</id>
        <activation>
          <property>
            <name>m2e.version</name>
          </property>
        </activation>  snip...

Sorry, I'm not sure, do you mean I should add that XML to my Android
project POM? Is that what the plugin.xml "generic" boolean flag for
projectConfigurators indicates?

If I do put this into my pom.xml, I get a NPE (see attached).

Also, you almost certainly want to avoid running "mvn package" during
incremental build (this is what current implementation of
AndroidMavenBuildParticipant does). It runs on each resource change
(think Ctrl-S in editor) and takes many seconds even for most simple
projects. It can also cause infinite build, because same output files
are changed by Eclipse JDT/ADT builders and by Maven mojos. Why do you
need to run any mojos? Can't you rely on ADT to do everything needed?

This is unfortunate and it's something I'd like to change. The problem
is that the ADT project builder does not include Maven dependency JAR
files when building the the binary application blob, so we need to
replace it with the a maven-based project build participant. To create
incremental builds would require changes to the underlying
maven-android-plugin which is something I'm planning to do, but in the
meantime I'd just like to get this problem with configureRawClasspath
fixed so I can at least get something up and working.

The reason there is an infinite build is because the JDT maven project
configurator adds the target/generated-sources/r directory, so each time
we do a maven build, it refreshes the generated class files here,
causing a further build, hence the infinite loop. This target generated
source folder is what I am trying to remove from the project classpath
in the call to configureRawClasspath.

Also the ADT automatically creates a /gen source folder, so if the Maven
android plugin also adds an identical generated source folder it creates
duplicate class build errors.

TIA...




_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-dev
Index: pom.xml
===================================================================
--- pom.xml	(revision 126)
+++ pom.xml	(working copy)
@@ -24,9 +24,9 @@
 
     <dependencies>
 		<dependency>
-			<groupId>android</groupId>
+			<groupId>com.google.android</groupId>
 			<artifactId>android</artifactId>
-			<version>1.5_r4</version>
+			<version>2.1_r1</version>
 			<scope>provided</scope>
 		</dependency>
 
@@ -44,10 +44,11 @@
             <plugin>
                 <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                 <artifactId>maven-android-plugin</artifactId>
+                <version>2.6.0</version>
                 <configuration>
                     <sdk>
-                        <path>${env.ANDROID_HOME}</path>
-                        <platform>3</platform>
+                        <path>/opt/android-sdk-linux_86</path>
+                        <platform>7</platform>
                     </sdk>
                     <deleteConflictingFiles>true</deleteConflictingFiles>
                 </configuration>
@@ -55,7 +56,9 @@
             </plugin>
 
             <plugin>
+            	<groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.2</version>
                 <configuration>
                     <source>1.5</source>
                     <target>1.5</target>
@@ -65,4 +68,33 @@
         </plugins>
     </build>
 
+  <profiles>
+    <profile>
+      <id>m2e</id>
+      <activation>
+        <property>
+          <name>m2e.version</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+	      <plugin>
+	        <groupId>org.maven.ide.eclipse</groupId>
+	        <artifactId>lifecycle-mapping</artifactId>
+	        <version>0.10.0</version>
+	        <configuration>
+	          <mappingId>customizable</mappingId>
+	          <configurators>
+	            <configurator id="org.maven.ide.eclipse.jdt.javaConfigurator" />
+	            <configurator id="com.urbanmania.eclipse.maven.android.androidDevelopmentToolsProjectConfigurator" />
+	          </configurators>
+	          <mojoExecutions>
+	            <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
+	          </mojoExecutions>
+	        </configuration>
+	      </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 </project>

Back to the top