@@ -471,39 +471,69 @@ public boolean isSatisfiedBy(Task t) {
471
471
472
472
tasks .named (JavaPlugin .COMPILE_JAVA_TASK_NAME , JavaCompile .class ,
473
473
compileJava -> {
474
+ // add the code gen sources
475
+ final SourceSet generatedSourceSet = sourceSets
476
+ .getByName (QuarkusGenerateCode .QUARKUS_GENERATED_SOURCES );
477
+ addCodeGenSourceDirs (compileJava , generatedSourceSet , quarkusExt );
474
478
// quarkusGenerateCode is a dependency
475
479
compileJava .dependsOn (quarkusGenerateCode );
476
480
// quarkusGenerateCodeDev must run before compileJava in case quarkusDev is the target
477
481
compileJava .mustRunAfter (quarkusGenerateCodeDev );
478
- // add the code gen sources
479
- addCodeGenSourceDirs (compileJava ,
480
- sourceSets .getByName (QuarkusGenerateCode .QUARKUS_GENERATED_SOURCES ), quarkusExt );
482
+
483
+ // The code below needs to be reviewed. There is no test coverage for it.
484
+ // We need to properly configure/use these tasks. For now they aren't actually used
485
+ // but w/o the code below, in some cases, Gradle may fail on determining task ordering.
486
+ // https://github.com/quarkusio/quarkus/issues/45057 states that this issue happens with
487
+ // org.gradle.parallel=true when building from IntelliJ
488
+ // Similar code is added for compileKotlin (although for Kotlin these task don't seem to exist).
489
+ if (tasks .contains (new NamedImpl (generatedSourceSet .getCompileJavaTaskName ()))) {
490
+ compileJava .mustRunAfter (tasks .named (generatedSourceSet .getCompileJavaTaskName ()));
491
+ }
481
492
});
482
493
tasks .named (JavaPlugin .COMPILE_TEST_JAVA_TASK_NAME , JavaCompile .class ,
483
494
compileTestJava -> {
484
- compileTestJava .dependsOn (quarkusGenerateCode );
485
- compileTestJava .dependsOn (quarkusGenerateCodeTests );
495
+ // add the code gen test sources
496
+ final SourceSet generatedSourceSet = sourceSets
497
+ .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES );
498
+ addCodeGenSourceDirs (compileTestJava , generatedSourceSet , quarkusExt );
499
+ compileTestJava .dependsOn (quarkusGenerateCode , quarkusGenerateCodeTests );
500
+ if (tasks .contains (new NamedImpl (generatedSourceSet .getCompileJavaTaskName ()))) {
501
+ compileTestJava .mustRunAfter (tasks .named (generatedSourceSet .getCompileJavaTaskName ()));
502
+ }
486
503
if (project .getGradle ().getStartParameter ().getTaskNames ().contains (QUARKUS_DEV_TASK_NAME )) {
487
504
compileTestJava .getOptions ().setFailOnError (false );
488
505
}
489
- // add the code gen test sources
490
- addCodeGenSourceDirs (compileTestJava ,
491
- sourceSets .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES ), quarkusExt );
492
506
});
493
507
});
494
508
495
509
project .getPlugins ().withId ("org.jetbrains.kotlin.jvm" , plugin -> {
496
510
quarkusDev .configure (task -> task .shouldPropagateJavaCompilerArgs (false ));
497
511
tasks .named ("compileKotlin" , task -> {
498
- task .mustRunAfter (quarkusGenerateCode );
512
+ final SourceSet generatedSourceSet = project .getExtensions ().getByType (SourceSetContainer .class )
513
+ .getByName (QuarkusGenerateCode .QUARKUS_GENERATED_SOURCES );
514
+ addCodeGenSourceDirs (task , generatedSourceSet , quarkusExt );
515
+ task .dependsOn (quarkusGenerateCode );
499
516
task .mustRunAfter (quarkusGenerateCodeDev );
500
- addCodeGenSourceDirs (task , project .getExtensions ().getByType (SourceSetContainer .class )
501
- .getByName (QuarkusGenerateCode .QUARKUS_GENERATED_SOURCES ), quarkusExt );
517
+ if (tasks .contains (new NamedImpl (generatedSourceSet .getCompileJavaTaskName ()))) {
518
+ task .mustRunAfter (tasks .named (generatedSourceSet .getCompileJavaTaskName ()));
519
+ }
520
+ String generatedSourcesCompileTaskName = generatedSourceSet .getCompileTaskName ("kotlin" );
521
+ if (tasks .contains (new NamedImpl (generatedSourcesCompileTaskName ))) {
522
+ task .mustRunAfter (tasks .named (generatedSourcesCompileTaskName ));
523
+ }
502
524
});
503
525
tasks .named ("compileTestKotlin" , task -> {
526
+ final SourceSet generatedSourceSet = project .getExtensions ().getByType (SourceSetContainer .class )
527
+ .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES );
528
+ addCodeGenSourceDirs (task , generatedSourceSet , quarkusExt );
504
529
task .dependsOn (quarkusGenerateCodeTests );
505
- addCodeGenSourceDirs (task , project .getExtensions ().getByType (SourceSetContainer .class )
506
- .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES ), quarkusExt );
530
+ if (tasks .contains (new NamedImpl (generatedSourceSet .getCompileJavaTaskName ()))) {
531
+ task .mustRunAfter (tasks .named (generatedSourceSet .getCompileJavaTaskName ()));
532
+ }
533
+ final String generatedSourcesCompileTaskName = generatedSourceSet .getCompileTaskName ("kotlin" );
534
+ if (tasks .contains (new NamedImpl (generatedSourcesCompileTaskName ))) {
535
+ task .mustRunAfter (tasks .named (generatedSourcesCompileTaskName ));
536
+ }
507
537
});
508
538
});
509
539
}
0 commit comments