使用maven-remote-resources-plugin并指定resourcesDirectory [英] Using the maven-remote-resources-plugin and specifying the resourcesDirectory

查看:115
本文介绍了使用maven-remote-resources-plugin并指定resourcesDirectory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 maven-remote-resources-plugin 时,我试图覆盖默认资源目录(src/main/resources).但是,似乎没有考虑以下示例中的指定值.如果有人可以给我一些指点,我们将不胜感激.

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 below doesn't seem to be taken into account. Would appreciate if someone could give me some pointers.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>my.resource.library</groupId>
    <artifactId>resource-library</artifactId>
    <version>1.0</version>
    <name>ResourceLibrary</name>

    <build>
        <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>

</project>

我想知道这是否是插件中的错误,因为我在构建的DEBUG输出中看到以下内容,这表明它试图使用正确的资源目录.调试输出中没有其他相关内容.

I'm wondering if this is a bug in the plugin, since I see the following in the DEBUG output of the build, which implies that its attempting to use the correct resources directory. Nothing else relevant appears in the debug output.

[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-remote-resources-plugin:1.5:bundle' with basic configurator -->
[DEBUG]   (f) includes = [**/*]
[DEBUG]   (f) outputDirectory = C:\jit\workspace\ResourceLibrary\target\classes
[DEBUG]   (f) resourcesDirectory = C:\jit\workspace\ResourceLibrary\common

我认为这实际上可能是一个错误,因此提出了: MRRESOURCES-96

I think this may actually be a bug so have raised: MRRESOURCES-96

推荐答案

为什么需要maven-remote-resources-plugin?

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

如果您的目标是override the default resources directory,则可以使用此处.

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.

替代

您还可以使用资源插件提供的resources目标,并在pom文件的块中指定资源.示例此处.

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

编辑

关于maven-remote-resources-plugin,请参见用法页:

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

这将触发对该项目的$ basedir/src/main/resources目录的扫描,并创建$ basedir/target/classes/META-INF/maven/remote-resources.xml清单文件.

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.

这意味着该插件将创建remote-resources.xml文件,但这并不意味着它将为您复制资源.

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

我使用您的插件配置创建了一个空的maven项目,实际上它确实创建了remote-resources.xml文件.此外,它没有复制$ {basedir}/common

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

要执行此操作,只需在build部分中指定资源.示例:

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>

这篇关于使用maven-remote-resources-plugin并指定resourcesDirectory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆