[英]How to add a library project as a dependecy to my Android Maven project
I'm creating on IntelliJ IDEA 12
a main Project (using Maven) and a module that is my library. 我正在IntelliJ IDEA 12
上创建一个主项目(使用Maven)和一个作为我的库的模块。 I need to add the module as a dependency to my main Project. 我需要将模块作为依赖项添加到我的主项目中。
How can I do this? 我怎样才能做到这一点?
For example this is the pom.xml
of the main project , I add my custom library ( groupId
-> com.example.app and artifactId
-> library) 例如,这是主项目的pom.xml
,我添加了自定义库( groupId
> com.example.app和artifactId
>库)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.myapp{groupId}</groupId>
<artifactId>my-example-app{artifactId}</artifactId>
<version>1.0</version>
<packaging>apk</packaging>
<dependencies>
<dependency>
<groupId>com.example.app</groupId>
<artifactId>library</artifactId>
<version>1.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.10</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<extensions>true</extensions>
<inherited>true</inherited>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And this is the pom.xml
of the library project : 这是库项目的pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.app</groupId>
<artifactId>library</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apklib</packaging>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.10</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.4.1</version>
<extensions>true</extensions>
<inherited>true</inherited>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
If you install the library project on your machine ( mvn clean install
), it will be accessible to IntelliJ IDEA
如果您在计算机上安装库项目( mvn clean install
),则IntelliJ IDEA
可以访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.