如何使用分类器访问jar? [英] How do I access a jar with a classifier?
问题描述
我有一个maven项目,可以将两个jar作为工件构建。版本号为0.7,一个工件以默认方式构建,第二个具有分类器。因此,在我的存储库中,它们看起来像这样:
Tue Jun 10 08:06:12 MST 2014 14915 gokenizer-0.7 .pom
Tue Jun 10 08:06:12 MST 2014 40 gokenizer-0.7-core.jar.sha1
Tue Jun 10 08:06:12 MST 2014 40 gokenizer-0.7.pom.sha1
Tue Jun 10 08:06:12 MST 2014 32 gokenizer-0.7.jar.md5
Tue Jun 10 08:06:12 MST 2014 32 gokenizer-0.7.pom.md5
Tue Jun 10 08 :06:12 MST 2014 37969843 gokenizer-0.7.jar
Tue Jun 10 08:06:12 MST 2014 41887392 gokenizer-0.7-core.jar
Tue Jun 10 08:06:12 MST 2014 32 gokenizer -0.7-core.jar.md5
Tue Jun 10 08:06:12 MST 2014 40 gokenizer-0.7.jar.sha1
如您所见,带有分类器的jar将core作为其分类器。
存储库的路径是:
http://myhostname/plugin/repository/project/DomainIQCore/LastSuccessful/repository/com/example/domain/gokenizer/0.7 /
一切都好吗?那么在构建我的项目时,如何实际指定我想要带有核心分类器的jar?
在我的build.scala文件中,我试过这个:
libraryDependencies ++ = Seq(
com.example.domain%gokenizer%0.7%core
),
然后我收到此错误:
java.lang.IllegalArgumentException:无法将依赖项'com.example.domain #gokenizer; 0.7'添加到模块com.example#domainiq_2的配置'core'。 10; 0.1.0-SNAPSHOT因为此配置不存在!
当我尝试这个时:
libraryDependencies ++ = Seq(
com.example.domain%gokenizer%0.7-core
),
它显然错误地构建了存储库的路径:
http://myhostname/plugin/repository/project/DomainIQCore/LastSuccessful/repository/com/example/domain/gokenizer/0.7-core/gokenizer-0.7-core.pom
我显然必须做错事。我认为第一种方式(以第4个字段为核心)是方式,但我不知道因为这种配置不存在意味着什么。既然它似乎甚至没有试图访问存储库,似乎我必须告诉SBT核心意味着什么?这对我来说没有意义,因为我认为它只是路径的一部分,而不是配置。
当我删除第4个字段时,它正确获取jar的非分类器版本,所以我知道存储库在那里工作...
帮助?
当然,一如既往,发布问题并找到答案;)
说分类器好多次让我在Great Google Machine上尝试不同的搜索,这让我得到了答案。
com.example.domain %gokenizer%0.7分类器核心
不是百分号。 分类器作为关键字。我不知道。现在它编译。</ p>
I have a maven project that builds two jars as artifacts. The version number is 0.7 and one artifact is built the "default" way and the second has a classifier. As such, in my repository, they look like this:
Tue Jun 10 08:06:12 MST 2014 14915 gokenizer-0.7.pom
Tue Jun 10 08:06:12 MST 2014 40 gokenizer-0.7-core.jar.sha1
Tue Jun 10 08:06:12 MST 2014 40 gokenizer-0.7.pom.sha1
Tue Jun 10 08:06:12 MST 2014 32 gokenizer-0.7.jar.md5
Tue Jun 10 08:06:12 MST 2014 32 gokenizer-0.7.pom.md5
Tue Jun 10 08:06:12 MST 2014 37969843 gokenizer-0.7.jar
Tue Jun 10 08:06:12 MST 2014 41887392 gokenizer-0.7-core.jar
Tue Jun 10 08:06:12 MST 2014 32 gokenizer-0.7-core.jar.md5
Tue Jun 10 08:06:12 MST 2014 40 gokenizer-0.7.jar.sha1
As you can see, the jar with the classifier has "core" as its classifier.
The path to the repository is:
http://myhostname/plugin/repository/project/DomainIQCore/LastSuccessful/repository/com/example/domain/gokenizer/0.7/
All good? So how do I actually specify that I want the jar with the "core" classifier when building my project?
In my build.scala file, I tried this:
libraryDependencies ++= Seq(
"com.example.domain" % "gokenizer" % "0.7" % "core"
),
But then I get this error:
java.lang.IllegalArgumentException: Cannot add dependency 'com.example.domain#gokenizer;0.7' to configuration 'core' of module com.example#domainiq_2.10;0.1.0-SNAPSHOT because this configuration doesn't exist!
And when I try this:
libraryDependencies ++= Seq(
"com.example.domain" % "gokenizer" % "0.7-core"
),
It clearly builds the path to the repository wrong:
http://myhostname/plugin/repository/project/DomainIQCore/LastSuccessful/repository/com/example/domain/gokenizer/0.7-core/gokenizer-0.7-core.pom
I must obviously be doing something wrong. I thought the first way (with the 4th field as "core") was the way, but I have no idea what "because this configuration doesn't exist" means. Since it doesn't appear to even be trying to hit the repository, it seems that I have to tell SBT what "core" means? That doesn't make sense to me because I thought it was just part of the path, not a "configuration" as such.
When I remove the 4th field, it properly gets the non-classifier version of the jar, so I know the repository is there and working...
Help?
Of course, as always happens, post the question and find the answer ;)
Saying "classifier" so many times made me try a different search on the Great Google Machine which netted me the answer.
"com.example.domain" % "gokenizer" % "0.7" classifier "core"
Not a percent sign. "classifier" as a keyword. I had no idea. Now it compiles.
这篇关于如何使用分类器访问jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!