运行黄瓜测试缓存依赖和插件在gradle上 [英] Run cucumber test with cached dependencies and plugins on gradle

查看:246
本文介绍了运行黄瓜测试缓存依赖和插件在gradle上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个gradle项目上运行一些测试用黄瓜,我试图在另一台PC(有限的网络访问)上运行此测试,所以我复制/粘贴的所有 〜。/ gradle / caches 和项目文件,如 build,src和build.gradle ,并将所有内容放置在原始

所以,一旦我得到了所有的东西,我运行这个

  no-daemon --offline cucumber 

我失败了

 >无法解析配置':classpath'的所有依赖项。 
>无法下载gradle-cucumber-plugin.jar(com.github.samueltbrown:gradle-cucumber-plugin:0.9):没有可用于离线模式的缓存版本

奇怪的是我在caches目录下有这个文件

 〜 /.gradle/caches/modules-2/files-2.1/com.github.samueltbrown/gradle-cucumber-plugin/0.9/7b65c67654715025eed1924 
0c4f7defbef9645e0#ls
gradle-cucumber-plugin-0.9.jar

FYI,我没有像gradle / java那样的经验,的建议将是巨大的,这是插件是必需的在build.gradle

 插件{
idcom.github.samueltbrown.cucumberversion0.9
}

/ p>

解决方案

查看此打开 Gradle问题



Gradle缓存目前不是可移植的。它工作,如果.gradle文件夹的绝对路径在两台机器上是完全相同的。如果两台机器上的用户名不同,〜/ .gradle 的绝对路径不同!



是几种方法你可以解决这个问题,按照所需的努力,最少到大多数:



1。无 - 离线 运行一次



如果您的网络有限机器,运行没有脱机标志一次,依赖关系将不会再次下载,但是校验和是 - 更重要的是缓存现在已经过验证,并适用于 - offline 标志。



2。将 .gradle 移动到可重复的路径



将gradle缓存文件夹移动到 / tmp $

$ h3> 3。将所有依赖项导出到本地文件夹

在连接网络的计算机上,使用gradle任务将所有依赖项导出到文件系统文件夹。将文件夹复制到另一台机器上,并在第二台机器上使用flatdir仓库。

  repositories {
flatDir {
dirs'lib'//包含依赖项的文件夹
}
}

(您也可以导出为maven格式的repo,而不是flatdir。请参见 http://stackoverflow.com/a/13396776/ 1174024



4。使用maven缓存代替



在我的经验中,Maven的.m2文件夹更加便于携带。创建一个具有相同依赖关系的maven项目,将依赖关系缓存到.m2中,然后将.m2复制到第二台机器。在第二个机器上添加 mavenLocal()作为仓库。


Hi I want to run a few test made with cucumber on a gradle project, I was trying to run this test's on another PC (with limited network access) so I copy/pasted everything that was under ~./gradle/caches and the project files like build, src and build.gradle and placed everything on the same place as the original

So once I got everything in place I ran this

  gradle --no-daemon --offline cucumber

And I get a failure

> Could not resolve all dependencies for configuration ':classpath'.
   > Could not download gradle-cucumber-plugin.jar (com.github.samueltbrown:gradle-cucumber-plugin:0.9): No cached version available for offline mode

The odd thing is that I have the file on the caches directory

~/.gradle/caches/modules-2/files-2.1/com.github.samueltbrown/gradle-cucumber-plugin/0.9/7b65c67654715025eed1924
0c4f7defbef9645e0# ls
gradle-cucumber-plugin-0.9.jar

FYI, I don't have the kind of experience with gradle/java as I would like so any kind of suggestion would be great, this is where the plugin is "required" on the build.gradle

plugins {
  id "com.github.samueltbrown.cucumber" version "0.9"
}

Thanks

解决方案

See this open Gradle issue

Gradle cache isn't exactly portable currently. It does work, if the absolute path of the .gradle folder is exactly the same on both machines. The absolute path of ~/.gradle is not the same if the username on both machines is different!

There are a few ways you can get around this, in order of effort required, least to most:

1. Run without --offline once

If this is possible on your network limited machine, run without offline flag once, the dependencies will not be downloaded again, but checksums are - and more importantly the cache is now validated and suitable for use with the --offline flag.

2. Move .gradle to a repeatable path

Move gradle cache folder to something like /tmp/.gradle by setting GRADLE_USER_HOME on both machines and then copy gradle cache between machines.

3. Export all dependencies to a local folder

On the network connected machine, use a gradle task to export all dependencies to a filesystem folder. Copy the folder over to the other machine, and use a flatdir repo on the second machine.

repositories {
  flatDir {
    dirs 'lib' //folder containing dependencies
  }
}

(You could also export to a maven format repo instead of flatdir. See http://stackoverflow.com/a/13396776/1174024)

4. Use a maven cache instead

In my experience Maven's .m2 folder is far more portable. Create a maven project with the same dependencies, cache dependencies into .m2 and then copy .m2 over to the second machine. On the second machine add mavenLocal() as a repo.

这篇关于运行黄瓜测试缓存依赖和插件在gradle上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆