Maven项目变量的依赖关系 [英] Maven project variables for dependencies

查看:88
本文介绍了Maven项目变量的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个加载小程序的html文件. html需要按名称引用jar,并且由于maven根据工件ID,版本等来命名它,因此html需要随着项目的发展而动态更新.似乎资源过滤是解决之道,但我无法弄清楚要插入的变量应该是什么样.我想要一些类似于$ {project.dependencies.myartifactid.version}的东西,但这似乎不是一个选择,而且我在谷歌搜索中遇到了不幸.

I have an html file which loads an applet. The html needs to refer to the jar by name, and since maven names it based on the artifactid, version, etc, the html needs to be dynamically updated as the project evolves. It seems like resource filtering is the way to go, but I can't figure out what the variable to interpolate should look like. I'd like something along the lines of ${project.dependencies.myartifactid.version}, but that doesn't seem to be an option and I've had woeful luck googling.

推荐答案

您将需要类似${project.dependencies[0].artifactId}的内容,其中0是war模块中applet依赖项的索引(请参阅

You'll need something like ${project.dependencies[0].artifactId} where 0 is the index of the dependency of the applet in your war module (see PLXUTILS-37). And indeed, using resources filtering should work.

更新:看来Maven资源插件中存在错误,该属性未按照此答案.

Update: It appears that there is bug in the Maven Resources Plugin, this property doesn't get filtered as mentioned in this question. You may have to use the workaround suggested in this answer.

这篇关于Maven项目变量的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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