【问题标题】:Gatling Gradle plugin not including transitive dependenciesGatling Gradle 插件不包括传递依赖项
【发布时间】:2021-01-30 00:31:53
【问题描述】:

我在我的 Scala 项目中使用 official Gatling Gradle plugin,我看到一个问题,其中包含的依赖项像

dependencies {
    gatling "LibraryA"
}

不包括传递依赖。也就是说,我有一个 Gatling 模拟类,它从 LibraryB 扩展了一个类,LibraryA 依赖于该类。但是,当我尝试运行模拟时,出现类似

的错误
Symbol 'type ClassFromTheTransitiveDependency' is missing from the classpath.

当我查看 Gradle 依赖项时,我将 LibraryB 视为 LibraryA 的依赖项。单击代码时,我的 IDE (IntelliJ) 也能识别它。

我已尝试搜索 single page of documentation for the plugin,但在那里我没有看到任何有用的信息。这只是不支持还是我遗漏了什么?

提前致谢,如果简单的话,请原谅我的 Gradle/build 平庸!

【问题讨论】:

    标签: gradle build.gradle gatling scala-gatling gatling-plugin


    【解决方案1】:

    您的帖子非常不完整,因为您无法根据您提供的信息进行调查和帮助。 通常,您应该提供一种方法来重现您的问题,请参阅http://sscce.org

    这就是我所做的:

    1. 克隆official demo project
    2. 添加了对 OkHttp 的依赖项(可传递地依赖于 okio 和 kotlin)
    3. 在示例模拟中添加了使用 OkHttp 的代码
    4. ./gradlew gatlingRun
    dependencies {
        gatling 'com.squareup.okhttp3:okhttp:4.9.0'
    }
    
      import okhttp3._
      val client = new OkHttpClient()
      val request = new Request.Builder().url("https://gatling.io").build
      println(client.newCall(request).execute().body.string())
    

    一切正常,所以问题很可能出在您这边,而不是 gatling-gradle-plugin。我建议从官方示例开始,并逐个添加片段,直到找出哪一个坏了。

    【讨论】:

    • 感谢您的回答。抱歉,我无法给出更好的可重现示例;这样做有点困难,因为依赖问题是通过私有/内部库。您的示例和我的示例之间的一个区别是我的代码直接使用来自传递依赖项之一的类。看起来在这里你只在你的例子中使用了对 OkHttp 的第一级依赖。
    • 尝试做和我一样的事情。您拥有所有工具。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-20
    • 1970-01-01
    • 2020-02-12
    相关资源
    最近更新 更多