Maven和Maven资源插件
我想使用maven资源插件将资源复制到另一个目录 我的资源目录具有以下结构:Maven和Maven资源插件,maven,Maven,我想使用maven资源插件将资源复制到另一个目录 我的资源目录具有以下结构: log4j.xml xml |_ resource-1 |_ resource-n 我只想将log4.xml复制到输出目录。以下是我的插件代码: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactI
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>
org.apache.maven.plugins
maven资源插件
2.6
${glassfish.conf}
${conf.location}
**/log4j.xml
**/xml/*
复制-log4j-to-glassfish
包裹
复制资源
但所有内容都复制到输出目录(log4j.xml和xml目录)
我试过了
<resource>
<directory>${conf.location}</directory>
<excludes>
<exclude>**/xml/*</exclude>
</excludes>
</resource>
${conf.location}
**/xml/*
或
${conf.location}
**/log4j.xml
甚至
${conf.location}
**/*
但目录中的所有内容都包含在内了…有什么问题吗
感谢您回答安德鲁·洛格维诺夫的问题: 使用这样的插件:
<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>
org.apache.maven.plugins
areconfiguration
块可以在plugin
或execution
标记内,因此我不知道这是插件错误还是对我的误解。要回答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>
org.apache.maven.plugins
WAREconfiguration
块可以在plugin
或execution
标记内,因此我不知道这是插件错误还是对我的误解。将配置
移出执行
是否是把配置
移出执行
的把戏
<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>
<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>