镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

DMG creation fails with Maven build in Jenkins #474

Open

Description

@treimers

Description

When the Maven build is run in our Jenkins DMG creation fails. This results from the fact that an OSA script is run that uses Finder to arrange the size of the DMG image and the position of the icons. This leads to creating a .DS_Store file on the volume.

Unfortunately there is no way to arrange the icons in the DMG volume other than using the Finder. At the end this leads to the decision to

  • create no DMG image when running in headless mode (Jenkins build) or
  • create a simple DMG image that looks a little bit ugly.

We would like to allow the latter and I inspected the code of this plugin.

I made a small modification in GenerateDmg and put the code in charge to run the OSA script into an if clause

	if (!GraphicsEnvironment.isHeadless()) {
		// renders applescript
		Logger.info("Rendering DMG customization applescript ... ");
		File applescriptFile = new File(assetsFolder, "customize-dmg.applescript");
		VelocityUtils.render("/mac/customize-dmg.applescript.vtl", applescriptFile, packager);
		Logger.info("Applescript rendered in " + applescriptFile.getAbsolutePath() + "!");

		// runs applescript
		Logger.info("Running applescript");
		execute("/usr/bin/osascript", applescriptFile, volumeName);
	}

I did a test run with this invocation: mvn -Djava.awt.headless=true clean package

Maybe there are better options? It could be also possible to pass an argument like a headless flag to the OSA script and do not run the Finder commands when headless mode is encountered? Or maybe you have even better ideas?

Versions

Javapackager: 1.7.6
Java: 18.0.2.1
Maven: 3.8.1

Pull request

If you like I can create a pull request when we have discussed and found the best way to handle this situation. I am open for your proposals.

Thanks
Thorsten

Activity

  1. maths22 commented on Sep 1, 2025

    @maths22
    Contributor

    That seems like a reasonable behavior change, though I think it should probably have a config flag to enable it so that it still would fail in a headless environment when using it in a context where you do care about the presentation of the final DMG. A config flag that defaults to auto-detection but allows explicitly opting either in or out could also be a reasonable option here.

  2. fvarrui commented on Sep 2, 2025

    @fvarrui
    Collaborator

    We could add these parameters in MacConfig to define this new behavior:

    <macConfig>
        <headlessMode>false|true</headlessMode> <!-- false by default -->
        <preconfiguredDsStorePath>path/to/custom/.DS_Store</preconfiguredDsStorePath>
    </macConfig>

    The preconfiguredDsStorePath parameter points to a preconfigured .DS_Store. If it's specified, the file should be copied into the DMG before the signing process.

    We might not need the headlessMode parameter (it’s redundant, since we already have GraphicsEnvironment.isHeadless()).

  3. fvarrui commented on Oct 4, 2026

    @fvarrui
    Collaborator

    Also reported in #377 (CircleCI), closed as a duplicate of this one. Same cause: customize-dmg.applescript drives the Finder through osascript, which isn't available or allowed on headless CI agents. A CircleCI workaround is enabling AppleScript support: https://support.circleci.com/hc/en-us/articles/360057033612-Enabling-AppleScript-Support-on-macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions