gradle构建和pom解析的问题

时间:2017-04-04 17:51:16

标签: maven gradle compiler-errors

我对Gradle构建有一个问题,我很难解决。

我一直收到错误说更新:

> Could not resolve credit/open/fabric:credit-open-fabric-api:17.4.1.RELEASE.
  > Could not parse POM http://Mywebsite/content/groups/public/openapi/17.4.1.RELEASE/open-api-17.4.1.RELEASE.pom
     > Could not resolve open:api:17.4.1.RELEASE.
        > Could not resolve open:api2:17.4.1.RELEASE.
           > Could not parse POM http://Mywebsite/content/groups/public/open/api2/17.4.1.RELEASE/api2-17.4.1.RELEASE.pom
              > Could not resolve open:open-parent:17.4.1.RELEASE.
                 > Could not resolve open:open-parent:17.4.1.RELEASE.
                    > Could not parse POM http://Mywebsite/content/groups/public/open/open-parent/17.4.1.RELEASE/open-parent-17.4.1.RELEASE.pom
                       > Unable to resolve version for dependency 'tibco:${tibrv.native}:jar'

并且堆栈跟踪显示解析包含依赖关系的pom时出现以下问题:UPDATED:

<dependency>
<groupID>tibco</groupID>
<artifactId>${tibrv.native}</artifactID>
</dependency>

<dependency>
<groupID>tibco</groupID>
<artifactId>tibask</artifactID>
</dependency>
.
. 
.
<profile>
 <id>tib-windows</id>
 <activation>
  <os>
   <family>windows</family>
  </os>
 </activation>
 <properties>
  <tibrv.native>tibask</tibrv.native>
 </properties>
</profile>

在我的build.gradle文件中,我有:

compile 'tibco:ask:8.3.1'

其中耶稣诞生是我POM中的artifactID。

我是否需要在gradle中的pom解析器的build.gradle文件中添加一些内容以获取${tibrv.native}值的真值?

2 个答案:

答案 0 :(得分:0)

如上所述here,不支持<os>个人资料激活

您可以设置tibrv.native系统属性,我真的不确定,但值得一试。

可能的解决方法是存储&#34;固定&#34;在主存储库之前排序的另一个存储库中的nativity-8.3.1.pom版本。 Maven存储库可以从本地文件夹中获取,我认为gradle能够从多个存储库中获取单个依赖项的工件(例如,来自一个存储库的pom和来自另一个存储库的jar)但不是100%确定。

例如:

repositories {
    maven {
       url uri('localrepo') // gradle will look here first
    }
    maven {
       url 'http://Mywebsite/content/groups/public'
    }
}

然后您可以在

存储固定版本的pom xml
$projectDir/localrepo/tibco/nativity/8.3.1/nativity-8.3.1.pom

答案 1 :(得分:0)

另一种可能的解决方案(不确定它是否有效)是使用transitive = false的配置。希望在这种情况下,gradle不会尝试解决传递依赖关系。显然,您需要自己手动添加传递依赖项。此外,通过执行此操作,组/工件/版本元数据将丢失,因此,如果使用者引用您的项目,则此依赖关系将能够参与依赖项解析。

例如

configurations {
    hack { transitive = false} 
} 
dependencies {
    hack 'tibco:nativity:8.3.1'
    compile configurations.hack.singleFile
    compile 'foo:bar:1.0'
}