@@ -348,19 +348,9 @@ List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
348
348
if (wdtModelPath != null ) {
349
349
dockerfileOptions .setWdtEnabled ();
350
350
dockerfileOptions .setWdtModelOnly (wdtModelOnly );
351
- String [] modelFiles = wdtModelPath .toString ().split ("," );
352
- List <String > modelList = new ArrayList <>();
353
-
354
- for (String modelFile : modelFiles ) {
355
- Path modelFilePath = Paths .get (modelFile );
356
- if (Files .isRegularFile (modelFilePath )) {
357
- String modelFilename = modelFilePath .getFileName ().toString ();
358
- Files .copy (modelFilePath , Paths .get (tmpDir , modelFilename ));
359
- modelList .add (modelFilename );
360
- } else {
361
- throw new IOException ("WDT model file " + modelFile + " not found" );
362
- }
363
- }
351
+
352
+ List <String > modelList = addWDTFilesAsList (wdtModelPath , "model" , tmpDir );
353
+
364
354
dockerfileOptions .setWdtModels (modelList );
365
355
366
356
dockerfileOptions .setWdtDomainType (wdtDomainType );
@@ -371,11 +361,11 @@ List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
371
361
dockerfileOptions .setRunRcu (runRcu );
372
362
}
373
363
374
- if (wdtArchivePath != null && Files . isRegularFile ( wdtArchivePath ) ) {
375
- String wdtArchiveFilename = wdtArchivePath . getFileName (). toString ();
376
- Files . copy (wdtArchivePath , Paths . get ( tmpDir , wdtArchiveFilename ) );
377
- //Until WDT supports multiple archives, take single file argument from CLI and convert to list
378
- dockerfileOptions .setWdtArchives (Collections . singletonList ( wdtArchiveFilename ) );
364
+ if (wdtArchivePath != null ) {
365
+
366
+ List < String > archiveList = addWDTFilesAsList (wdtArchivePath , "archive" , tmpDir );
367
+
368
+ dockerfileOptions .setWdtArchives (archiveList );
379
369
}
380
370
dockerfileOptions .setDomainHome (wdtDomainHome );
381
371
@@ -394,6 +384,24 @@ List<String> handleWdtArgsIfRequired(String tmpDir) throws IOException {
394
384
return retVal ;
395
385
}
396
386
387
+ private List <String > addWDTFilesAsList (Path fileArg , String type , String tmpDir ) throws IOException {
388
+ String [] listOfFiles = fileArg .toString ().split ("," );
389
+ List <String > fileList = new ArrayList <>();
390
+
391
+ for (String individualFile : listOfFiles ) {
392
+ Path individualPath = Paths .get (individualFile );
393
+ if (Files .isRegularFile (individualPath )) {
394
+ String modelFilename = individualPath .getFileName ().toString ();
395
+ Files .copy (individualPath , Paths .get (tmpDir , modelFilename ));
396
+ fileList .add (modelFilename );
397
+ } else {
398
+ String errMsg = String .format ("WDT %s file %s not found " , type , individualFile );
399
+ throw new IOException (errMsg );
400
+ }
401
+ }
402
+ return fileList ;
403
+ }
404
+
397
405
/**
398
406
* Parses wdtVersion and constructs the url to download WDT and adds the url to cache.
399
407
*
0 commit comments