@@ -35,6 +35,7 @@ public abstract class ContributionTask extends DefaultTask {
35
35
private static final String BUILD_FILE = "build.gradle" ;
36
36
private static final String USER_CODE_FILTER_FILE = "user-code-filter.json" ;
37
37
private static final String REQUIRED_DOCKER_IMAGES_FILE = "required-docker-images.txt" ;
38
+
38
39
@ Inject
39
40
protected abstract ExecOperations getExecOperations ();
40
41
@@ -324,9 +325,7 @@ private void updateAllowedPackages(List<String> allowedPackages, boolean isAlrea
324
325
}
325
326
326
327
private void addTests (Path originalTestsLocation ){
327
- Path destination = testsDirectory .resolve ("src" )
328
- .resolve ("test" )
329
- .resolve ("java" );
328
+ Path destination = testsDirectory .resolve ("src" ).resolve ("test" ).resolve ("java" );
330
329
Path allTests = originalTestsLocation .resolve ("." );
331
330
332
331
ensureFileBelongsToProject (destination );
@@ -369,7 +368,7 @@ private void addDockerImages(List<String> images) throws IOException {
369
368
Files .createFile (destination );
370
369
}
371
370
372
- for (var image : images ) {
371
+ for (String image : images ) {
373
372
writeToFile (destination , image .concat (System .lineSeparator ()), StandardOpenOption .APPEND );
374
373
}
375
374
}
@@ -386,7 +385,6 @@ private void addUserCodeFilterFile(List<String> packages) throws IOException {
386
385
387
386
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter ();
388
387
prettyPrinter .indentArraysWith (DefaultIndenter .SYSTEM_LINEFEED_INSTANCE );
389
-
390
388
objectMapper .writer (prettyPrinter ).writeValue (testsDirectory .resolve (USER_CODE_FILTER_FILE ).toFile (), Map .of ("rules" , filterFileRules ));
391
389
}
392
390
@@ -427,7 +425,7 @@ private void addAgentConfigBlock() {
427
425
InteractiveTaskUtils .printUserInfo ("Configuring agent block in: " + BUILD_FILE );
428
426
429
427
if (!Files .exists (buildFilePath ) || !Files .isRegularFile (buildFilePath )) {
430
- throw new RuntimeException ("Cannot add additional dependencies to " + buildFilePath + ". Please check if a " + BUILD_FILE + " exists on that location." );
428
+ throw new RuntimeException ("Cannot add agent block to " + buildFilePath + ". Please check if a " + BUILD_FILE + " exists on that location." );
431
429
}
432
430
433
431
@@ -474,37 +472,37 @@ private void removeEmptyConfigFiles() throws IOException {
474
472
List <CONFIG_FILES > remainingFiles = new LinkedList <>(Arrays .asList (CONFIG_FILES .values ()));
475
473
476
474
Path resourceConfigPath = metadataDirectory .resolve (CONFIG_FILES .RESOURCE .get ());
477
- ResourceConfigModel resourceConfig = objectMapper .readValue (new File ( resourceConfigPath .toUri () ), new TypeReference <>() {});
475
+ ResourceConfigModel resourceConfig = objectMapper .readValue (resourceConfigPath .toFile ( ), new TypeReference <>() {});
478
476
if (resourceConfig .isEmpty ()) {
479
477
removeConfigFile (resourceConfigPath , CONFIG_FILES .RESOURCE , remainingFiles );
480
478
}
481
479
482
480
Path serializationConfigPath = metadataDirectory .resolve (CONFIG_FILES .SERIALIZATION .get ());
483
- SerializationConfigModel serializationConfig = objectMapper .readValue (new File ( serializationConfigPath .toUri () ), new TypeReference <>() {});
481
+ SerializationConfigModel serializationConfig = objectMapper .readValue (serializationConfigPath .toFile ( ), new TypeReference <>() {});
484
482
if (serializationConfig .isEmpty ()) {
485
483
removeConfigFile (serializationConfigPath , CONFIG_FILES .SERIALIZATION , remainingFiles );
486
484
}
487
485
488
486
Path jniConfigPath = metadataDirectory .resolve (CONFIG_FILES .JNI .get ());
489
- List <Object > jniConfig = objectMapper .readValue (new File ( jniConfigPath .toUri () ), new TypeReference <>() {});
487
+ List <Object > jniConfig = objectMapper .readValue (jniConfigPath .toFile ( ), new TypeReference <>() {});
490
488
if (jniConfig .isEmpty ()) {
491
489
removeConfigFile (jniConfigPath , CONFIG_FILES .JNI , remainingFiles );
492
490
}
493
491
494
492
Path proxyConfigPath = metadataDirectory .resolve (CONFIG_FILES .PROXY .get ());
495
- List <Object > proxyConfig = objectMapper .readValue (new File ( proxyConfigPath .toUri () ), new TypeReference <>() {});
493
+ List <Object > proxyConfig = objectMapper .readValue (proxyConfigPath .toFile ( ), new TypeReference <>() {});
496
494
if (proxyConfig .isEmpty ()) {
497
495
removeConfigFile (proxyConfigPath , CONFIG_FILES .PROXY , remainingFiles );
498
496
}
499
497
500
498
Path reflectConfigPath = metadataDirectory .resolve (CONFIG_FILES .REFLECTION .get ());
501
- List <Object > reflectConfig = objectMapper .readValue (new File ( reflectConfigPath .toUri () ), new TypeReference <>() {});
499
+ List <Object > reflectConfig = objectMapper .readValue (reflectConfigPath .toFile ( ), new TypeReference <>() {});
502
500
if (reflectConfig .isEmpty ()) {
503
501
removeConfigFile (reflectConfigPath , CONFIG_FILES .REFLECTION , remainingFiles );
504
502
}
505
503
506
504
Path predefinedClassesConfigPath = metadataDirectory .resolve (CONFIG_FILES .PREDEFINED_CLASSES .get ());
507
- List <PredefinedClassesConfigModel > predefinedClassesConfig = objectMapper .readValue (new File ( predefinedClassesConfigPath .toUri () ), new TypeReference <>() {});
505
+ List <PredefinedClassesConfigModel > predefinedClassesConfig = objectMapper .readValue (predefinedClassesConfigPath .toFile ( ), new TypeReference <>() {});
508
506
if (predefinedClassesConfig .size () == 1 ) {
509
507
if (predefinedClassesConfig .get (0 ).isEmpty ()) {
510
508
removeConfigFile (predefinedClassesConfigPath , CONFIG_FILES .PREDEFINED_CLASSES , remainingFiles );
@@ -513,7 +511,7 @@ private void removeEmptyConfigFiles() throws IOException {
513
511
514
512
Path agentExtractedPredefinedClasses = metadataDirectory .resolve ("agent-extracted-predefined-classes" );
515
513
if (Files .exists (agentExtractedPredefinedClasses )) {
516
- File [] extractedPredefinedClasses = new File ( agentExtractedPredefinedClasses .toUri () ).listFiles ();
514
+ File [] extractedPredefinedClasses = agentExtractedPredefinedClasses .toFile ( ).listFiles ();
517
515
if (extractedPredefinedClasses == null || extractedPredefinedClasses .length == 0 ) {
518
516
ensureFileBelongsToProject (agentExtractedPredefinedClasses );
519
517
@@ -543,7 +541,6 @@ private void trimIndexFile(Path index, List<CONFIG_FILES> remainingFiles) throws
543
541
InteractiveTaskUtils .printUserInfo ("Removing sufficient entries from: " + index );
544
542
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter ();
545
543
prettyPrinter .indentArraysWith (DefaultIndenter .SYSTEM_LINEFEED_INSTANCE );
546
-
547
544
objectMapper .writer (prettyPrinter ).writeValue (index .toFile (), remainingFiles .stream ().map (CONFIG_FILES ::get ).toList ());
548
545
}
549
546
0 commit comments