如何在maven安装目标目录中包含文件夹中的特定文件?

时间:2016-05-04 06:27:16

标签: maven pom.xml

目录结构

conf
    axis2.aar
        com
        lib
        META-INF
        axis2.xml
        build.xml
        common-logging.properties
        log4j.properties
        *.class

我希望在执行maven安装时,只有axis2.xml应包含在目标文件夹的axis2.aar中。我尝试了许多包含和排除组合,但没有 工作。做maven安装后,它取整个axis2.aar内容。我也尝试过滤,将其设置为true。请提出一些解决方案。

的pom.xml

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CUDB_HSS</groupId>
<artifactId>CUDB_HSS</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>wsdl</directory>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>conf/axis2.aar</directory>
            <filtering>true</filtering>
            <includes>
            <include>**/*.xml</include>
         </includes>
            <excludes>
                <exclude>**/*.java</exclude>
                <exclude>**/*.properties</exclude>
            </excludes>
        </resource>
    </resources>


    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
        </plugin>

        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <id>default-jar</id>
                    <phase>never</phase>
                    <configuration>
                        <finalName>unwanted</finalName>
                        <classifier>unwanted</classifier>
                     </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-aar-maven-plugin</artifactId>
            <version>1.6.4</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                <id>cudb-hss-aar</id>
                <phase>package</phase>
                <goals>
                    <goal>aar</goal>
                </goals>
                <configuration>
                    <aarDirectory>conf/axis2.aar</aarDirectory>
                    <aarName>axis2</aarName>
                    <filesets>
                        <fileset>
                            <directory>conf/axis2.aar</directory>
                            <outputDirectory>target</outputDirectory>
                            <includes>
                                <include>**/*.xml</include>
                            </includes>
                            <excludes>
                                <exclude>**/*.properties</exclude>
                            </excludes>
                        </fileset>
                    </filesets>

            </configuration>
          </execution>
        </executions>      
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>cudb-hss</id>
                    <phase>package</phase>
                    <configuration>
                        <classifier>client1</classifier>
                            <finalName>cudb-hss</finalName>
                            <includes>
                                <include>com/accenture/**/*.class</include>
                                <include>macro_CUDB_Accenture_HSS.class</include>
                                <include>**/com/accenture/il/interfaces/cudb/hss/conf/jaxb/**/*.properties</include>
                                <include>**/com/accenture/il/interfaces/cudb/hss/error/bean/jaxb/**/*.properties</include>        
                                <include>**/*.properties</include>
                            </includes>
                     </configuration>
                     <goals>
                        <goal>jar</goal>
                    </goals>    
                    </execution>  
                </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <executions>
     <execution>
     <id>cudb-hss-wsdl</id>
     <phase>package</phase>
     <configuration>
     <classifier>client2</classifier>
     <finalName>cudb-hss-wsdl</finalName>
      <includes>
     <include>com/ericsson/**/*.class</include>
     <include>**/com/ericsson/**/jaxb.properties</include>
     </includes> 
     </configuration>
     <goals>
     <goal>jar</goal>
     </goals>    
    </execution>  
    </executions>
  </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

您的问题的答案可以是:

                    <fileset>
                        <directory>conf/axis2.aar</directory>
                        <outputDirectory>target</outputDirectory>
                        <includes>
                            <include>axis2.xml</include>
                        </includes>
                    </fileset>