如何使用 maven 3 从最终构建 zip 存档中删除目录

发布于 2025-01-07 15:38:39 字数 2268 浏览 0 评论 0原文

当构建准备就绪时,我在不同平台的所有构建存档中都有 p2 文件夹。据我所知,不可能在构建阶段从存档中排除 p2 目录。因此,我尝试自己打包存档,而不是使用存档产品执行。 问题是如果我想为其他平台或架构制作档案,我将需要更改 pom.xml。 现在我有以下构建模式:

  <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-director-plugin</artifactId>
                <version>${tycho-version}</version>
                <executions>
                    <execution>
                        <id>materialize-products</id>
                        <goals>
                            <goal>materialize-products</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>pack-zip-files</id>
                            <phase>package</phase>
                        <configuration>
                            <target>
                                <zip basedir="${project.build.directory}/products/xxx/win32/win32/x86"
                                    destfile="${project.build.directory}/products/xxx-1.0.${BUILD_NUMBER}-win32.win32.x86.zip"
                                    excludes="${exclude_p2}" />
                                <zip basedir="${project.build.directory}/products/xxx/linux/gtk/x86"
                                    destfile="${project.build.directory}/products/xxx-1.0.${BUILD_NUMBER}-linux.gtk.x86.zip"
                                    excludes="${exclude_p2}" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
</build>

问题是如何从所有 zip 文件中删除 p2 文件夹?

When the build is ready i have p2 folder in all build archives for different platforms.As i understand it's imposible to exclude p2 directory from archives on building stage. So I try pack archive myself instead of using archive-products execution.
The problem is if i want to make archives for others platform or architecture I will need to change pom.
Now i have the following build schema:

  <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-director-plugin</artifactId>
                <version>${tycho-version}</version>
                <executions>
                    <execution>
                        <id>materialize-products</id>
                        <goals>
                            <goal>materialize-products</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>pack-zip-files</id>
                            <phase>package</phase>
                        <configuration>
                            <target>
                                <zip basedir="${project.build.directory}/products/xxx/win32/win32/x86"
                                    destfile="${project.build.directory}/products/xxx-1.0.${BUILD_NUMBER}-win32.win32.x86.zip"
                                    excludes="${exclude_p2}" />
                                <zip basedir="${project.build.directory}/products/xxx/linux/gtk/x86"
                                    destfile="${project.build.directory}/products/xxx-1.0.${BUILD_NUMBER}-linux.gtk.x86.zip"
                                    excludes="${exclude_p2}" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
</build>

The quiestion is how to remove p2 folder from all zip files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回心转意 2025-01-14 15:38:39

你现在所做的确实是唯一的方法。您可以将打包类型更改为 eclipse-application ,并且不会创建该目录,但它是一种已弃用的打包类型,并且存在大量问题。

帮助实现多个 POM 支持的唯一方法是将 POM 配置放入配置文件中,并让构建产品的项目继承它。您还可以使用 osgi.os osgi.arch 属性来代替 win32linux 等硬编码内容>。

What you are doing now is really the only way to do it. You could change the packaging type to eclipse-application and that directory won't be created, but it is a deprecated packaging type and has a whole slew of problems.

The only way to help with multiple POM support would be to put that POM configuration into a profile and have your projects that build products inherit from it. You can also use the osgi.os osgi.arch properties in place of hard-coding things like win32 and linux.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文