【问题标题】:zip some modules including target directory from multi-module maven project压缩一些模块,包括来自多模块 maven 项目的目标目录
【发布时间】:2021-05-28 12:34:49
【问题描述】:

我有一个具有以下层次结构的多模块 maven 项目,并希望在 mvn 构建和 curl 之后创建一个 zip 或将其上传到一个私有存储库。我正在使用 maven-assembly-plugin 但它不包括所需的目录。请您给点建议吗?

|--subproject1
   |--src/main/..
   |--resoruces/..
   |target/..
   |pom.xml
|--subproject2
   |--src/main/..
   |--resoruces/..
   |pom.xml
pom.xml```

content of zip.xml

    <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>project</id>
        <formats>
            <format>zip</format>
        </formats>
        <includeBaseDirectory>false</includeBaseDirectory>
        <!--<fileSet></fileSet>-->
          <fileSets>
            <fileSet>
                <directory>${project.basedir}/subproject1</directory>
                <outputDirectory></outputDirectory>
                <useDefaultExcludes>true</useDefaultExcludes>
                <excludes>
                    <exclude>**/*.log</exclude>
                </excludes>
            </fileSet>
          </fileSets>
            <files>
                <file>
                    <source> ${project.basedir}/pom.xml</source>
                    <outputDirectory>/</outputDirectory>
                </file>
            </files>
    
    </assembly>
    
    below plugin is added in pom.xml of subproject1
    <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <appendAssemblyId>true</appendAssemblyId>
                                <descriptors>
                                    <descriptor>zip.xml</descriptor>
                                </descriptors>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

我想创建一个包含 src、resources 和 target 文件夹的 subproject1 的 zip。请协助。

【问题讨论】:

  • 使用 jar 命令我可以用工件准备一个 zip 文件

标签: java spring maven maven-plugin maven-assembly-plugin


【解决方案1】:

使用“jar -cf project.zip project-name”命令,正在创建 zip。

【讨论】:

    猜你喜欢
    • 2013-12-13
    • 2012-06-20
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    • 2016-06-12
    • 1970-01-01
    • 2021-02-09
    相关资源
    最近更新 更多