首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven和maven-resources-plugin

Maven和maven-resources-plugin
EN

Stack Overflow用户
提问于 2012-11-18 19:03:05
回答 1查看 21.5K关注 0票数 1

我想使用maven-resources-plugin将资源复制到另一个目录。

我的资源目录结构如下:

代码语言:javascript
复制
log4j.xml
xml
  |_ resource-1
  |_ resource-n

我只想将log4.xml复制到输出目录。这是我的插件代码:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <outputDirectory>${glassfish.conf}</outputDirectory>
            <resources>
                <resource>
                    <directory>${conf.location}</directory>
                    <includes>
                        <include>**/log4j.xml</include>
                    </includes>
                    <excludes>
                        <exclude>**/xml/*</exclude>
                    </excludes>
                </resource>
            </resources>
        </configuration>
        <executions>
            <execution>
                <id>copy-log4j-to-glassfish</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
            </execution>
        </executions>
</plugin>

但所有内容都被复制到输出目录(log4j.xml和xml目录)。

我试过了

代码语言:javascript
复制
<resource>
    <directory>${conf.location}</directory>
        <excludes>
            <exclude>**/xml/*</exclude>
        </excludes>
</resource>

代码语言:javascript
复制
<resource>
    <directory>${conf.location}</directory>
    <includes>
        <include>**/log4j.xml</include>
    </includes>                         
</resource>

甚至

代码语言:javascript
复制
<resource>
    <directory>${conf.location}</directory>
    <excludes>
        <exclude>**/*</exclude>
    </excludes>
</resource>

但是目录的所有内容都是included...What是问题所在吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-19 16:53:45

要回答安德鲁·洛格维诺夫:

有了这样的插件:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>copy-log4j-to-glassfish</id>
            <phase>package</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${glassfish.conf}</outputDirectory>
                <resources>
                    <resource>
                        <directory>${conf.location}</directory>
                        <includes>
                            <include>log4j.xml</include>
                        </includes>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

它工作得很好,只复制了log4j.xml。

现在有了这个插件配置:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <executions>
        <execution>
            <id>copy-log4j-to-glassfish</id>
            <phase>package</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <outputDirectory>${glassfish.conf}</outputDirectory>
        <resources>
            <resource>
                <directory>${conf.location}</directory>
                <includes>
                    <include>log4j.xml</include>
                </includes>
            </resource>
        </resources>
    </configuration>
</plugin>

我的所有文件都被复制了。

我检查了一下xsd、here是不是configuration块,可以在plugin中,也可以在execution标记中,所以我不知道这是不是一个插件bug,或者这是对我的误解。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13439520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档