maven汇编不同的名字

时间:2014-01-20 10:52:26

标签: maven maven-assembly-plugin

我有这个配置:

<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>com.nsn.nms.parser</groupId>
    <artifactId>w4nparser</artifactId>
    <version>1.0</version>
    <url>http://maven.apache.org</url>
    <name>NMSParser</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <!-- <finalName>${project.artifactId}-${project.version}</finalName> -->
        <!-- <finalName>OSS_CD_</finalName> -->
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                        <descriptor>assembly-cisco-ipsla.xml</descriptor>
                        <descriptor>assembly-mpls.xml</descriptor>
                        <descriptor>assembly-juniper-rpm.xml</descriptor>
                    </descriptors>
                    <finalName>OSS_CD_</finalName>
                    <!-- <appendAssemblyId>false</appendAssemblyId> -->
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

带有描述符:

<?xml version="1.0" ?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>${BUILD_NUMBER}-Cisco-IPSLA</id>
    <formats>
        <format>tar.gz</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <baseDirectory>/W4NParser/input/</baseDirectory>

    <fileSets>
        <fileSet>

            <includes>
                <include>/installation/updater.py</include>
                <include>/installation/config.py</include>
                <!--cm-->
                <include>/W4NParser/input/cm/CM_*.xml</include>
                <include>/W4NParser/input/cm/rtt*.xml</include>
                <!--pm-->
                <include>/W4NParser/input/pm/rtt*.xml</include>


                <!--W4N config files-->
                <include>../W4N_config_files/MIB/CISCO-ENHANCED-MEMPOOL-MIB.mib</include>
                <include>../W4N_config_files/MIB/CISCO-RTTMON-RTP-MIB.mib</include>
                <include>../W4N_config_files/MIB/MPLS-TE-STD-MIB[rfc3812].mib</include>
                <include>../W4N_config_files/snmp-masks/NSN-CISCO-RTT-SNMP-DISCOVERY.xml</include>
                <include>../W4N_config_files/snmp-masks/NSN-CISCO-IPSLA-STATSTABLE-SNMP-DISCOVERY.xml</include>
                <include>../W4N_config_files/device-discovery/NSN-CISCO-RTT-DEVICE-DISCOVERY.xml</include>



            </includes>
            <outputDirectory>/w4nparser-cisco-ipsla</outputDirectory>
            <excludes>

            </excludes>
        </fileSet>
    </fileSets>
</assembly>

是否可以为每个描述符生成不同的文件名? 我做了一个id的实验。但是它始终以-显示  例如:

OSS_CD_-32-Cisco-IPSLA.tar.gz

我尝试了不同的方法来移除第一个-,但没有成功。

2 个答案:

答案 0 :(得分:0)

也许有更好的方法,但您如何定义多个<executions/>并定义不同的<configuration/> - s?

请考虑以下事项:

<?xml version="1.0" ?>
<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>com.nsn.nms.parser</groupId>
    <artifactId>w4nparser</artifactId>
    <version>1.0</version>
    <url>http://maven.apache.org</url>
    <name>NMSParser</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <!-- <finalName>${project.artifactId}-${project.version}</finalName> -->
        <!-- <finalName>OSS_CD_</finalName> -->
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                        <descriptor>assembly-cisco-ipsla.xml</descriptor>
                        <descriptor>assembly-mpls.xml</descriptor>
                        <descriptor>assembly-juniper-rpm.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>execution-1</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>OSS_CD_1</finalName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>execution-2</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>OSS_CD_2</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
              <artifactId>exec-maven-plugin</artifactId>
              <groupId>org.codehaus.mojo</groupId>
              <version>1.2.1</version>
              <executions>
                <execution><!-- renames the tar-gz -->
                  <id>remaner</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                  <configuration>
                    <executable>${basedir}/build_script/renamer.py</executable>
                  </configuration>
                </execution>
              </executions>
            </plugin>           
        </plugins>
    </build>
</project>

答案 1 :(得分:0)

我已经尝试了一种适合我的不同方法。 完成后我更改了文件的名称。 添加exec-plugin。 这不是更优雅的解决方案,但它正在发挥作用。

<?xml version="1.0" ?>
<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>com.nsn.nms.parser</groupId>
    <artifactId>w4nparser</artifactId>
    <version>1.0</version>
    <url>http://maven.apache.org</url>
    <name>NMSParser</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <!-- <finalName>${project.artifactId}-${project.version}</finalName> -->
        <!-- <finalName>OSS_CD_</finalName> -->
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                        <descriptor>assembly-cisco-ipsla.xml</descriptor>
                        <descriptor>assembly-mpls.xml</descriptor>
                        <descriptor>assembly-juniper-rpm.xml</descriptor>
                    </descriptors>
                    <finalName>OSS_CD_</finalName>
                </configuration>
            </plugin>
            <plugin>
              <artifactId>exec-maven-plugin</artifactId>
              <groupId>org.codehaus.mojo</groupId>
              <version>1.2.1</version>
              <executions>
                <execution><!-- renames the tar-gz -->
                  <id>remaner</id>
                  <phase>verify</phase>
                  <goals>
                    <goal>exec</goal>
                  </goals>
                  <configuration>
                    <executable>${basedir}/build_script/renamer.py</executable>
                  </configuration>
                </execution>
              </executions>
            </plugin>           
        </plugins>
    </build>
</project>