2012-12-24 206 views

回答

1

例如,這是主體工程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

+0

但是我必須在每次重新編譯我的庫之前運行這個maven命令,直到最終發佈? –

相關問題