我如何扩展主 distZip 以便获得包含一些额外文件的 ZIP 文件的副本?

How do I extend the main distZip so I get a copy of the ZIP file with some extra files in it?

我正在尝试使用应用程序插件为我的项目生成多个 zip 文件,以便我可以在 zip 中包含 OS 个特定的 exe 文件。 我在 src/win32/dist 下有 exe 文件,它们最终在 win32 zip 文件中很好,但这就是那个 zip 文件中的全部内容。

我如何配置我的附加发行版,以便它们每个都包含主 zip 中的所有内容以及这些 exe 文件,而不仅仅是这些 exe 文件?

这里有一个配置示例:

distributions {
    //I want win32 to include the same as the 'main' dist plus files in src/win32/dist
    win32 { 
        contents {
            from { libsDir }
        }
    }

    amd64 { 
        contents {
            from { libsDir }
        }
    }
}

目录结构如下:

src/
    win32/
        dist/
            prunsrv.exe        <-- win32 specific exe
    amd64/
        dist/
            prunsrv.exe        <-- amd64 specific exe

我从未使用过 'distribution' 或 'application' 插件;但是通过 'distribution' plugin & Distribution javadoc 的文档,我了解到:

  1. 分发版会自动拉入 src/<distName>/dist 下的文件,这就是您提到的。
  2. 接下来是包含主要分布的内容;为此,将您的 distributions 更改为

    win32 { 
        contents {
            with project.distributions.main.getContents()
        }
    }
    
    amd64 { 
        contents {
            with project.distributions.main.getContents()
        }
    }