使用 Maven jar 打包目标/类以外的内容
我使用maven jar插件来打包jar文件。但看起来 Maven jar 插件只打包目标/类中的内容。我还想将许多其他目录中的目标/类和(资源和类)文件中的所有类打包。我怎样才能用maven jar 做到这一点?
I am using maven jar plugin to package the jar file. But it looks like maven jar plugin just only pack the stuff that stay inside target/classes. I am also want to pack all the classes in target/classes and (resource and class) files from many other directories. How can i do that with maven jar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不能(或只是不想)将它们放在
src/main/resources
下,则可以使用
元素声明其他资源位置:请参阅指定资源目录。
插件生成源的约定是在
target/ generated-sources/
中生成它们,并且一个实现良好的插件应该添加指定路径作为源目录(以便编译生成的代码)。当他们不这样做时,Build Helper Maven 插件可以来救援。如果您要生成类,为什么不在
${project.build.outputDirectory}
(即默认情况下target/classes
)中生成它们)?我认为无论如何你都不能添加第二类目录。如果这没有帮助,请澄清您的确切限制和要求。
参考文献
If you can't (or just don't want to) put them under
src/main/resources
, you can declare additional resource locations using the<resource>
element:See Specifying resource directories.
The convention with plugins generating sources it to generate them in
target/generated-sources/<tool>
and a well implemented plugin should add the specified path as a source directory (so that generated code would be compiled). When they don't, the Build Helper Maven Plugin can come to the rescue.If you are generating classes, why don't you generate them in
${project.build.outputDirectory}
(i.e.target/classes
by default)? I don't think you can add a 2nd classes directory anyway.If this doesn't help, please clarify your exact constraints and requirements.
References