2017-03-01 34 views
0

我看到maven pom.xml很簡單:Maven的嘗試下載一個<packaing> POM POM</package>作爲一個jar文件,並不能找到它

<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>org.acb</groupId> 
    <artifactId>adfafa</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <dependencies> 
<dependency> 
    <!-- https://mvnrepository.com/artifact/org.pentaho/pentaho-aggdesigner --> 
<groupId>org.pentaho</groupId> 
<artifactId>pentaho-aggdesigner</artifactId> 
    <version>5.1.5-jhyde</version> 
</dependency> 

    </dependencies> 
</project> 

從pom.xml的,我只是想Pentaho的-aggdesigner這是兩個模塊父POM的Pentaho-aggdesigner-core.jar添加和Pentaho的-aggdesigner-algorithm.jar,我的遠程回購是:http://repo.spring.io/plugins-release

所以,我認爲,Maven將參觀http://repo.spring.io/plugins-release/org/pentaho/pentaho-aggdesigner/5.1.5-jhyde/pentaho-aggdesigner-5.1.5-jhyde.pom下載父POM,然後,根據到pom,它會下載兩個子模塊pentaho-aggdesigner-core.jar和pentaho-aggdesigner-algorithm.jar。 Pentaho的-aggdesigner-5.1.5-jhyde.pom的內容是:

<?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>org.pentaho</groupId> 
    <artifactId>pentaho-aggdesigner</artifactId> 
    <packaging>pom</packaging> 
    <version>5.1.5-jhyde</version> 
    <name>Pentaho Aggregate Designer</name> 
    <description>Designs aggregate tables for the Mondrian OLAP engine</description> 
    <url>http://github.com/pentaho/mondrian</url> 
    <inceptionYear>2006</inceptionYear> 

    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <distributionManagement> 
    <repository> 
     <id>conjars</id> 
     <name>Conjars</name> 
     <url>http://conjars.org/repo</url> 
     <layout>default</layout> 
    </repository> 
    </distributionManagement> 



    <issueManagement /> 

    <scm> 
    <connection>scm:git:git://github.com/julianhyde/pentaho-aggdesigner.git</connection> 
    <developerConnection>scm:git:[email protected]:julianhyde/pentaho-aggdesigner.git</developerConnection> 
    <url>http://github.com/julianhyde/pentaho-aggdesigner/tree/master</url> 
    <tag>pentaho-aggdesigner-5.1.5-jhyde</tag> 
    </scm> 

    <modules> 
    <module>pentaho-aggdesigner-algorithm</module> 
    <module>pentaho-aggdesigner-core</module> 
    </modules> 

    <dependencyManagement> 
    <!-- Dependency versions for all sub-modules. 
     Sorted by groupId, artifactId. --> 
    <dependencies> 
     <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.4</version> 
     </dependency> 
     <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.1.3</version> 
     </dependency> 
     <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>1.3.1</version> 
     </dependency> 
     <dependency> 
     <groupId>org.pentaho</groupId> 
     <artifactId>pentaho-aggdesigner-algorithm</artifactId> 
     <version>5.1.5-jhyde</version> 
     </dependency> 
     <dependency> 
     <groupId>pentaho</groupId> 
     <artifactId>mondrian</artifactId> 
     <version>3.6.9</version> 
     </dependency> 
     <dependency> 
     <groupId>dom4j</groupId> 
     <artifactId>dom4j</artifactId> 
     <version>1.6.1</version> 
     </dependency> 
     <dependency> 
     <groupId>jaxen</groupId> 
     <artifactId>jaxen</artifactId> 
     <version>1.1-beta-6</version> 
     </dependency> 

     <!-- Test dependencies. --> 
     <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.4</version> 
     <scope>test</scope> 
     </dependency> 
     <dependency> 
     <groupId>org.jmock</groupId> 
     <artifactId>jmock-junit4</artifactId> 
     <version>2.4.0</version> 
     <scope>test</scope> 
     </dependency> 
     <dependency> 
     <groupId>org.jmock</groupId> 
     <artifactId>jmock-legacy</artifactId> 
     <version>2.4.0</version> 
     <scope>test</scope> 
     </dependency> 
     <dependency> 
     <groupId>org.pentaho</groupId> 
     <artifactId>pentaho-aggdesigner-algorithm</artifactId> 
     <version>5.1.5-jhyde</version> 
     <type>test-jar</type> 
     <scope>test</scope> 
     </dependency> 
     <dependency> 
     <groupId>org.hsqldb</groupId> 
     <artifactId>hsqldb</artifactId> 
     <version>2.3.1</version> 
     <scope>test</scope> 
     </dependency> 
     <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.17</version> 
     <scope>test</scope> 
     </dependency> 
     <dependency> 
     <groupId>pentaho</groupId> 
     <artifactId>mondrian-data-foodmart-hsqldb</artifactId> 
     <version>0.2</version> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 

    <reporting> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-javadoc-plugin</artifactId> 
     <version>2.9.1</version> 
     <configuration> 
      <links> 
      <link>http://docs.oracle.com/javase/7/docs/api/</link> 
      </links> 
     </configuration> 
     </plugin> 
    </plugins> 
    </reporting> 

    <build> 
    <defaultGoal>package</defaultGoal> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-dependency-plugin</artifactId> 
     <version>2.8</version> 
     <executions> 
      <execution> 
      <id>properties</id> 
      <goals> 
       <goal>properties</goal> 
      </goals> 
      <phase>initialize</phase> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-source-plugin</artifactId> 
     <version>2.2.1</version> 
     <executions> 
      <execution> 
      <id>attach-sources</id> 
      <phase>verify</phase> 
      <goals> 
       <goal>jar-no-fork</goal> 
       <goal>test-jar-no-fork</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-jar-plugin</artifactId> 
     <version>2.2</version> 
     <executions> 
      <execution> 
      <goals> 
       <goal>test-jar</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>properties-maven-plugin</artifactId> 
     <version>1.0-alpha-2</version> 
     <executions> 
      <execution> 
      <phase>initialize</phase> 
      <goals> 
       <goal>read-project-properties</goal> 
      </goals> 
      <configuration> 
       <files> 
       <file>build.properties</file> 
       </files> 
      </configuration> 
      </execution> 
     </executions> 
     </plugin> 
     <plugin> 
     <!-- If we don't specify gitexe version, git doesn't 
      commit during release process. --> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-release-plugin</artifactId> 
     <dependencies> 
      <dependency> 
      <groupId>org.apache.maven.scm</groupId> 
      <artifactId>maven-scm-provider-gitexe</artifactId> 
      <version>1.9.1</version> 
      </dependency> 
     </dependencies> 
     </plugin> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.17</version> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

你可以看到,POM清楚地表明,我不是一個罐子POM,但一個包POM。但行家還是認爲它是廣口瓶POM,並試圖從遠程回購下載Pentaho的-aggdesigner.jar,當然,jar文件不存在,並拋出這個錯誤:

[ERROR] Failed to execute goal on project adfafa: Could not resolve dependencies for project org.acb:adfafa:jar:0.0.1-SNAPSHOT: Could not find artifact org.pentaho:pentaho-aggdesigner:jar:5.1.5-jhyde in springmaven (http://repo.spring.io/plugins-release/) -> [Help 1] 
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project adfafa: 
Could not resolve dependencies for project org.acb:adfafa:jar:0.0.1-SNAPSHOT: Could not find artifact org.pentaho:pentaho-aggdesigner:jar:5.1.5-jhyde in springmaven (http://repo.spring.io/plugins-release/) 

回答

0

不,沒有按行家」這樣工作。另請參見How to use POMs as a dependency in Maven?

父級只是將子級模塊的配置組合在一起的技巧。它不會自動引入傳遞依賴。

所以你需要指定確切的jar依賴關係。大概是這樣的:

<dependency> 
    <groupId>org.pentaho</groupId> 
    <artifactId>pentaho-aggdesigner-algorithm</artifactId> 
    <version>5.1.5-jhyde</version> 
</dependency> 
<dependency> 
    <groupId>org.pentaho</groupId> 
    <artifactId>pentaho-aggdesigner-core</artifactId> 
    <version>5.1.5-jhyde</version> 
</dependency> 

有POM的,你可以使用這樣,通過在你的依賴型「POM」:

<dependency> 
    <groupId>xxx.yyy</groupId> 
    <artifactId>pentaho-all</artifactId> 
    <type>pom</type> 
    <version>XXXX</version> 
</dependency> 

在這種情況下,Pentaho的,都將是一個POM直接依賴關係列表,然後您將作爲傳遞依賴關係導入。但是您發現的聚合器pom沒有直接的依賴關係,只有模塊和依賴關係管理,所以這不會起作用。

+0

這就是我從src代碼編譯配置單元時遇到的問題。編譯失敗,我找到了配置。所以很奇怪。 – wuchang

+0

你的意思是,這顯然是一個錯誤的配置?但 pom而不是 jar表示什麼? – wuchang

+0

包裝'pom'表示該模塊本身不會創建罐子/戰爭/耳朵。它主要用於帶有子模塊的家長poms或poms。 – greyfairer

相關問題