![](/img/trans.png)
[英]maven-dependency-plugin ignores outputDirectory configuration
[英]resources not properly copying with maven-dependency-plugin
我正在尝试使Maven将一些资源(特别是master.css文件)从Core模块复制到依赖于它的所有模块中。
我正在尝试使用此问题的第一个答案: 使用依赖项的资源? :
<build>
<plugins>
<!--Extract core's resources-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>${project.groupId}</includeGroupIds>
<includeArtifactIds>core</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/core-resources</outputDirectory>
<excludes>org/**,META-INF/**,rebel.xml</excludes>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<!--New resource locations-->
<resources>
<resource>
<filtering>false</filtering>
<directory>${project.build.directory}/core-resources</directory>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
我将此代码放在Core的pom.xml文件中(不是父项目-是吗?)/但是我遇到了麻烦-我不确定我做的是否正确。 在依赖Core的模块的目标目录中,没有看到任何复制的内容。
这是我mvn clean install时该部分的输出:
--- maven-dependency-plugin:2.1:unpack-dependencies (unpack) @ Core ---
--- maven-resources-plugin:3.0.2:resources (default-resources) @ Core ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory {project-directory}\Core\target\core-resources
Copying 16 resources
其中{project-directory}是我的项目的完整路径。
我的核心资源文件夹如下所示:
src/main/resources
/core-resources
master.css
/fxml
~some stuff~
/imgs
~some stuff~
/styles
~some stuff~
在依赖Core的模块的目标目录中,没有看到任何复制的内容。
基本上,我有3个问题:
它从哪里复制?
它复制到哪里?
为什么现在不复制任何内容?
如果还有其他需要的信息,我可以提供。 我不太擅长Maven,老实说,Maven文档对我来说是希腊文。 我可能误解了有关Maven的一些重要信息,因此,如果听起来有些奇怪,请告诉我。
它从哪里复制?
您的担心来自PATH:
<build>
<plugins>
<!--Extract core's resources-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>${project.groupId}</includeGroupIds>
<includeArtifactIds>core</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
<overWrite>true</overWrite>
<!-- HERE -->
<outputDirectory>${project.build.directory}/core-resources</outputDirectory>
<excludes>org/**,META-INF/**,rebel.xml</excludes>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<!--New resource locations-->
<resources>
<!-- AND HERE -->
<resource>
<filtering>false</filtering>
<directory>${project.build.directory}/core-resources</directory>
</resource>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
它复制到哪里?
他尝试复制**/core-resources
为什么现在不复制任何内容?
他尝试阅读以下包**/core-resources
另一个是正确的插件版本
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
PS:对不起我的英语。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.