有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java POM,用于压缩项目

是否有可能创建一个POM,在包或更大的包上,它仅仅组装整个项目(例如,到一个zip文件中)并将其放在目标中

在本例中,项目中没有任何Java代码,它只是我想要打包的一组脚本和文件。为了一致性(因为我们的商店都是Maven),我真的希望有一个POM来做这件事,因为目前我们有一个shell脚本来做这件事

请举例说明

谢谢


共 (1) 个答案

  1. # 1 楼答案

    因此,我以以下内容结束,它在target中创建了一个文件ServerSetupTools-0.1-SNAPSHOT.tar.gz,这对我来说很有用。唯一的缺点是,当文件位于根目录中时,我不确定如何让它拉取这些文件,所以我将它们全部移到了src/main/resources,这对我也很有用。希望这能帮助其他人

    POM文件:

    <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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>ServerSetupTools</artifactId>
    <packaging>pom</packaging>
    <name>ServerSetupTools</name>
    <url>http://maven.apache.org</url>
    <groupId>com.mycompany.utilities</groupId>
    <version>0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <!   Run assembly as part of packaging  >
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>
                            src/main/assembly/assemble.xml
                        </descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase><!  append to the packaging phase.  >
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    

    src/main/assembly/assemble.xml

    <assembly xmlns="http://maven.apache.org/xsd/assembly"
    xsi:schemaLocation="http://maven.apache.org/xsd/assembly-1.0.0.xsd">
    <id>dist</id>
    <formats>
        <format>tar.gz</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <includes>
                <include>*</include>
            </includes>
            <directory>src/main/resources</directory>
            <outputDirectory>bin</outputDirectory>
            <fileMode>0755</fileMode>
        </fileSet>
    </fileSets>