2013-01-23 154 views
4

我想使用一个Flex库(SWC),它定义了它的POM中的一些依赖关系。我希望Gradle能够自动提供这些传递性依赖。但是,gradle dependencies只显示手动添加的一个依赖项。Gradle忽略传递依赖关系

merged 
\--- com.example:flex-core:1.0.0 

库的POM文件包含以下内容:

<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</groupId> 
    <artifactId>flex-core</artifactId> 
    <version>1.0.0-SNAPSHOT</version> 
    <packaging>swc</packaging> 
    <dependencies> 
    <dependency> 
     <groupId>org.as3commons</groupId> 
     <artifactId>as3commons-lang</artifactId> 
     <version>0.3.6</version> 
     <type>swc</type> 
     <scope>external</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.as3commons</groupId> 
     <artifactId>as3commons-collections</artifactId> 
     <version>1.3.2</version> 
     <type>swc</type> 
     <scope>external</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.as3commons</groupId> 
     <artifactId>as3commons-reflect</artifactId> 
     <version>1.6.0</version> 
     <type>swc</type> 
     <scope>external</scope> 
    </dependency> 
    </dependencies> 
</project> 

我已在以下依赖我build.gradle

dependencies { 
    merged 'com.example:flex-core:[email protected]' 
} 

为什么摇篮忽略从依赖POM?是因为“外部”范围? 是否可以在不添加它们的情况下获得这些依赖关系?

回答

7

声明依赖关系时使用artifact only notation@scw)。这意味着Gradle只会检索工件本身,但不会使用POM中的传递依赖关系。

试试这个:

dependencies { 
    merged 'com.example:core:1.0.0' 
} 

不应该的名字是flex-core?至少这就是POM上面所说的。

+0

你说得对。我刚刚删除了@ @src并且它可以工作。 –

+0

我已更新我的问题并修复了工件名称。感谢您指出。 –