[英]Why classifier is removed from artifact while installing on local maven repo?
I have a utility project which uses gradle to generate the JAR artifacts. 我有一个实用程序项目,它使用gradle生成JAR工件。 While generating the JAR artifact, I use
classifier
property of Jar task explained here . 虽然生成JAR神器,我使用的
classifier
jar任务的属性解释这里 。 The code I use in my build.gradle is: 我在build.gradle中使用的代码是:
def artifactClassifier = project.hasProperty('classifier') ? classifier : "dev"
jar {
classifier = artifactClassifier
}
I could see the JAR is generated as expected ( myutils-1.0-test.jar
) while I run following gradle build. 我可以看到JAR是按照预期生成的(
myutils-1.0-test.jar
),同时我按照gradle构建运行。
$ gradle clean build -Pclassifier=test
Now, I tried to install this artifact to my local M2 repo using following command: 现在,我尝试使用以下命令将此工件安装到我的本地M2存储库:
$ mvn:install install-file -Dfile=/path/to/myutils-1.0-test.jar -DgroupId=my.group -DartifactId=myutils -Dversion=1.0 -Dclassifiers=test
This installation was successful, but when I checked my M2 repo, I see the JAR file is located as: ~/.m2/repository/my/group/myutils/1.0/myutils-1.0.jar
. 这个安装很成功,但是当我检查了我的M2
~/.m2/repository/my/group/myutils/1.0/myutils-1.0.jar
,我看到JAR文件位于: ~/.m2/repository/my/group/myutils/1.0/myutils-1.0.jar
。 The classifier value test
is missing from the installed artifact name. 已安装的工件名称中缺少分类器值
test
。 Then, I tried to add this as a dependency as: 然后,我尝试将其添加为依赖项:
<dependency>
<groupId>my.group</groupId>
<artifactId>myutils</artifactId>
<version>1.0</version>
<classifier>test</classifier>
</dependency>
But, maven could not resolve it. 但是,maven无法解决它。 After I removed
classifier
tag, maven could resolve the dependency. 删除
classifier
标签后,maven可以解决依赖关系。 Same thing happened with Gradle too. Gradle也发生了同样的事情。 When I added following, Gradle failed to resolve the dependency (I tried without
@jar
and that too didn't work. 当我添加了以下内容时,Gradle无法解决依赖关系(我试过没有
@jar
,这也没有用。
ext {
myutils.version = "1.0"
}
compile "my.group:myutils:${myutils_version}:test@jar"
Whereas on removing :test@jar
let Gradle resolve the dependency. 而在删除
:test@jar
让Gradle解析依赖关系。
I am using Gradle v2.3
and Maven v3.3.1
我正在使用Gradle
v2.3
和Maven v3.3.1
Am I missing anything? 我错过了什么吗? Could someone help me?
有人能帮助我吗?
Try using -Dclassifier
(without s) as parameter to mvn install:install-file
. 尝试使用
-Dclassifier
(不带s)作为mvn install:install-file
。
ie: 即:
$ mvn install:install-file -Dfile=/path/to/myutils-1.0-test.jar -DgroupId=my.group -DartifactId=myutils -Dversion=1.0 -Dclassifier=test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.