简体   繁体   English

Maven依赖插件未正确复制资源

[英]resources not properly copying with maven-dependency-plugin

I'm trying to get maven to copy some resources (specifically a master.css file) from a Core module into all modules that depend on it. 我正在尝试使Maven将一些资源(特别是master.css文件)从Core模块复制到依赖于它的所有模块中。

I'm attempting to use the first answer on this question: 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> 

I put this code in the pom.xml file for Core (not the parent project -- is that right?)/ But I'm having trouble with it -- I am unsure I'm doing everything correctly. 我将此代码放在Core的pom.xml文件中(不是父项目-是吗?)/但是我遇到了麻烦-我不确定我做的是否正确。 I do not see anything copied over in the target directories of the modules that depend on Core. 在依赖Core的模块的目标目录中,没有看到任何复制的内容。

Here is the output of that part when I mvn clean install: 这是我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

where {project-directory} is the full path to my project. 其中{project-directory}是我的项目的完整路径。

My core resources folder looks like this: 我的核心资源文件夹如下所示:

src/main/resources
    /core-resources
        master.css
    /fxml
        ~some stuff~
    /imgs
        ~some stuff~
    /styles
        ~some stuff~

I do not see anything copied over in the target directories of the modules that depend on Core. 在依赖Core的模块的目标目录中,没有看到任何复制的内容。

Basically, I have 3 questions: 基本上,我有3个问题:

Where is it copying from? 它从哪里复制?

Where is it copying to? 它复制到哪里?

Why isn't it copying anything right now? 为什么现在不复制任何内容?

If there's any other information that's needed I can provide that. 如果还有其他需要的信息,我可以提供。 I'm not very good at maven and honestly the maven docs are Greek to me. 我不太擅长Maven,老实说,Maven文档对我来说是希腊文。 I'm probably misunderstanding something important about maven so if something sounds weird please tell me. 我可能误解了有关Maven的一些重要信息,因此,如果听起来有些奇怪,请告诉我。

Where is it copying from? 它从哪里复制?

your worries come from PATH : 您的担心来自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> 

Where is it copying to? 它复制到哪里?

he tries to copy in **/core-resources 他尝试复制**/core-resources

Why isn't it copying anything right now? 为什么现在不复制任何内容?

He tries to read in the following package **/core-resources 他尝试阅读以下包**/core-resources

Another is correctly out of plugin version it's 另一个是正确的插件版本

<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>

PS: Sorry for me english. PS:对不起我的英语。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM