Skip to content

8356218: [macos] Document --app-content #26848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sashamatveev
Copy link
Member

@sashamatveev sashamatveev commented Aug 19, 2025

  • Added following note for --app-content on macOS to help and man page: The value should be a directory with the "Resources" subdirectory (or any other directory that is valid in the "Contents" directory of the application bundle). Otherwise, jpackage may produce invalid application bundle which may fail code signing and/or notarization.
  • Added warning if --app-content if it points to non-standard subdirectory in "Contents" directory.
  • Added test to cover warning message.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8356218: [macos] Document --app-content (Enhancement - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26848/head:pull/26848
$ git checkout pull/26848

Update a local copy of the PR:
$ git checkout pull/26848
$ git pull https://git.openjdk.org/jdk.git pull/26848/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26848

View PR using the GUI difftool:
$ git pr show -t 26848

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26848.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 19, 2025

👋 Welcome back almatvee! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Aug 19, 2025

@sashamatveev This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8356218: [macos] Document --app-content

Reviewed-by: asemenyuk

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 71 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Aug 19, 2025

@sashamatveev The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs [email protected] rfr Pull request is ready for review labels Aug 19, 2025
@mlbridge
Copy link

mlbridge bot commented Aug 19, 2025

Webrevs

if (!CONTENTS_SUB_DIRS.stream()
.anyMatch(subDir -> contentDir.getFileName().toString()
.equalsIgnoreCase(subDir))) {
Log.info(MessageFormat.format(I18N.getString(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified down to:

Log.info(I18N.format("warning.non.standard.contents.sub.dir", contentDir));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I copy-paste this code. We have many places with MessageFormat.format(I18N.getString()). Should I file follow up bug to clean-up it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you. I think it is sufficient merely not add new MessageFormat.format() calls and use I18N.format() instead.

@@ -85,3 +85,4 @@ message.codesign.failed.reason.app.content="codesign" failed and additional appl
message.codesign.failed.reason.xcode.tools=Possible reason for "codesign" failure is missing Xcode with command line developer tools. Install Xcode with command line developer tools to see if it resolves the problem.
warning.unsigned.app.image=Warning: Using unsigned app-image to build signed {0}.
warning.per.user.app.image.signed=Warning: Support for per-user configuration of the installed application will not be supported due to missing "{0}" in predefined signed application image.
warning.non.standard.contents.sub.dir=Warning: --app-content value "{0}" points to the non-standard subdirectory in the "Contents" directory of the application bundle.
Copy link
Member

@alexeysemenyukoracle alexeysemenyukoracle Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning is not particularly helpful:

  • It doesn't provide details;
  • It is misleading. The value of the --app-content cli option specifies directories and files that will be copied into the application bundle, not those in the bundle.

I'd issue a warning for every unexpected directory/file found in the value of the --app-content option.

I suggest we have two warning messages:

Warning: The file name of the directory "{0}" specified for the --app-content option is not a standard subdirectory name in the "Contents" directory of the application bundle. The result application bundle may fail notarization.
Warning: The value "{0}" of the --app-content option is not a directory. The result application bundle may fail notarization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.

for (var contentDir : app.contentDirs()) {
if (!CONTENTS_SUB_DIRS.stream()
.anyMatch(subDir -> contentDir.getFileName().toString()
.equalsIgnoreCase(subDir))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why case-insensitive path name comparison on Unix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default macOS is case-insensitive. If I rename MacOS to macos in application bundle, such bundle will still works. I assumed that Resources and resources are same thing. After thinking more about it I think it should be case sensitive comparison. Will change it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to case sensitive comparison.

@@ -123,6 +125,17 @@ private static void validateAppVersion(Application app) throws ConfigException {
}
}

private static void validateAppContentDirs(Application app) {
for (var contentDir : app.contentDirs()) {
if (!CONTENTS_SUB_DIRS.stream()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could replace CONTENTS_SUB_DIRS with a Set<String>, and the inspection with CONTENTS_SUB_DIRS.contains(contentDir.getFileName().toString()).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as suggested.

@sashamatveev
Copy link
Member Author

8356218: [macos] Document --app-content [v3]

  • Fixed latest review comments.
  • Test moved from ErrorTest to AppContentTest.
  • Added setIgnoreExitCode() to JPackageCommand to ignore exit code. Added test case may or may not fail depending on macOS version.

Comment on lines 745 to 748
public JPackageCommand setIgnoreExitCode(boolean v) {
ignoreExitCode = v;
return this;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad. It makes unclear semantics of the JPackageCommand.execute(int expectedExitCode) function.

I suggest adding JPackageCommand.executeIgnoreExitCode() function instead in the following way:

public Executor.Result executeIgnoreExitCode() {
    return execute(Optional.empty());
}

public Executor.Result execute(int expectedExitCode) {
    return execute(Optional.of(expectedExitCode));
} 

private Executor.Result execute(Optional expectedExitCode) {
    // Here goes the implementation of the current execute(int expectedExitCode) function adjusted accordingly
} 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@Test(ifOS = MACOS)
@Parameter({TEST_DIR, "warning.non.standard.contents.sub.dir"})
@Parameter({TEST_DUKE, "warning.app.content.is.not.dir"})
public void testWarnings(String... args) throws Exception {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String... args -> String testPath, String warningId

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@sashamatveev
Copy link
Member Author

8356218: [macos] Document --app-content [v4]

  • Fixed latest comments.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs [email protected] ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants