使用 Maven jar 打包目标/类以外的内容

发布于 2024-09-30 20:53:11 字数 114 浏览 0 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦罢 2024-10-07 20:53:11

资源文件位于项目的另一个文件夹中。

如果您不能(或只是不想)将它们放在 src/main/resources 下,则可以使用 元素声明其他资源位置:

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory> [your folder here] </directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>

请参阅指定资源目录

其他类是生成的类。

插件生成的约定是在target/ generated-sources/中生成它们,并且一个实现良好的插件应该添加指定路径作为源目录(以便编译生成的代码)。当他们不这样做时,Build Helper Maven 插件可以来救援。

如果您要生成,为什么不在${project.build.outputDirectory}(即默认情况下target/classes)中生成它们)?我认为无论如何你都不能添加第二类目录。

如果这没有帮助,请澄清您的确切限制和要求。

参考文献

The resource files stays in another folder of project.

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:

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory> [your folder here] </directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>

See Specifying resource directories.

The other classes are generated classes.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文