如何在Maven中使用或滥用工件分类器? [英] How to use or abuse artifact classifiers in maven?

查看:85
本文介绍了如何在Maven中使用或滥用工件分类器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在尝试将使用ant构建的非常(非常)大型项目移植到maven(同时也移植到svn).在重塑项目结构以最适合Maven范例的过程中,正在探索所有可能性.

We are currently attempting to port a very (very) large project built with ant to maven (while also moving to svn). All possibilities are being explored in remodeling the project structure to best fit the maven paradigm.

现在更具体地讲,我遇到了分类器,并且想知道如何利用它们来发挥自己的优势,同时避免使用分类器反模式".

谢谢

来自: http://maven.apache.org/pom.html

分类器:您有时可能会在 坐标,这就是分类器.我们将访问分类器 以后,但就目前而言,知道这类项目就足够了 显示为groupId:artifactId:packaging:classifier:version.

classifier: You may occasionally find a fifth element on the coordinate, and that is the classifier. We will visit the classifier later, but for now it suffices to know that those kinds of projects are displayed as groupId:artifactId:packaging:classifier:version.

分类器允许区分从中构建的工件 相同的POM,但内容不同.这是一些可选的 任意字符串(如果存在)附加到工件名称上 在版本号之后.作为这一要素的动力, 例如考虑一个提供针对JRE的工件的项目 1.5,但同时还有一个仍支持JRE 1.4的工件.第一个工件可以配备分类器jdk15和 第二个与jdk14一起使用,以便客户端可以选择使用哪个.

The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number. As a motivation for this element, consider for example a project that offers an artifact targeting JRE 1.5 but at the same time also an artifact that still supports JRE 1.4. The first artifact could be equipped with the classifier jdk15 and the second one with jdk14 such that clients can choose which one to use.

分类器的另一个常见用例是需要附加 次要工件到项目的主要工件.如果您浏览 在Maven中央存储库中,您会注意到分类器源 和javadoc用于部署项目源代码和API文档 以及打包的类文件.

Another common use case for classifiers is the need to attach secondary artifacts to the project's main artifact. If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files.

推荐答案

我认为正确的问题是How to use or abuse attached artifacts maven?,因为从根本上来说,这就是引入分类器的原因-允许您发布附加的工件.

I think the correct question would be How to use or abuse attached artifacts maven? Because basicaly that is why classifiers are introduced - to allow you to publish attached artifacts.

Maven项目通常隐式使用附加的工件,例如通过使用maven-javadoc-plugin或maven-source-plugin. maven-javadoc-plugin使用javadoc分类器发布包含生成的文档的附加工件,而maven-source-plugin使用sources分类器发布源.

Well, Maven projects often implicitely use attached artifacts, e.g. by using maven-javadoc-plugin or maven-source-plugin. maven-javadoc-plugin publishes attached artifact that contains generated documentation by using a javadoc classifier, and maven-source-plugin publishes sources by using sources classifier.

现在如何显式使用附加工件?我使用附加的工件来发布线束外壳脚本(start.sh和Co).用分类器sql或类似的方法在随附的工件中发布SQL脚本也是一个好主意.

Now what about explicit usage of attached artifacts? I use attached artifacts to publish harness shell scripts (start.sh and Co). It's also a good idea to publish SQL scripts in the attached artifact with a classifier sql or something like that.

如何在分类器上附上人造物品? -这可以通过build-helper-maven-plugin完成.

How can you attach an arbitary artifact with your classifier? - this can be done with build-helper-maven-plugin.

这篇关于如何在Maven中使用或滥用工件分类器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆