How to specify “pig-0.13.0-h2.jar” dependency in build.gradle?

我的梦境 提交于 2019-12-11 11:04:06

问题


To specify a Maven dependency in my project, I provide a name, a group id, and a version. This has been enough for every dependency in my project, save one. Pig has multiple jars in the same artifact (not sure if I have the proper nomenclature; I'm still rather new to Maven), but I only need one.

Specifically, I need pig-0.13.0-h2.jar. However, when I provide the dependency

compile "org.apache.pig:pig:0.13.0"

in my build.gradle, only pig-0.13.0.jar, pig-0.13.0-sources.jar, and pig-0.13.0.pom are downloaded. I need the "*-h2.jar", because that's the correct one to work with my version of Hadoop.

Is there a way to tell Gradle (and, generally, Maven or whatever) that my compile dependency requires this exact jar, and that only this one should be included in the classpath?


回答1:


What you need is to specify the classifier. The following script will do the job:

apply plugin: 'java'

repositories {
   mavenCentral()
}

dependencies {
   compile "org.apache.pig:pig:0.13.0:h2"
}

task copyDeps(type: Copy) {
   from configurations.compile
   into 'deps'
}


来源:https://stackoverflow.com/questions/28955104/how-to-specify-pig-0-13-0-h2-jar-dependency-in-build-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!