简体   繁体   English

从命令行运行gradle时如何将自定义JAR文件添加到CLASSPATH?

[英]How to add a custom JAR file to CLASSPATH when running gradle from command line?

Same question as this except that, how to do this for Gradle? 因为同样的问题不同的是,如何为摇篮做到这一点?

I have placed cucumber-android and some other JAR files related to cucumber in my app/libs directory. 我已经在我的app / libs目录中放置了cucumber-android和与黄瓜相关的其他一些JAR文件。 This is part of my build.gradle: 这是我的build.gradle的一部分:

buildscript {
   dependencies {
    classpath 'io.fabric.tools:gradle:1.19.2'
    classpath fileTree(dir: 'libs', include: '*.jar')
  }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile fileTree(dir: 'libs', include: ['*.jar'])

When I run a cucumber feature test from Android Studio, it runs successfully, because Android Studio automatically includes the files in the libs directory into CLASSPATH. 当我从Android Studio运行黄瓜功能测试时,它成功运行,因为Android Studio自动将libs目录中的文件包含到CLASSPATH中。

When I run the test from command line using 当我使用以下命令从命令行运行测试时

./gradlew --info cC

I get the error: 我得到错误:

cucumber.runtime.CucumberException: No backends were found. cuming.runtime.CucumberException:找不到后端。 Please make sure you have a backend module on your CLASSPATH. 请确保您在CLASSPATH上有一个后端模块。

This is because the JAR files in the libs are not in the CLASSPATH. 这是因为库中的JAR文件不在CLASSPATH中。 How do I include JAR files when running cc in gradle? 在gradle中运行cc时如何包含JAR文件?

我必须从具有@CucumberOptions批注的类中删除@RunWith(Cucumber.class)批注。

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

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