我试图让Maven将一些资源(特别是master.css文件)从Core模块复制到依赖于它的所有模块中。
我正在尝试使用此问题的第一个答案:Use a dependency's resources?:
<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的一些重要信息,所以如果听起来有些怪异,请告诉我。
答案 0 :(得分:0)
从哪里复制?
您的担心来自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:对不起,我是英语。