Run cucumber test with cached dependencies and plugins on gradle

前端 未结 1 1918
梦毁少年i
梦毁少年i 2020-12-04 02:51

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

相关标签:
1条回答
  • 2020-12-04 03:28

    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 https://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.

    0 讨论(0)
提交回复
热议问题