简体   繁体   English

詹金斯的Gradle

[英]Gradle on Jenkins

I have a project which consist of several modules declared in the settings.gradle file: 我有一个项目,包含在settings.gradle文件中声明的几个模块:

include ':core_icons'
include ':core'

core_icons is used by the core module as an versioned dependency: core_icons被核心模块用作版本化依赖项:

compile 'com.company.core:icons:0.0.1-SNAPSHOT'

On Jenkins, the build does not run because Gradle is looking for the dependency in the local maven cache but can't find it: 在Jenkins上,构建不会运行,因为Gradle在本地maven缓存中查找依赖项但无法找到它:

* What went wrong:
A problem occurred configuring project ':core'.
> Could not resolve all dependencies for configuration ':core:_debugPublishCopy'.
   > Could not find com.company.core:icons:0.0.1-SNAPSHOT.

It seems like Gradle tries to find already each dependency then it starts up. 似乎Gradle尝试找到每个依赖项然后启动它。

I tried to reproduce this on my local machine by clearing the dependencies from my local maven cache but then I am able to build the project without any problems via: 我试图通过清除本地maven缓存中的依赖关系在我的本地机器上重现这个,但是我能够通过以下方式构建项目而没有任何问题:

gradlew core_icons:install 

I checked the Gradle versions, both are equal (2.14.1) 我检查了Gradle版本,两者都相等(2.14.1)

I tried to invoke on Jenkins the build exactly the same, but it does not work because it can't find the dependency. 我试图在Jenkins上调用完全相同的构建,但它不起作用,因为它找不到依赖项。

When removing the the core module from the settings.gradle the build runs fine on Jenkins. 从settings.gradle中删除核心模块时,构建在Jenkins上运行正常。

Anybody knows why this is happening only on Jenkins? 有谁知道为什么这只发生在詹金斯身上?

I figured out the solution to my problem, here it is: 我想出了我的问题的解决方案,这里是:

The problem was that I had a dependency to core_icons which just gets created during that build like this: 问题是我对core_icons有一个依赖,它只是在这个构建过程中创建的,如下所示:

compile 'com.company.core:icons:0.0.1-SNAPSHOT'

Since this represents a dependency which should be found in the local Maven repo or in MavenCentral, Gradle was not able to find it. 由于这表示应该在本地Maven仓库或MavenCentral中找到依赖关系,因此Gradle无法找到它。

Just reference the dependency like a normal Project, like so: 像普通项目一样引用依赖项,如下所示:

compile project(':core_icons')

Then you can invoke also the install goal later to publish your artifacts to the Maven repo as a snapshot or release version. 然后,您可以稍后调用安装目标,以将工件作为快照或发布版本发布到Maven存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM