Using the maven-remote-resources-plugin and specifying the resourcesDirectory

后端 未结 2 1823
[愿得一人]
[愿得一人] 2021-01-20 02:16

I\'m trying to override the default resources directory (src/main/resources) when using the maven-remote-resources-plugin. However the specified value in the sample

相关标签:
2条回答
  • 2021-01-20 02:47

    kly is right about it not copying resources for you (I apologize, I cannot comment yet - not enough reputation).

    With the "bundle" goal, you are only generating a manifest with a list of the included resources. The manifest must be packaged in an artifact along with the resources themselves, which will only happen in your instance if you also use copy-resources to put them in the target/classes directory.

    You then must use the "process" goal, and list your bundle, in any other project you wish to use the resources from.

    0 讨论(0)
  • 2021-01-20 03:01

    Why do you need maven-remote-resources-plugin?

    If your goal is to override the default resources directory ,then you can use mvn resources:copy-resources, since it's more flexible. An example here.

    Alternative

    You can also use the resources goal provided by resources plugin, and specify the resources in pom file's block. Example here.


    Edit

    About maven-remote-resources-plugin, see the usage page:

    This will trigger the scanning of that project's $basedir/src/main/resources directory and create the $basedir/target/classes/META-INF/maven/remote-resources.xml manifest file.

    That means this plugin will create the remote-resources.xml file, but it doesn't mean that it will copy the resources for you.

    I created an empty maven project using your plugin configuration, and it actually did create an remote-resources.xml file. Also, it did not copy the files under ${basedir}/common

    To do that, just specify the resources in build section. Example:

    <build>
            <resources>
                <resource>
                    <directory>${basedir}/common</directory>
                </resource>
                <resource>
                    <directory>${basedir}/src/main/resources</directory>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-remote-resources-plugin</artifactId>
                    <version>1.5</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>bundle</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <resourcesDirectory>${basedir}/common</resourcesDirectory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </configuration>
                </plugin>
            </plugins>
    </build>
    
    0 讨论(0)
提交回复
热议问题