1

maven-resources-pluginを使用してリソースを別のディレクトリにコピーしたいと思います。

私のリソースディレクトリはこの構造になっています:

log4j.xml
xml
  |_ resource-1
  |_ resource-n

log4.xmlのみを出力ディレクトリにコピーしたいと思います。これが私のプラグインコードです:

<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ディレクトリ)にコピーされます。

私は試した

<resource>
    <directory>${conf.location}</directory>
        <excludes>
            <exclude>**/xml/*</exclude>
        </excludes>
</resource>

または

<resource>
    <directory>${conf.location}</directory>
    <includes>
        <include>**/log4j.xml</include>
    </includes>                         
</resource>

<resource>
    <directory>${conf.location}</directory>
    <excludes>
        <exclude>**/*</exclude>
    </excludes>
</resource>

しかし、ディレクトリのすべてのコンテンツが含まれています...問題は何ですか?

ありがとうございました

4

1 に答える 1

6

Andrew Logvinovに答えるには:

そのようなプラグインで:

<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のみがコピーされます。

このプラグイン構成で今:

<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をチェックすると、configurationブロックがタグの内側pluginまたは内側にある可能性があるexecutionため、これがプラグインのバグなのか、これが私の誤解なのかわかりません。

于 2012-11-19T08:53:45.033 に答える