如何来包括依赖关系到一个EAR没有版本的文件名(How to include dependencie

2019-06-23 12:09发布

我创建的.ear使用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样子乔达时间-1.6.2.jar, 公共-IO-1.4.jar等。

但同时,我有相关性,我想有没有版本。 例如,我该怎么办,那依赖性SLF4J-API-1.5.6.jar看起来像SLF4J-api.jar文件在我的.ear

Answer 1:

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.

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.

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".



Answer 2:

我完全米哈尔卡里诺夫斯基同意。 但是,我掉进了同样的情况,那么,实际上是一个逆情况 - 有人已经配置了项目排除在最终的EAR版本,我一直在寻找一种方式来取消这个,因为它是违反了Maven的生活方式,所以我VE搜查网页,发现过这个问题,但答案我在代码本身找到。 您可以使用:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-ear-plugin</artifactId>
   <configuration>
        <version>5</version>
    <defaultLibBundleDir>lib</defaultLibBundleDir>
    <fileNameMapping>no-version</fileNameMapping>
   </configuration>
</plugin>

与标签fileNameMapping该生产线是你想要的。 我希望这可以帮助。



文章来源: How to include dependencies into an EAR without version in the file name