问题
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