45
45
import java .util .regex .Pattern ;
46
46
import java .util .stream .Collectors ;
47
47
import java .util .stream .Stream ;
48
- import jdk .jpackage .internal .AppImageFile ;
49
- import jdk .jpackage .internal .ApplicationLayout ;
50
- import jdk .jpackage .internal .PackageFile ;
51
- import jdk .jpackage .internal .util .XmlUtils ;
52
48
import static jdk .jpackage .test .AdditionalLauncher .forEachAdditionalLauncher ;
53
49
import jdk .jpackage .internal .util .function .ThrowingConsumer ;
54
50
import jdk .jpackage .internal .util .function .ThrowingFunction ;
@@ -157,8 +153,10 @@ public String getArgumentValue(String argName,
157
153
public <T > T getArgumentValue (String argName ,
158
154
Supplier <T > defaultValueSupplier ,
159
155
Function <String , T > stringConverter ) {
160
- return getArgumentValue (argName , (unused ) -> defaultValueSupplier .get (),
161
- stringConverter );
156
+ return getArgumentValue (argName ,
157
+ Optional .ofNullable (defaultValueSupplier ).map (supplier -> {
158
+ return (Function <JPackageCommand , T >)unused -> supplier .get ();
159
+ }).orElse (null ), stringConverter );
162
160
}
163
161
164
162
public String getArgumentValue (String argName ,
@@ -217,9 +215,9 @@ public String version() {
217
215
}
218
216
219
217
public String name () {
220
- String appImage = getArgumentValue ("--app-image" , () -> null );
218
+ String appImage = getArgumentValue ("--app-image" );
221
219
if (appImage != null ) {
222
- String name = AppImageFile .extractAppName (Path .of (appImage ));
220
+ String name = AppImageFile .load (Path .of (appImage )). mainLauncherName ( );
223
221
// can be null if using foreign app-image
224
222
return ((name != null ) ? name : getArgumentValue ("--name" ));
225
223
}
@@ -233,7 +231,7 @@ public String installerName() {
233
231
if (installerName == null ) {
234
232
String appImage = getArgumentValue ("--app-image" );
235
233
if (appImage != null ) {
236
- installerName = AppImageFile .extractAppName (Path .of (appImage ));
234
+ installerName = AppImageFile .load (Path .of (appImage )). mainLauncherName ( );
237
235
}
238
236
}
239
237
return installerName ;
@@ -306,42 +304,6 @@ public JPackageCommand setFakeRuntime() {
306
304
return this ;
307
305
}
308
306
309
- public void createJPackageXMLFile (String mainLauncher , String mainClass )
310
- throws IOException {
311
- Path jpackageXMLFile = AppImageFile .getPathInAppImage (
312
- Optional .ofNullable (getArgumentValue ("--app-image" )).map (
313
- Path ::of ).orElseThrow (() -> {
314
- return new RuntimeException (
315
- "Error: --app-image expected" );
316
- }));
317
-
318
- XmlUtils .createXml (jpackageXMLFile , xml -> {
319
- xml .writeStartElement ("jpackage-state" );
320
- xml .writeAttribute ("version" , AppImageFile .getVersion ());
321
- xml .writeAttribute ("platform" , AppImageFile .getPlatform ());
322
-
323
- xml .writeStartElement ("app-version" );
324
- xml .writeCharacters ("1.0" );
325
- xml .writeEndElement ();
326
-
327
- xml .writeStartElement ("main-launcher" );
328
- xml .writeCharacters (mainLauncher );
329
- xml .writeEndElement ();
330
-
331
- xml .writeStartElement ("main-class" );
332
- xml .writeCharacters (mainClass );
333
- xml .writeEndElement ();
334
-
335
- xml .writeStartElement ("signed" );
336
- xml .writeCharacters ("false" );
337
- xml .writeEndElement ();
338
-
339
- xml .writeStartElement ("app-store" );
340
- xml .writeCharacters ("false" );
341
- xml .writeEndElement ();
342
- });
343
- }
344
-
345
307
JPackageCommand addPrerequisiteAction (ThrowingConsumer <JPackageCommand > action ) {
346
308
verifyMutable ();
347
309
prerequisiteActions .add (action );
@@ -935,7 +897,7 @@ JPackageCommand assertAppLayout() {
935
897
private void assertAppImageFile () {
936
898
Path appImageDir = Path .of ("" );
937
899
if (isImagePackageType () && hasArgument ("--app-image" )) {
938
- appImageDir = Path .of (getArgumentValue ("--app-image" , () -> null ));
900
+ appImageDir = Path .of (getArgumentValue ("--app-image" ));
939
901
}
940
902
941
903
final Path lookupPath = AppImageFile .getPathInAppImage (appImageDir );
@@ -956,12 +918,12 @@ private void assertAppImageFile() {
956
918
AppImageFile aif = AppImageFile .load (rootDir );
957
919
958
920
boolean expectedValue = hasArgument ("--mac-sign" );
959
- boolean actualValue = aif .isSigned ();
921
+ boolean actualValue = aif .macSigned ();
960
922
TKit .assertEquals (Boolean .toString (expectedValue ), Boolean .toString (actualValue ),
961
923
"Check for unexptected value in app image file for <signed>" );
962
924
963
925
expectedValue = hasArgument ("--mac-app-store" );
964
- actualValue = aif .isAppStore ();
926
+ actualValue = aif .macAppStore ();
965
927
TKit .assertEquals (Boolean .toString (expectedValue ), Boolean .toString (actualValue ),
966
928
"Check for unexptected value in app image file for <app-store>" );
967
929
}
@@ -975,9 +937,8 @@ private void assertPackageFile() {
975
937
assertFileInAppImage (lookupPath , null );
976
938
} else {
977
939
if (TKit .isOSX () && hasArgument ("--app-image" )) {
978
- String appImage = getArgumentValue ("--app-image" ,
979
- () -> null );
980
- if (AppImageFile .load (Path .of (appImage )).isSigned ()) {
940
+ String appImage = getArgumentValue ("--app-image" );
941
+ if (AppImageFile .load (Path .of (appImage )).macSigned ()) {
981
942
assertFileInAppImage (lookupPath , null );
982
943
} else {
983
944
assertFileInAppImage (lookupPath , lookupPath );
1 commit comments
openjdk-notifier[bot] commentedon Nov 22, 2024
Review
Issues