maven-remote-resources-plugin不会将资源存入/ target / classes

时间:2015-08-31 15:35:22

标签: java maven

我正在尝试使用maven-remote-resources-plugin在多个项目中共享远程资源。

我在\ src \ main \ resources中有一个包含资源文件的jar。 pom是:

...
<build>
    <plugins>
        <plugin>
            <artifactId>maven-remote-resources-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                    <configuration>
                        <includes>
                            <include>*.*</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
...

当我在这个项目上运行mvn install时,会创建包含\ src \ main \ resources中所有文件的\ target \ classes \ META-INF \ maven \ remote-resources.xml文件。

这似乎是正确的。

问题在于需要资源的项目。 我在pom中有这个:

...
<plugin>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.5</version>
    <executions>
        <execution>
            <goals>
                <goal>process</goal>
            </goals>
            <configuration>
                <resourceBundles>
                    <resourceBundle><groupId>:<artifactId>:<version></resourceBundle>
                </resourceBundles>
            </configuration>
        </execution>
    </executions>
</plugin>
...

当我在这个项目上运行mvn install时,我在控制台上得到了这个:

[INFO] --- maven-remote-resources-plugin:1.5:process (default) @ <project> --- 
Downloading: <repository>/<groupId>/<artifactId>/<version>/maven-metadata.xml
781/781 B   
Downloaded: <repository>/<groupId>/<artifactId>/<version>/maven-metadata.xml (781 B at 38.1 KB/sec)

所以似乎找到并下载了资源包。

maven-remote-dependency-plugin的Apache文档中,有人说:

  

这将从POM中指定的远程存储库中检索apache-jar-resource-bundle-1.0.jar,处理包中的每个资源并将它们存放在项目$ basedir / target / classes目录中。

但是,文件不会复制到目录中。

我错过了什么或做错了什么?

Maven版本3.3.1

提前感谢您的回答。

1 个答案:

答案 0 :(得分:1)

最后一切正常。

不知道我是否看不到创建的文件夹(默认为${project.build.directory}/maven-shared-archive-resources,而 ${basedir}/target/classes就像是说在文档中)或我的已安装/部署的资源项目中出现了问题。

但是,使用上面的代码,我将所有资源都复制到具有资源依赖性的项目的${project.build.directory}/maven-shared-archive-resources目录中(在pom中定义了进程目标的那些目录)。

如果您想要更改复制资源的目录,只需在<outputDirectory>中的流程目标配置中添加pom.xml选项。