@@ -471,39 +471,61 @@ 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
+ // Similar code is added for compileKotlin (although for Kotlin these task don't seem to exist).
487
+ if (tasks .contains (new NamedImpl (generatedSourceSet .getCompileJavaTaskName ()))) {
488
+ compileJava .mustRunAfter (tasks .named (generatedSourceSet .getCompileJavaTaskName ()));
489
+ }
481
490
});
482
491
tasks .named (JavaPlugin .COMPILE_TEST_JAVA_TASK_NAME , JavaCompile .class ,
483
492
compileTestJava -> {
484
- compileTestJava .dependsOn (quarkusGenerateCode );
485
- compileTestJava .dependsOn (quarkusGenerateCodeTests );
493
+ // add the code gen test sources
494
+ final SourceSet generatedSourceSet = sourceSets
495
+ .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES );
496
+ addCodeGenSourceDirs (compileTestJava , generatedSourceSet , quarkusExt );
497
+ compileTestJava .dependsOn (quarkusGenerateCode , quarkusGenerateCodeTests );
498
+ if (tasks .contains (new NamedImpl (generatedSourceSet .getCompileJavaTaskName ()))) {
499
+ compileTestJava .mustRunAfter (tasks .named (generatedSourceSet .getCompileJavaTaskName ()));
500
+ }
486
501
if (project .getGradle ().getStartParameter ().getTaskNames ().contains (QUARKUS_DEV_TASK_NAME )) {
487
502
compileTestJava .getOptions ().setFailOnError (false );
488
503
}
489
- // add the code gen test sources
490
- addCodeGenSourceDirs (compileTestJava ,
491
- sourceSets .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES ), quarkusExt );
492
504
});
493
505
});
494
506
495
507
project .getPlugins ().withId ("org.jetbrains.kotlin.jvm" , plugin -> {
496
508
quarkusDev .configure (task -> task .shouldPropagateJavaCompilerArgs (false ));
497
509
tasks .named ("compileKotlin" , task -> {
498
- task .mustRunAfter (quarkusGenerateCode );
510
+ final SourceSet generatedSourceSet = project .getExtensions ().getByType (SourceSetContainer .class )
511
+ .getByName (QuarkusGenerateCode .QUARKUS_GENERATED_SOURCES );
512
+ addCodeGenSourceDirs (task , generatedSourceSet , quarkusExt );
513
+ task .dependsOn (quarkusGenerateCode );
499
514
task .mustRunAfter (quarkusGenerateCodeDev );
500
- addCodeGenSourceDirs (task , project .getExtensions ().getByType (SourceSetContainer .class )
501
- .getByName (QuarkusGenerateCode .QUARKUS_GENERATED_SOURCES ), quarkusExt );
515
+ String generatedSourcesCompileTaskName = generatedSourceSet .getCompileTaskName ("kotlin" );
516
+ if (tasks .contains (new NamedImpl (generatedSourcesCompileTaskName ))) {
517
+ task .mustRunAfter (tasks .named (generatedSourcesCompileTaskName ));
518
+ }
502
519
});
503
520
tasks .named ("compileTestKotlin" , task -> {
521
+ final SourceSet generatedSourceSet = project .getExtensions ().getByType (SourceSetContainer .class )
522
+ .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES );
523
+ addCodeGenSourceDirs (task , generatedSourceSet , quarkusExt );
504
524
task .dependsOn (quarkusGenerateCodeTests );
505
- addCodeGenSourceDirs (task , project .getExtensions ().getByType (SourceSetContainer .class )
506
- .getByName (QuarkusGenerateCode .QUARKUS_TEST_GENERATED_SOURCES ), quarkusExt );
525
+ final String generatedSourcesCompileTaskName = generatedSourceSet .getCompileTaskName ("kotlin" );
526
+ if (tasks .contains (new NamedImpl (generatedSourcesCompileTaskName ))) {
527
+ task .mustRunAfter (tasks .named (generatedSourcesCompileTaskName ));
528
+ }
507
529
});
508
530
});
509
531
}
0 commit comments