如何将依赖项包含在文件名中没有版本的 EAR 中 [英] How to include dependencies into an EAR without version in the file name

查看:19
本文介绍了如何将依赖项包含在文件名中没有版本的 EAR 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 maven 创建 .ear

I am creating .ear using maven

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-ear-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <finalName>wsformatter-ear</finalName>
    <includeLibInApplicationXml>true</includeLibInApplicationXml>
    <version>1.4</version>
  </configuration>
</plugin>  

.ear 中的所有依赖项看起来像 joda-time-1.6.2.jarcommons-io-1.4.jar 等.

All dependencies in the .ear look like joda-time-1.6.2.jar, commons-io-1.4.jar etc.

而且,我有依赖项,我希望没有版本.例如,我该怎么做,那个依赖 slf4j-api-1.5.6.jar 在我的 .ear 中看起来像 slf4j-api.jarem>

But also, I have dependencies, that I want have without version. For example, how can I do, that dependency slf4j-api-1.5.6.jar will look like slf4j-api.jar in my .ear

推荐答案

基本上,你不能(没有对 Maven 插件配置的某种黑客攻击),即使你可以 - 只是不要.Maven 关于依赖关系的方法和理念是严格而直接的,包括将版本作为文件名后缀的默认约定.它只是立即说明使用了哪个版本的工件.如果您依赖某个经常发布的工件,那么无论如何您都必须在 EAR 的 POM 中更新它的版本,因此它的传播"不会以某种方式自动执行.因此,我看不出这个文件名后缀有什么问题.

Basically, you can't (without some kind of hacking on Maven's plugins' configuration) and even if you could - just don't. Maven approach and philosophy about dependencies is being strict and straight about them, including default convention of having version as file name suffix. It just immediately say which version of the artifact is used. If you depend on some artifact that is often released, you have to update its version in your EAR's POM anyway, so its "propagation" isn't somehow self-acting. Therefore, I don't see any problem with this file name suffix.

如果这种频繁更改的需求对您来说是个问题,也许您应该考虑以某种方式修改这个频繁发布的工件的开发周期?也许你可以延长它在同一个 SNAPSHOT 版本中花费的时间?即使您经常进行内部"发布(例如 nightbuilds),Maven 也不会强迫您在每次发布时都增加版本(在 Maven 发布插件的意义上).您可以根据需要保留一些 SNAPSHOT 版本.即使在非常快速的敏捷流程(或看板)中,这种真正的"发布通常每隔几周发生一次,而且时间足够长,可以管理.

If this need for frequent change is problematic for you, maybe you should consider to modify somehow this frequently released artifact's development cycle? Probably you can extend a little a time it spend during same SNAPSHOT version? Even if you do frequent "internal" releases (like nightbuilds), Maven doesn't force you to bump your version every release (in sense of Maven Release Plugin). You can stay with some SNAPSHOT version as long as you want. Even in really quick Agile processes (or Kanban) this kind of "real" release usually happens every few weeks and it's long enough to be manageable.

最后,不是这样的,我不会帮助你(或类似的事情)或不想帮助你.我只是认为你试图反对 Maven.如果你接受并遵循它的方法和约定,Maven 真的很强大.根据我的经验,试图解决这个问题(迟早)意味着问题.我已经看到许多项目具有类似 Maven 的 Ant 配置,并且许多开发人员抱怨 Maven 很烂.在弄清楚那里的东西后,我说:Maven 不烂,你的 POM 烂".

At the end, it's not like this I won't help you (or something like this) or don't want to. I just think you're trying to go against Maven. Maven is really powerful if you accept and go with its approach and conventions. From my experience, trying to get around this means problems (sooner or later). I've already seen many projects that had Maven-like-Ant configuration and many developers around complaining that Maven sucks. After figuring out the stuff there I said them: "Maven doesn't suck, your POMs do".

这篇关于如何将依赖项包含在文件名中没有版本的 EAR 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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