I have an Android project, I use maven to manage it, and it works well on the command line. Design as below:
My project
| --android
| ---- CSI
| ---- pom.xml
| ----......
| --common
| ---- CSI
| ---- assets
| ----
repo | --desktop
| --pom.xml
I put the shared code and assets in the shared directory. and pom.xml in the android directory:
<project> ........ <dependencies> <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>2.2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.badlogic.gdx</groupId> <artifactId>gdx</artifactId> <version>0.9.1</version> </dependency> <dependency> <groupId>com.badlogic.gdx</groupId> <artifactId>gdx-backend-android</artifactId> <version>0.9.1</version> </dependency> <dependency> <groupId>com.google.ads</groupId> <artifactId>GoogleAdMobAdsSdk</artifactId> <version>4.0.4</version> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <sourceDirectory>src</sourceDirectory> <pluginManagement> <plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.0.0-alpha-14</version> <extensions>true</extensions> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <configuration> <sdk> <platform>8</platform> </sdk> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <phase>generate-sources</phase> <goals><goal>add-source</goal></goals> <configuration> <sources> <source>../common/src</source> </sources> </configuration> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>../common/assets</directory> </resource> </resources> </build> <repositories> <repository> <id>libs</id> <url>file://${basedir}/../common/repo/</url> </repository> </repositories> </project>
As you can see above, I installed the src dir add-on using build-helper-maven-plugin and set the dir resource in common / src, I also have a common / repo shared repository to manage my third library.
Everything is fine, when I use the command line, I can install mnn android: deploy 'with my phone. However, when I import it into Eclipse with M2E, I run into problems below
The added src directory, which I added to pom.xml, did not appear in the Eclipse workspace, so the code in android / src cannot find the package.
If I linked the source folder manually in Eclipse, it will tell me that I need to update the maven configuration, and I made another mistake: "Can not nest" android / gen 'in' android '. To enable attachment exclude 'gen' from 'android' "to appear.
I was completely embarrassed by this mess. Anyone running into the same problem and why can I use maven on the command line and can't on M2E, thanks?
source share