0

ファイルシステムのフォルダーにデプロイしたいかなり単純な Maven アセンブリがあります。抽出コマンドを使用して Maven ビルドをチェーンすることは間違いなく可能ですが、ファイルをデプロイする場所のプロパティを渡すことにより、Maven 内から次のことを行う方法はありますか?

mvn install && tar -C /my/deployment/folder xvzf target/${project.artifactId}-${project.version}-default.tar.gz ${project.artifactId}-${project.version}-default/

Mavenにいくつかの構成を提供して、次のようなことができる方法はありますか:

mvn install deploy -DdeploymentDir=/my/deployment/folder
4

1 に答える 1

0

dir<format>dir</format>を使用して、解凍されたディレクトリを取得します

        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptors>
                    <descriptor>path/to/assembly.xml</descriptor>
                </descriptors>
            </configuration>
        </plugin>

assembly.xml

    <?xml version="1.0" encoding="GBK"?>
    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1">
        <id></id>
        <baseDirectory>${project.artifactId}-${project.version}-default/</baseDirectory>
        <formats>
            <format>dir</format>
        </formats>

        <fileSets>
            <fileSet>
                <directory>../../path/to/${project.artifactId}-${project.version}-default/</directory>
                <outputDirectory></outputDirectory>
                <includes>
                    <include>**/**</include>
                </includes>
            </fileSet>
        </fileSets>
    </assembly>

antrun を使用して dest dir にコピーします

    <plugin>   
       <artifactId>maven-antrun-plugin</artifactId>    
         <executions>     
        <execution>
        <phase> ... choose after assembly </phase>        
               <goals>            
                     <goal>run</goal>        
               </goals>             
               <configuration>       
                     <tasks>          
                         <copy todir="/tmp/xx" >        
                        <fileset dir="target/${project.build.finalName}"/>
                </copy>
                     </tasks>          
               </configuration>        
        </execution>    
         </executions>  
    </plugin>  
于 2013-01-19T08:56:07.363 に答える