我有一个 android 项目,我使用 maven 来管理它,它在命令行中运行良好。施工如下:
我的项目
| --android |
----src
|----pom.xml
|----......
|--common
|----src
|----assets
|---- repo
|--桌面
|--pom.xml
我将共享代码和资产放在公共目录中。和 android 目录中的 pom.xml 是:
<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 or api level (api level 4 = platform 1.6)-->
<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>
正如您在上面看到的,我使用 build-helper-maven-plugin 设置了附加 src 目录,并将资源目录设置为 common/src,我在 common/repo 中还有一个本地存储库来管理我的第三个库。
当我使用命令行时一切都很好,我可以用我的手机'mvn install android:deploy'。但是,当我使用 M2E 将其导入 Eclipse 时,我遇到了以下问题
我在 pom.xml 中添加的添加 src 目录在 Eclipse 工作区中没有显示,所以 android/src 中的代码找不到包。
如果我在 Eclipse 中手动链接源文件夹,它会告诉我应该更新 maven 配置,而我确实这样做了,另一个错误“无法在 'android' 中嵌套 'android/gen'。启用嵌套从 'android' 中排除 'gen'”显示向上。
我完全被这个烂摊子弄糊涂了。任何人都遇到同样的问题,为什么我可以在命令行中使用 maven 而不能在 M2E 中使用,谢谢?