@@ -374,7 +374,7 @@ public Path outputBundle() {
374
374
String dirName ;
375
375
if (!TKit .isOSX ()) {
376
376
dirName = name ();
377
- } else if (hasArgument ( "--app-image" ) && hasArgument ( "--mac-sign" )) {
377
+ } else if (MacHelper . signPredefinedAppImage ( this )) {
378
378
// Request to sign external app image, not to build a new one
379
379
dirName = getArgumentValue ("--app-image" );
380
380
} else {
@@ -936,38 +936,54 @@ JPackageCommand assertAppLayout() {
936
936
return this ;
937
937
}
938
938
939
+ private boolean expectAppImageFile () {
940
+ if (isRuntime ()) {
941
+ return false ;
942
+ }
943
+
944
+ if (TKit .isOSX ()) {
945
+ if (MacHelper .signPredefinedAppImage (this )) {
946
+ // Request to sign external app image, ".jpackage.xml" file should exist.
947
+ return true ;
948
+ }
949
+
950
+ if (!isImagePackageType () && hasArgument ("--app-image" )) {
951
+ // Build native macOS package from an external app image.
952
+ // If the external app image is signed, ".jpackage.xml" file should be kept, otherwise removed.
953
+ return AppImageFile .load (Path .of (getArgumentValue ("--app-image" ))).macSigned ();
954
+ }
955
+ }
956
+
957
+ return isImagePackageType ();
958
+ }
959
+
939
960
private void assertAppImageFile () {
940
961
Path appImageDir = Path .of ("" );
941
962
if (isImagePackageType () && hasArgument ("--app-image" )) {
942
963
appImageDir = Path .of (getArgumentValue ("--app-image" ));
943
964
}
944
965
945
966
final Path lookupPath = AppImageFile .getPathInAppImage (appImageDir );
946
- if (isRuntime () || (! isImagePackageType () && ! TKit . isOSX () )) {
967
+ if (! expectAppImageFile ( )) {
947
968
assertFileInAppImage (lookupPath , null );
948
- } else if (!TKit .isOSX ()) {
949
- assertFileInAppImage (lookupPath , lookupPath );
950
969
} else {
951
970
assertFileInAppImage (lookupPath , lookupPath );
952
971
953
- // If file exist validated important values based on arguments
954
- // Exclude validation when we generating packages from predefined
955
- // app images, since we do not know if image is signed or not.
956
- if (isImagePackageType () || !hasArgument ("--app-image" )) {
972
+ if (TKit .isOSX ()) {
957
973
final Path rootDir = isImagePackageType () ? outputBundle () :
958
974
pathToUnpackedPackageFile (appInstallationDirectory ());
959
975
960
976
AppImageFile aif = AppImageFile .load (rootDir );
961
977
962
- boolean expectedValue = hasArgument ( "--mac-sign" );
978
+ boolean expectedValue = MacHelper . appImageSigned ( this );
963
979
boolean actualValue = aif .macSigned ();
964
- TKit .assertEquals (Boolean . toString ( expectedValue ), Boolean . toString ( actualValue ) ,
965
- "Check for unexptected value in app image file for <signed> " );
980
+ TKit .assertEquals (expectedValue , actualValue ,
981
+ "Check for unexpected value of <signed> property in app image file" );
966
982
967
983
expectedValue = hasArgument ("--mac-app-store" );
968
984
actualValue = aif .macAppStore ();
969
- TKit .assertEquals (Boolean . toString ( expectedValue ), Boolean . toString ( actualValue ) ,
970
- "Check for unexptected value in app image file for <app-store> " );
985
+ TKit .assertEquals (expectedValue , actualValue ,
986
+ "Check for unexpected value of <app-store> property in app image file" );
971
987
}
972
988
}
973
989
}
@@ -1037,11 +1053,17 @@ JPackageCommand setUnpackedPackageLocation(Path path) {
1037
1053
}
1038
1054
1039
1055
JPackageCommand winMsiLogFile (Path v ) {
1056
+ if (!TKit .isWindows ()) {
1057
+ throw new UnsupportedOperationException ();
1058
+ }
1040
1059
this .winMsiLogFile = v ;
1041
1060
return this ;
1042
1061
}
1043
1062
1044
1063
public Optional <Path > winMsiLogFile () {
1064
+ if (!TKit .isWindows ()) {
1065
+ throw new UnsupportedOperationException ();
1066
+ }
1045
1067
return Optional .ofNullable (winMsiLogFile );
1046
1068
}
1047
1069
0 commit comments