4141import java .util .stream .Stream ;
4242import jdk .jpackage .internal .Codesign .CodesignException ;
4343import jdk .jpackage .internal .model .Application ;
44+ import jdk .jpackage .internal .model .ApplicationLayout ;
45+ import jdk .jpackage .internal .model .Launcher ;
4446import jdk .jpackage .internal .model .MacApplication ;
4547import jdk .jpackage .internal .util .PathUtils ;
4648import jdk .jpackage .internal .util .function .ExceptionBox ;
@@ -63,21 +65,22 @@ static Consumer<Path> createSigner(MacApplication app, CodesignConfig signingCfg
6365 });
6466 }
6567
66- static Consumer <Path > createUnsigner (MacApplication app ) {
67- return toConsumer (appImage -> {
68- new AppImageSigner (Codesigners .nop ()).sign (app , appImage );
69- });
70- }
71-
72- static final class SignFilter implements Predicate <Path > {
68+ private static final class SignFilter implements Predicate <Path > {
7369
7470 SignFilter (Application app , Path appImage ) {
7571 Objects .requireNonNull (appImage );
72+
73+ // Don't explicitly sign main launcher. It will be implicitly signed when the bundle is signed.
74+ otherExcludePaths = app .asApplicationLayout ().map (appLayout -> {
75+ return appLayout .resolveAt (appImage );
76+ }).map (ApplicationLayout ::launchersDirectory ).flatMap (launchersDir -> {
77+ return app .mainLauncher ().map (Launcher ::executableNameWithSuffix ).map (launchersDir ::resolve );
78+ }).map (Set ::of ).orElseGet (Set ::of );
7679 }
7780
7881 @ Override
7982 public boolean test (Path path ) {
80- if (!Files .isRegularFile (path )) {
83+ if (!Files .isRegularFile (path ) || otherExcludePaths . contains ( path ) ) {
8184 return false ;
8285 }
8386
@@ -91,6 +94,8 @@ public boolean test(Path path) {
9194
9295 return false ;
9396 }
97+
98+ private final Set <Path > otherExcludePaths ;
9499 }
95100
96101 private void sign (MacApplication app , Path appImage ) throws CodesignException , IOException {
@@ -219,11 +224,6 @@ private Optional<Consumer<Path>> findCodesigner(Path path) {
219224 return Optional .empty ();
220225 }
221226
222- static Codesigners nop () {
223- Consumer <Path > nop = path -> {};
224- return new Codesigners (nop , nop , nop );
225- }
226-
227227 static Codesigners create (CodesignConfig signingCfg ) {
228228 final var signingCfgWithoutEntitlements = CodesignConfig .build ().from (signingCfg ).entitlements (null ).create ();
229229
0 commit comments