简体   繁体   中英

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.

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. I do not see anything copied over in the target directories of the modules that depend on Core.

Here is the output of that part when I 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.

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.

Basically, I have 3 questions:

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. I'm probably misunderstanding something important about maven so if something sounds weird please tell me.

Where is it copying from?

your worries come from 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

Why isn't it copying anything right now?

He tries to read in the following package **/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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