我想在构建时将项目内的资源复制到 jar 中的特定文件夹中。我在我的内部使用此代码pom.xml:
<resource>
<directory>${basedir}/locale</directory>
</resource>
Run Code Online (Sandbox Code Playgroud)
将 locale 目录中的所有文件复制到我的 jar 中。但文件全部复制到jar文件的根目录下,而不是locale文件夹内。
是否可以使用 Maven 将资源复制到导出的 jar 文件中的特定位置?
您需要使用该targetPath属性。引用 Maven 参考:
targetPath:指定用于放置构建中的资源集的目录结构。目标路径默认为基本目录。通常为将打包在 JAR 中的资源指定的目标路径是 META-INF。
<resource>
<directory>${basedir}/locale</directory>
<targetPath>locale</targetPath>
</resource>
Run Code Online (Sandbox Code Playgroud)