0
我在IntelliJ IDEA 12
上創建了一個主項目(使用Maven)和一個模塊,這是我的庫。我需要添加模塊作爲依賴到我的主項目。如何將庫項目作爲依賴添加到我的Android Maven項目
我該怎麼做?
我在IntelliJ IDEA 12
上創建了一個主項目(使用Maven)和一個模塊,這是我的庫。我需要添加模塊作爲依賴到我的主項目。如何將庫項目作爲依賴添加到我的Android Maven項目
我該怎麼做?
例如,這是主體工程的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>
這是的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>
如果您的機器上安裝庫項目(它將被訪問到IntelliJ IDEA
但是我必須在每次重新編譯我的庫之前運行這個maven命令,直到最終發佈? –
你想添加你的子項目作爲你的主要項目的庫? –
沒錯。我需要將我的應用程序分成多個項目。 –