Linux Pom.xml - tar 任务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3677233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:28:17  来源:igfitidea点击:

Pom.xml - tar task

maven-2tar

提问by fatnjazzy

Is it possible to add a task to the pom.xml file that will create a tar.gz / .zip file.
for eample:

是否可以在 pom.xml 文件中添加一个任务来创建 tar.gz / .zip 文件。
例如:

<tar type="tar.gz" source="resources/sql" tofile="target/sql.tar.gz"/>

Thanks

谢谢

回答by JoseK

Use the maven-assembly-plugin

使用 maven-assembly-plugin

Create a src/main/assembly/bin.xml as detailed at http://maven.apache.org/plugin-developers/cookbook/generate-assembly.htmland http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#bin

创建一个 src/main/assembly/bin.xml,详见http://maven.apache.org/plugin-developers/cookbook/generate-assembly.htmlhttp://maven.apache.org/plugins/maven-程序集插件/descriptor-refs.html#bin

Put your resources sql files in the includesand give the format of outputas tar.gz

把你的资源 sql 文件放在里面,includes并给出outputtar.gz的格式

Next, in your pom.xml put the reference to this plugin

接下来,在您的 pom.xml 中放置对此插件的引用

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <configuration>
          <descriptors>
            <descriptor>src/main/assembly/bin.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
            </phase>              
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

Last, call this using

最后,调用它使用

mvn package