问题与gradle构建和pom解析
我有一个关于Gradle构建的问题,我很难解决。问题与gradle构建和pom解析
我不断收到一个错误说更新:
> 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:
<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>
在我的构建.gradle文件我有:
compile 'tibco:ask:8.3.1'
其中,nativity是我的POM中的artifactID。
我需要在我的build.gradle文件中为gradle中的pom解析器添加什么内容才能获得${tibrv.native}
值的真实值?
如前所述here的<os>
轮廓激活不支持
这是可能的,你可以设置tibrv.native
系统属性,我真的不知道,但它是值得一试。
可能的解决方法是将nativity-8.3.1.pom
的“固定”版本存储在另一个在主存储库之前排序的存储库中。 Maven存储库可以来自本地文件夹,我认为gradle能够从多个存储库中获取单个依赖项的工件(例如,来自一个仓库的仓库和另一个仓库的仓库),但不能100%确定。
如:
repositories {
maven {
url uri('localrepo') // gradle will look here first
}
maven {
url 'http://Mywebsite/content/groups/public'
}
}
然后,您可以存储XML POM的固定版本在
$projectDir/localrepo/tibco/nativity/8.3.1/nativity-8.3.1.pom
有没有一种方法让gradle查看存储库位置并忽略位于此处的pom文件,并且只使用此内部的jar locaiton? – koala421
我这么认为,看到我的其他答案 –
另一种可能的解决方案(不知道它会工作)是使用与配置transitive = false
。希望在这种情况下,gradle不会尝试解决传递依赖关系。显然你需要自己手动添加传递依赖。此外,通过这样做,组/工件/版本元数据将丢失,因此如果消费者引用您的项目,则此依赖关系无法参与依赖关系解析。
如
configurations {
hack { transitive = false}
}
dependencies {
hack 'tibco:nativity:8.3.1'
compile configurations.hack.singleFile
compile 'foo:bar:1.0'
}
我面临的问题是正在阅读的POM文件和gradle没有找到罐子tibco:$ tibrv.native}:回购仓库内的jar(它不应该是因为它不存在)..基本上Gradle没有正确解析pom – koala421
我希望'transitive = false'意味着pom中的依赖被忽略。猜猜我错了:( –
请粘贴'pom.xml'的相关部分,它定义了'tibrv.native'财产。希望它不在 –
这正是它在... – koala421
请参阅[这里](https://blog.gradle.org/maven-pom-profiles)讨论关于gradle中maven配置文件的支持。和[这里](https://dzone.com/articles/maven-profile-best-practices)为什么在依赖管理中使用配置文件被认为是反模式 –