scope - 如何在 Gradle 构建中使用为 jar 文件提供的范围?

标签 scope gradle

我需要在我的应用程序中使用 Amazon Maps 和 Amazon Messaging。

使用 gradle,我没有成功添加具有“提供”范围的 Amazon 依赖项 as they need to be :

The JAR file contains stub implementations of the Amazon Maps API. It does not contain actual implementations of the Maps API classes, so you should not compile the JAR into your app.

None of the solutions provided by Amazon support worked为我。

如果有人成功通过 Gradle 使用亚马逊 map 或亚马逊消息传递,请在此处分享您的 build.gradle 文件。

最佳答案

2.12 release of Gradle , compileOnly添加的目的是为 provided 范围提供类似的功能。测试类路径中发生的情况有所不同。以下是发行说明中的​​相关引用和片段:

You can now declare dependencies to be used only at compile time in conjunction with the Java plugin. Compile only dependencies are used only during source compilation and are not included in the runtime classpath or exposed to dependent projects. This behavior is similar to that of the 'provided' scope available in Maven based builds. However, unlike Maven provided dependencies, compile only dependencies in Gradle are not included on the test classpath.

Compile only dependencies should be assigned to the relevant source set's 'compileOnly' configuration.

dependencies {
    compileOnly 'javax.servlet:servlet-api:2.5'
}

关于scope - 如何在 Gradle 构建中使用为 jar 文件提供的范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18738888/

相关文章:

c++ - 不断收到错误 "is not a class or namespace"或 "cannot call member function without object"

c++ - 在 C++ 中隐藏 int 变量的名称

ruby-on-rails - ActiveRecord 中 default_scope 的替代方案

android - 如何在Gradle中删除任务名称中的斜杠

java - 使用 Gradle/Java8 构建时存储某些类的方法参数名称

android - Gradle uploadArchives 并行运行,导致 oss sonatype nexus 上出现多个暂存存储库

VB.NET 变量范围

javascript - 使用 jQuery 时维持此范围

java - Spring和Gradle构建:无此类属性:类的主类名称:org.gradle.api.internal.project.DefaultProject_Decorated

react-native - 更新android studio后无法让Android模拟器运行应用