@@ -92,12 +92,12 @@ final class BundleSupport {
92
92
boolean loadBundle ;
93
93
boolean writeBundle ;
94
94
95
- private static final int bundleFileFormatVersionMajor = 0 ;
96
- private static final int bundleFileFormatVersionMinor = 9 ;
95
+ private static final int BUNDLE_FILE_FORMAT_VERSION_MAJOR = 0 ;
96
+ private static final int BUNDLE_FILE_FORMAT_VERSION_MINOR = 9 ;
97
97
98
- private static final String bundleInfoMessagePrefix = "GraalVM Native Image Bundle Support: " ;
99
- private static final String bundleTempDirPrefix = "bundleRoot-" ;
100
- private static final String originalDirExtension = ".orig" ;
98
+ private static final String BUNDLE_INFO_MESSAGE_PREFIX = "GraalVM Native Image Bundle Support: " ;
99
+ private static final String BUNDLE_TEMP_DIR_PREFIX = "bundleRoot-" ;
100
+ private static final String ORIGINAL_DIR_EXTENSION = ".orig" ;
101
101
102
102
private Path bundlePath ;
103
103
private String bundleName ;
@@ -154,7 +154,7 @@ static BundleSupport create(NativeImage nativeImage, String bundleArg, NativeIma
154
154
for (int i = buildArgs .size () - 1 ; i >= 0 ; i --) {
155
155
args .push (buildArgs .get (i ));
156
156
}
157
- nativeImage .showVerboseMessage (nativeImage .isVerbose (), bundleInfoMessagePrefix + "Inject args: '" + String .join (" " , buildArgs ) + "'" );
157
+ nativeImage .showVerboseMessage (nativeImage .isVerbose (), BUNDLE_INFO_MESSAGE_PREFIX + "Inject args: '" + String .join (" " , buildArgs ) + "'" );
158
158
/* Snapshot args after in-place expansion (includes also args after this one) */
159
159
bundleSupport .updatedBuildArgs = args .snapshot ();
160
160
break ;
@@ -193,7 +193,7 @@ private BundleSupport(NativeImage nativeImage) {
193
193
loadBundle = false ;
194
194
writeBundle = true ;
195
195
try {
196
- rootDir = Files .createTempDirectory (bundleTempDirPrefix );
196
+ rootDir = Files .createTempDirectory (BUNDLE_TEMP_DIR_PREFIX );
197
197
bundleProperties = new BundleProperties ();
198
198
199
199
Path inputDir = rootDir .resolve ("input" );
@@ -222,11 +222,11 @@ private BundleSupport(NativeImage nativeImage, String bundleFilenameArg) {
222
222
updateBundleLocation (Path .of (bundleFilenameArg ), false );
223
223
224
224
try {
225
- rootDir = Files .createTempDirectory (bundleTempDirPrefix );
225
+ rootDir = Files .createTempDirectory (BUNDLE_TEMP_DIR_PREFIX );
226
226
bundleProperties = new BundleProperties ();
227
227
228
228
outputDir = rootDir .resolve ("output" );
229
- String originalOutputDirName = outputDir .getFileName ().toString () + originalDirExtension ;
229
+ String originalOutputDirName = outputDir .getFileName ().toString () + ORIGINAL_DIR_EXTENSION ;
230
230
231
231
Path bundleFilePath = bundlePath .resolve (bundleName + BUNDLE_FILE_EXTENSION );
232
232
try (JarFile archive = new JarFile (bundleFilePath .toFile ())) {
@@ -497,14 +497,14 @@ void complete() {
497
497
Path externalOutputDir = bundlePath .resolve (bundleName + "." + outputDir .getFileName ());
498
498
copyFiles (outputDir , externalOutputDir , true );
499
499
outputNewline .run ();
500
- nativeImage .showMessage (bundleInfoMessagePrefix + "Bundle build output written to " + externalOutputDir );
500
+ nativeImage .showMessage (BUNDLE_INFO_MESSAGE_PREFIX + "Bundle build output written to " + externalOutputDir );
501
501
}
502
502
503
503
try {
504
504
if (writeBundle ) {
505
505
Path bundleFilePath = writeBundle ();
506
506
outputNewline .run ();
507
- nativeImage .showMessage (bundleInfoMessagePrefix + "Bundle written to " + bundleFilePath );
507
+ nativeImage .showMessage (BUNDLE_INFO_MESSAGE_PREFIX + "Bundle written to " + bundleFilePath );
508
508
}
509
509
} finally {
510
510
nativeImage .showNewline ();
@@ -550,7 +550,7 @@ void updateBundleLocation(Path bundleFile, boolean redefine) {
550
550
}
551
551
552
552
private Path writeBundle () {
553
- String originalOutputDirName = outputDir .getFileName ().toString () + originalDirExtension ;
553
+ String originalOutputDirName = outputDir .getFileName ().toString () + ORIGINAL_DIR_EXTENSION ;
554
554
Path originalOutputDir = rootDir .resolve (originalOutputDirName );
555
555
if (Files .exists (originalOutputDir )) {
556
556
nativeImage .deleteAllFiles (originalOutputDir );
@@ -589,10 +589,10 @@ private Path writeBundle() {
589
589
if (buildArg .startsWith (nativeImage .oHPath )) {
590
590
continue ;
591
591
}
592
- if (buildArg .equals (CmdLineOptionHandler .verboseOption )) {
592
+ if (buildArg .equals (CmdLineOptionHandler .VERBOSE_OPTION )) {
593
593
continue ;
594
594
}
595
- if (buildArg .equals (CmdLineOptionHandler .dryRunOption )) {
595
+ if (buildArg .equals (CmdLineOptionHandler .DRY_RUN_OPTION )) {
596
596
continue ;
597
597
}
598
598
if (buildArg .startsWith ("-Dllvm.bin.dir=" )) {
@@ -737,11 +737,11 @@ private void loadAndVerify() {
737
737
fileVersionKey = PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR ;
738
738
int minor = Integer .parseInt (properties .getOrDefault (fileVersionKey , "-1" ));
739
739
String message = String .format ("The given bundle file %s was created with newer bundle-file-format version %d.%d" +
740
- " (current %d.%d). Update to the latest version of native-image." , bundleFileName , major , minor , bundleFileFormatVersionMajor , bundleFileFormatVersionMinor );
741
- if (major > bundleFileFormatVersionMajor ) {
740
+ " (current %d.%d). Update to the latest version of native-image." , bundleFileName , major , minor , BUNDLE_FILE_FORMAT_VERSION_MAJOR , BUNDLE_FILE_FORMAT_VERSION_MINOR );
741
+ if (major > BUNDLE_FILE_FORMAT_VERSION_MAJOR ) {
742
742
throw NativeImage .showError (message );
743
- } else if (major == bundleFileFormatVersionMajor ) {
744
- if (minor > bundleFileFormatVersionMinor ) {
743
+ } else if (major == BUNDLE_FILE_FORMAT_VERSION_MAJOR ) {
744
+ if (minor > BUNDLE_FILE_FORMAT_VERSION_MINOR ) {
745
745
NativeImage .showWarning (message );
746
746
}
747
747
}
@@ -761,14 +761,14 @@ private void loadAndVerify() {
761
761
localDateStr = "unknown time" ;
762
762
}
763
763
nativeImage .showNewline ();
764
- nativeImage .showMessage (String .format ("%sLoaded Bundle from %s" , bundleInfoMessagePrefix , bundleFileName ));
765
- nativeImage .showMessage (String .format ("%sBundle created at '%s'" , bundleInfoMessagePrefix , localDateStr ));
766
- nativeImage .showMessage (String .format ("%sUsing version: '%s'%s on platform: '%s'%s" , bundleInfoMessagePrefix , bundleVersion , currentVersion , bundlePlatform , currentPlatform ));
764
+ nativeImage .showMessage (String .format ("%sLoaded Bundle from %s" , BUNDLE_INFO_MESSAGE_PREFIX , bundleFileName ));
765
+ nativeImage .showMessage (String .format ("%sBundle created at '%s'" , BUNDLE_INFO_MESSAGE_PREFIX , localDateStr ));
766
+ nativeImage .showMessage (String .format ("%sUsing version: '%s'%s on platform: '%s'%s" , BUNDLE_INFO_MESSAGE_PREFIX , bundleVersion , currentVersion , bundlePlatform , currentPlatform ));
767
767
}
768
768
769
769
private void write () {
770
- properties .put (PROPERTY_KEY_BUNDLE_FILE_VERSION_MAJOR , String .valueOf (bundleFileFormatVersionMajor ));
771
- properties .put (PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR , String .valueOf (bundleFileFormatVersionMinor ));
770
+ properties .put (PROPERTY_KEY_BUNDLE_FILE_VERSION_MAJOR , String .valueOf (BUNDLE_FILE_FORMAT_VERSION_MAJOR ));
771
+ properties .put (PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR , String .valueOf (BUNDLE_FILE_FORMAT_VERSION_MINOR ));
772
772
properties .put (PROPERTY_KEY_BUNDLE_FILE_CREATION_TIMESTAMP , ZonedDateTime .now ().format (DateTimeFormatter .ISO_DATE_TIME ));
773
773
boolean imageBuilt = !nativeImage .isDryRun ();
774
774
properties .put (PROPERTY_KEY_IMAGE_BUILT , String .valueOf (imageBuilt ));
0 commit comments