在Maven项目中包括非Java源代码 [英] Including non-Java sources in a Maven project

查看:81
本文介绍了在Maven项目中包括非Java源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始一个项目,我希望它将包含大量的非Java代码(主要是shell和SQL脚本).

I'm starting on a project that I expect will include a substantial amount of non-Java code (mostly shell and SQL scripts).

我仍然想用Maven管理这个项目.非Java源代码和Maven的最佳实践是什么?源应该去哪里?在不同的生命周期阶段,他们会发生什么?任何指向更多信息的指针或链接将不胜感激.

I would still like to manage this project with Maven. What are the best practices wrt non-Java source code and Maven? Where should the source go? What happens to them during the different lifecycle phases? Any pointers or links to more information would be greatly appreciated.

推荐答案

如果您不想像heckj所建议的那样将这些Java文件包含在JAR文件中,则不得将非Java代码放入资源中.资源中的所有内容都会自动复制到JAR文件中,我想您不希望将shell脚本和SQL脚本包含在JAR文件中,对吗?

You must not put the non-Java code into resources, if you don't want to include these files into your JAR files like heckj has suggested. Everything that is located in resources is automatically copied into the JAR file and I guess you don't want shell scripts and SQL scripts be included in a JAR file, right?

因此,Maven的方式是在src/main下创建其他文件夹.例如.为您的SQL脚本创建一个 sql 文件夹,为您的Shell脚本创建一个 sh 文件夹,依此类推.这是其他Maven插件也需要来源的位置,例如用于C ++,Groovy等.

So the Maven way would be to create additional folders under src/main. E.g. create a sql folder for your SQL scripts, an sh folder for your shell scripts and so on. This is the location where other Maven plugins also expect sources, e.g. for C++, Groovy and so on.

这篇关于在Maven项目中包括非Java源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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