自定义文件作为依赖项
我有一个包含多个模块的 Maven 项目,
其中一个模块生成一个自定义的二进制文件。我需要这个文件作为另一个模块的输入。
我想做的就是获取这个文件作为依赖项,并在 ant 脚本的帮助下在其他模块中使用它。
我尝试了很多 Maven Assembly Plugin 和 dependency:copy-dependencies 插件,但没有成功
感谢您的任何建议
I have a maven project with several modules,
One of these modules produces a custom, binary file. I need this file as input in another module.
What I want to do, is to fetch this file as dependency an use it in an other module with the help of an ant-script.
I tries a lot with Maven Assembly Plugin and dependency:copy-dependencies plugin, but with no success
Thanks for any suggestions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

我对我的一个项目有非常相似的要求。我试图在这里综合它,我希望这可以帮助您:
假设该项目的结构如下:
让我们从 projectfoo pom 开始:
简单......
现在是模块 1
:。 .. 和描述符文件 (src/main/assemble/resources.xml):
我假设您之前已经以某种方式生成了二进制资源并将其存储在src/main/resources。上面的代码所做的只是创建资源的 zip 工件,这是简化其作为 module2 中的 Maven 依赖项注入的必要步骤。
因此,现在我们只需将此 zip 工件添加为模块 2 中的依赖项:
...最后使用 maven-dependency-plugin 解压它,最好在 module2 的类路径中(目标/类):
...就是这样!
雅尼克.
I had a very similar requirement for a project of mine. I am trying to synthesize it here, I hope this could help you :
Let's say that the project is structured as follow :
Let's start with the projectfoo pom :
Easy....
Now the module 1 :
... and the descriptor file (src/main/assembly/resources.xml) :
I assume here that you have previously generated your binary resource one way or another and stored it in src/main/resources. What the code above does is just creating a zip artifact of your resource, this is a necessary step to ease its injection as a maven dependency in module2.
So, now we just have to add this zip artifact as a dependency in module 2 :
... and finally unzip it with the maven-dependency-plugin, ideally in the classpath of module2 (target/classes) :
... and that's it !
Yannick.