快速配置maven环境

时间:2022-08-10 16:49:33

 

1.把maven的插件包拷贝到eclipse相关目录;

 

2.在maven安装目录中的setting.xml文件中修改成 <localRepository>D:/.m2/repository</localRepository>;

 

3.在eclipse中的maven选项中,选择自己定义的setting.xml文件。

 

 

 

搭配maven eclipse android环境:

 

1.You will need   'Eclipse Indigo or Juno ' installed.

You can install the Android Connector for Maven via the Eclipse Marketplace. SelectHelp -> Eclipse Marketplace... and search for "android m2e".

 

2. 到下面网站下载Maven的中心库,

http://search.maven.org/#search|ga|1|android-quickstart

之后复制到Maven的repository中

快速配置maven环境

之后在Eclipse中,new Maven project , 添加原型archieve, 定位到上面的Maven中心库

快速配置maven环境

 

之后自定义GroupId 和 ArtifactId

快速配置maven环境



之后就能新建Android 项目了


此外如果新建Android项目之后可以Convert To Maven, 虽然新建的是Android 4.0 但是还是可以用Maven导入其他的依赖项,只需要添加dependency即可

快速配置maven环境


最后附上一份pom的模板(如果新建Maven Android 还是需要自己调整pom的配置

pom.xml

[html] view plaincopyprint?
  1. <projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>myandroid</groupId>
  5. <artifactId>AndroidIMProject</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. <packaging>apk</packaging>
  8. <properties>
  9. <platform.version> 2.2.1
  10. </platform.version>
  11. </properties>
  12. <dependencies>
  13. <dependency>
  14. <groupId>com.google.android</groupId>
  15. <artifactId>android</artifactId>
  16. <version>${platform.version}</version>
  17. <scope>provided</scope>
  18. </dependency>
  19. </dependencies>
  20. <build>
  21. <plugins>
  22. <plugin>
  23. <groupId>com.jayway.maven.plugins.android.generation2</groupId>
  24. <artifactId>android-maven-plugin</artifactId>
  25. <version>3.5.0</version>
  26. <configuration>
  27. <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
  28. <assetsDirectory>${project.basedir}/assets</assetsDirectory>
  29. <resourceDirectory>${project.basedir}/res</resourceDirectory>
  30. <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
  31. <sdk>
  32. <platform>8</platform>
  33. </sdk>
  34. <undeployBeforeDeploy>true</undeployBeforeDeploy>
  35. </configuration>
  36. <extensions>true</extensions>
  37. </plugin>
  38. <plugin>
  39. <artifactId>maven-compiler-plugin</artifactId>
  40. <version>2.3.2</version>
  41. <configuration>
  42. <source>1.6</source>
  43. <target>1.6</target>
  44. </configuration>
  45. </plugin>
  46. </plugins>
  47. </build>
  48. </project>

 

 -------------------------------无聊的分割线-------------------------------------------------------

 http://blog.csdn.net/anialy/article/details/8539182  参考这个人的配置