-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8333727: Use JOpt in jpackage to parse command line #28163
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
alexeysemenyukoracle
wants to merge
56
commits into
openjdk:master
Choose a base branch
from
alexeysemenyukoracle:JDK-8333727
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18,471
−6,636
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
91dfca5
LinuxPackagingPipeline, WinPackagingPipeline: add normalizeShortcuts()
alexeysemenyukoracle be6d513
LauncherStartupInfoBuilder: bugfix; CfgFile: remove null defaults
alexeysemenyukoracle 3ecd492
Add LauncherModularStartupInfoMixin.moduleVersion()
alexeysemenyukoracle 8636750
FileAssociationGroup: add FileAssociationGroup.Builder.description()
alexeysemenyukoracle 53fbadb
Add JPackageException to the model
alexeysemenyukoracle 5f075a7
Make ConfigException and PackagerException extend RuntimeException; F…
alexeysemenyukoracle 629510f
ConfigException: extend JPackageException; JPackageException: update …
alexeysemenyukoracle 2bf3f38
Add a builder for LauncherStartupInfo with the unit tests.
alexeysemenyukoracle faa0175
Add SetBuilder utility class
alexeysemenyukoracle 07186c0
Use I18N.buildConfigException() to create ConfigException instances
alexeysemenyukoracle b2a40e5
Better exception handling in AppImageFile. Better test coverage. Use …
alexeysemenyukoracle 5a5aa0e
the cli: old help output
alexeysemenyukoracle ac22bca
the cli: old help output reordered and trailing whitespace trimmed
alexeysemenyukoracle 358754d
the cli: new help output
alexeysemenyukoracle 3cb2cdc
Add the "cli".
alexeysemenyukoracle 614518b
ApplicationBuilder: add externalApplication()
alexeysemenyukoracle b2f2287
Get rid of BundlingOperation and BundleCreator classe. Add BundlingOp…
alexeysemenyukoracle 2b76f8b
Add *FromOptions, OptionUtils, DefaultBundlingEnvironment, and TempDi…
alexeysemenyukoracle f0340d9
Update module-info.java files
alexeysemenyukoracle c03dbb6
Use cli to parse app image file
alexeysemenyukoracle 33d59cc
Follow up change for ExternalApplication.LauncherInfo change
alexeysemenyukoracle 668395f
Follow up change for ExternalApplication changes
alexeysemenyukoracle 7dfeba6
ModelAsserter: adhoc comparison of model classes created from params …
alexeysemenyukoracle 4906fd5
Remove "params"-related classes
alexeysemenyukoracle d2c8cc6
WinExeBundler: Strip all but native library specific code
alexeysemenyukoracle cf08c87
LauncherFromOptions2 -> LauncherFromOptions
alexeysemenyukoracle dd628a8
Strip ModelAsserter from the DefaultBundlingEnvironment and make it f…
alexeysemenyukoracle e0512e1
Remove PackagerException
alexeysemenyukoracle 912f428
Remove ApplicationLayoutUtils
alexeysemenyukoracle 7d7efb2
module-info.java cleanup
alexeysemenyukoracle 788b1bf
ApplicationBuilder: simplify; use `error.launcher-duplicate-name` ins…
alexeysemenyukoracle 7e581ab
*Resources.properties: remove obsolete IDs
alexeysemenyukoracle 7d5bdb4
main/Main.java: make it a proxy for the cli's Main
alexeysemenyukoracle 66e2df2
Make jtreg tests work with the cli
alexeysemenyukoracle b567bea
JPackageToolProvider.java: remove
alexeysemenyukoracle fc97f88
ErrorTest: follow up for changes in jpackage because of the cli; Main…
alexeysemenyukoracle c06fca1
Remove redundant copy of ObjectMapper.java
alexeysemenyukoracle b289bf3
MainResources.properties, MacResources.properties: remove obsolete IDs
alexeysemenyukoracle e8e2344
Add test to run multiple instances of jpackage tool provider asynchro…
alexeysemenyukoracle 1b88f47
the cli: after params removed
alexeysemenyukoracle da39bcc
Rework ExternalApplication and AppImageFile
alexeysemenyukoracle bfa308d
OptionSpecBuilder: bugfix
alexeysemenyukoracle a041411
StandardOption, HelpResources.properties: split description of the "a…
alexeysemenyukoracle 0448168
Update cli-*.txt help output files
alexeysemenyukoracle f7de264
MainResources.properties: remove unreferenced L10N key
alexeysemenyukoracle 470d74c
Validator: formatting
alexeysemenyukoracle 54e5fb2
StandardValidator: expose
alexeysemenyukoracle 4dc4c67
Fix findings in the code review
alexeysemenyukoracle cfe8693
Fix typo and trailing whitespace
alexeysemenyukoracle 862285d
Removed commented out code
alexeysemenyukoracle a926aaa
StandardValidator: rename IS_EXISTENT_NOT_DIRECTORY into IS_FILE_OR_S…
alexeysemenyukoracle 1892798
"main.option." -> "help.option."
alexeysemenyukoracle b7a176b
PackageType: minor
alexeysemenyukoracle 474d0af
the cli: Options: add copyWithDefaultValue(WithOptionIdentifier withI…
alexeysemenyukoracle aa57979
Merge branch 'master' into JDK-8333727
alexeysemenyukoracle bee331c
AsyncTest: call javac and jar tool providers only once for all async …
alexeysemenyukoracle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppBundler.java
This file was deleted.
Oops, something went wrong.
114 changes: 114 additions & 0 deletions
114
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxBundlingEnvironment.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /* | ||
| * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. Oracle designates this | ||
| * particular file as subject to the "Classpath" exception as provided | ||
| * by Oracle in the LICENSE file that accompanied this code. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
| package jdk.jpackage.internal; | ||
|
|
||
| import static java.util.stream.Collectors.toMap; | ||
| import static jdk.jpackage.internal.LinuxFromOptions.createLinuxApplication; | ||
| import static jdk.jpackage.internal.LinuxPackagingPipeline.APPLICATION_LAYOUT; | ||
| import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_APP_IMAGE; | ||
| import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_DEB; | ||
| import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_LINUX_RPM; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.stream.Stream; | ||
| import jdk.jpackage.internal.cli.Options; | ||
| import jdk.jpackage.internal.cli.StandardBundlingOperation; | ||
| import jdk.jpackage.internal.model.BundlingOperationDescriptor; | ||
| import jdk.jpackage.internal.model.LinuxPackage; | ||
| import jdk.jpackage.internal.model.PackageType; | ||
| import jdk.jpackage.internal.util.Result; | ||
|
|
||
| public class LinuxBundlingEnvironment extends DefaultBundlingEnvironment { | ||
|
|
||
| public LinuxBundlingEnvironment() { | ||
| super(build() | ||
| .defaultOperation(() -> { | ||
| return LazyLoad.SYS_ENV.value().map(LinuxSystemEnvironment::nativePackageType).map(DESCRIPTORS::get); | ||
| }) | ||
| .bundler(CREATE_LINUX_APP_IMAGE, LinuxBundlingEnvironment::createAppImage) | ||
| .bundler(CREATE_LINUX_DEB, LazyLoad::debSysEnv, LinuxBundlingEnvironment::createDebPackage) | ||
| .bundler(CREATE_LINUX_RPM, LazyLoad::rpmSysEnv, LinuxBundlingEnvironment::createRpmPackage)); | ||
| } | ||
|
|
||
| private static void createDebPackage(Options options, LinuxDebSystemEnvironment sysEnv) { | ||
|
|
||
| createNativePackage(options, | ||
| LinuxFromOptions::createLinuxDebPackage, | ||
| buildEnv()::create, | ||
| LinuxBundlingEnvironment::buildPipeline, | ||
| (env, pkg, outputDir) -> { | ||
| return new LinuxDebPackager(env, pkg, outputDir, sysEnv); | ||
| }); | ||
| } | ||
|
|
||
| private static void createRpmPackage(Options options, LinuxRpmSystemEnvironment sysEnv) { | ||
|
|
||
| createNativePackage(options, | ||
| LinuxFromOptions::createLinuxRpmPackage, | ||
| buildEnv()::create, | ||
| LinuxBundlingEnvironment::buildPipeline, | ||
| (env, pkg, outputDir) -> { | ||
| return new LinuxRpmPackager(env, pkg, outputDir, sysEnv); | ||
| }); | ||
| } | ||
|
|
||
| private static void createAppImage(Options options) { | ||
|
|
||
| final var app = createLinuxApplication(options); | ||
|
|
||
| createApplicationImage(options, app, LinuxPackagingPipeline.build(Optional.empty())); | ||
| } | ||
|
|
||
| private static PackagingPipeline.Builder buildPipeline(LinuxPackage pkg) { | ||
| return LinuxPackagingPipeline.build(Optional.of(pkg)); | ||
| } | ||
|
|
||
| private static BuildEnvFromOptions buildEnv() { | ||
| return new BuildEnvFromOptions().predefinedAppImageLayout(APPLICATION_LAYOUT); | ||
| } | ||
|
|
||
| private static final class LazyLoad { | ||
|
|
||
| static Result<LinuxDebSystemEnvironment> debSysEnv() { | ||
| return DEB_SYS_ENV; | ||
| } | ||
|
|
||
| static Result<LinuxRpmSystemEnvironment> rpmSysEnv() { | ||
| return RPM_SYS_ENV; | ||
| } | ||
|
|
||
| private static final Result<LinuxSystemEnvironment> SYS_ENV = LinuxSystemEnvironment.create(); | ||
|
|
||
| private static final Result<LinuxDebSystemEnvironment> DEB_SYS_ENV = LinuxDebSystemEnvironment.create(SYS_ENV); | ||
|
|
||
| private static final Result<LinuxRpmSystemEnvironment> RPM_SYS_ENV = LinuxRpmSystemEnvironment.create(SYS_ENV); | ||
| } | ||
|
|
||
| private static final Map<PackageType, BundlingOperationDescriptor> DESCRIPTORS = Stream.of( | ||
| CREATE_LINUX_DEB, | ||
| CREATE_LINUX_RPM | ||
| ).collect(toMap(StandardBundlingOperation::packageType, StandardBundlingOperation::descriptor)); | ||
| } |
79 changes: 0 additions & 79 deletions
79
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxFromOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /* | ||
| * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. Oracle designates this | ||
| * particular file as subject to the "Classpath" exception as provided | ||
| * by Oracle in the LICENSE file that accompanied this code. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
| package jdk.jpackage.internal; | ||
|
|
||
| import static jdk.jpackage.internal.FromOptions.buildApplicationBuilder; | ||
| import static jdk.jpackage.internal.FromOptions.createPackageBuilder; | ||
| import static jdk.jpackage.internal.LinuxPackagingPipeline.APPLICATION_LAYOUT; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_APP_CATEGORY; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_DEB_MAINTAINER_EMAIL; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_MENU_GROUP; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_PACKAGE_DEPENDENCIES; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_PACKAGE_NAME; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_RELEASE; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_RPM_LICENSE_TYPE; | ||
| import static jdk.jpackage.internal.cli.StandardOption.LINUX_SHORTCUT_HINT; | ||
| import static jdk.jpackage.internal.model.StandardPackageType.LINUX_DEB; | ||
| import static jdk.jpackage.internal.model.StandardPackageType.LINUX_RPM; | ||
|
|
||
| import jdk.jpackage.internal.cli.Options; | ||
| import jdk.jpackage.internal.model.Launcher; | ||
| import jdk.jpackage.internal.model.LinuxApplication; | ||
| import jdk.jpackage.internal.model.LinuxDebPackage; | ||
| import jdk.jpackage.internal.model.LinuxLauncher; | ||
| import jdk.jpackage.internal.model.LinuxLauncherMixin; | ||
| import jdk.jpackage.internal.model.LinuxRpmPackage; | ||
| import jdk.jpackage.internal.model.StandardPackageType; | ||
|
|
||
| final class LinuxFromOptions { | ||
|
|
||
| static LinuxApplication createLinuxApplication(Options options) { | ||
|
|
||
| final var launcherFromOptions = new LauncherFromOptions().faWithDefaultDescription(); | ||
|
|
||
| final var appBuilder = buildApplicationBuilder().create(options, launcherOptions -> { | ||
|
|
||
| final var launcher = launcherFromOptions.create(launcherOptions); | ||
|
|
||
| final var shortcut = LINUX_SHORTCUT_HINT.findIn(launcherOptions); | ||
|
|
||
| return LinuxLauncher.create(launcher, new LinuxLauncherMixin.Stub(shortcut)); | ||
|
|
||
| }, (LinuxLauncher linuxLauncher, Launcher launcher) -> { | ||
| return LinuxLauncher.create(launcher, linuxLauncher); | ||
| }, APPLICATION_LAYOUT); | ||
|
|
||
| appBuilder.launchers().map(LinuxPackagingPipeline::normalizeShortcuts).ifPresent(appBuilder::launchers); | ||
|
|
||
| return LinuxApplication.create(appBuilder.create()); | ||
| } | ||
|
|
||
| static LinuxRpmPackage createLinuxRpmPackage(Options options) { | ||
|
|
||
| final var superPkgBuilder = createLinuxPackageBuilder(options, LINUX_RPM); | ||
|
|
||
| final var pkgBuilder = new LinuxRpmPackageBuilder(superPkgBuilder); | ||
|
|
||
| LINUX_RPM_LICENSE_TYPE.ifPresentIn(options, pkgBuilder::licenseType); | ||
|
|
||
| return pkgBuilder.create(); | ||
| } | ||
|
|
||
| static LinuxDebPackage createLinuxDebPackage(Options options) { | ||
|
|
||
| final var superPkgBuilder = createLinuxPackageBuilder(options, LINUX_DEB); | ||
|
|
||
| final var pkgBuilder = new LinuxDebPackageBuilder(superPkgBuilder); | ||
|
|
||
| LINUX_DEB_MAINTAINER_EMAIL.ifPresentIn(options, pkgBuilder::maintainerEmail); | ||
|
|
||
| final var pkg = pkgBuilder.create(); | ||
|
|
||
| // Show warning if license file is missing | ||
| if (pkg.licenseFile().isEmpty()) { | ||
| Log.verbose(I18N.getString("message.debs-like-licenses")); | ||
| } | ||
|
|
||
| return pkg; | ||
| } | ||
|
|
||
| private static LinuxPackageBuilder createLinuxPackageBuilder(Options options, StandardPackageType type) { | ||
|
|
||
| final var app = createLinuxApplication(options); | ||
|
|
||
| final var superPkgBuilder = createPackageBuilder(options, app, type); | ||
|
|
||
| final var pkgBuilder = new LinuxPackageBuilder(superPkgBuilder); | ||
|
|
||
| LINUX_PACKAGE_DEPENDENCIES.ifPresentIn(options, pkgBuilder::additionalDependencies); | ||
| LINUX_APP_CATEGORY.ifPresentIn(options, pkgBuilder::category); | ||
| LINUX_MENU_GROUP.ifPresentIn(options, pkgBuilder::menuGroupName); | ||
| LINUX_RELEASE.ifPresentIn(options, pkgBuilder::release); | ||
| LINUX_PACKAGE_NAME.ifPresentIn(options, pkgBuilder::literalName); | ||
|
|
||
| return pkgBuilder; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.