java - 构建 dmg 文件时出现 BUILD FAILED 错误

标签 java macos deployment ant dmg

我正在使用 ant 工具构建 dmg 文件,但构建时出现错误。

build.xml 摘录:

            ...
            <copy todir="${mac.build.dir}/.background">
                    <fileset file="${basedir}/build/installer/images/mac/dmgBackground.png"/>
            </copy>

            <symlink link="${mac.build.dir}/Applications" overwrite="true" resource="/Applications" />
            <echo message="Create tmp.dmg"/>
            <exec executable="hdiutil" failonerror="true">
                    <arg line="create -srcfolder '${mac.build.dir}' -volname '${mac.volname}' -fs HFS+ -fsargs '-c c=64,a=16,e=16' -format UDRW '${target}/tmp.dmg'"/>
            </exec>
            ....

错误:

**BUILD FAILED
D:\DevProjects\spark\build\build.xml:761: Could not launch ln: java.io.IOException: Cannot run program "ln": CreateProcess error=2, The system cannot find the file specified**

我使用脚本来调用dmg文件创建是ant installer.mac

我调用的是正确的目标还是错误的目标?

最佳答案

Ant 的 symlink 任务不适用于 Windows 变体。

参见:Ant symlink task on windows (NTFS)

来自Ant documentation :

Manages symbolic links on Unix based platforms. Can be used to make an individual link, delete a link, create multiple links from properties files, or create properties files describing links in the specified directories. Existing links are not overwritten by default.

...和...

LIMITATIONS: Because Java has no direct support for handling symlinks this task divines them by comparing canonical and absolute paths. On non-unix systems this may cause false positives. Furthermore, any operating system on which the command ln -s is not a valid command on the command line will not be able to use action="single" or action="recreate". Action="record" and action=delete should still work. Finally, the lack of support for symlinks in Java means that all links are recorded as links to the canonical resource name. Therefore the link: link --> subdir/dir/../foo.bar will be recorded as link=subdir/foo.bar and restored as link --> subdir/foo.bar

<小时/>

至于如何解决这个问题,我现在一无所知,因为我以前从未制作过DMG。但是,符号链接(symbolic link)是指向“应用程序”文件夹的链接,可能就在那里,以便用户有一个方便的链接来将应用程序拖动到其中,以便将其复制到“应用程序”中。因此,该链接可能不是绝对必要的。如果有人能对此有所启发,请这样做。

关于java - 构建 dmg 文件时出现 BUILD FAILED 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10168405/

相关文章:

java - 为什么顺序流和并行流的归约结果不同?

Java读取文件并将字符串存储到数组中

java - 安全删除通行证数量

grails - 在 Jetty 上部署 Grails war 会产生 ConcurrentModificationException

java - 如何在 Java 中构造类型?

objective-c - NSTableView的行号

linux - 在终端 (Mac) 中的目录之间复制所有文件

python - 在 osx 上显示菜单栏图标

angular - 每个分支的 Azure Devops azure-pipelines.yml

deployment - 覆盖容器规范中定义的 env 值