2323
2424import io .quarkus .bootstrap .workspace .ArtifactSources ;
2525import io .quarkus .bootstrap .workspace .DefaultArtifactSources ;
26+ import io .quarkus .bootstrap .workspace .LazySourceDir ;
2627import io .quarkus .bootstrap .workspace .SourceDir ;
2728import io .quarkus .bootstrap .workspace .WorkspaceModule ;
2829import io .quarkus .bootstrap .workspace .WorkspaceModuleId ;
@@ -35,7 +36,6 @@ public static Provider<DefaultProjectDescriptor> buildForApp(Project project) {
3536 final SourceSetContainer srcSets = evaluated .getExtensions ().getByType (SourceSetContainer .class );
3637 project .getTasks ().withType (Jar .class ).forEach (jarTask -> {
3738 final String classifier = jarTask .getArchiveClassifier ().get ();
38- System .out .println ("Classifier '" + classifier + "'" );
3939 final Map <String , Task > contentTasks = new HashMap <>();
4040 jarTask .getTaskDependencies ().getDependencies (jarTask )
4141 .forEach (o -> {
@@ -47,67 +47,64 @@ public static Provider<DefaultProjectDescriptor> buildForApp(Project project) {
4747 contentTasks .put (o .getName (), o );
4848 }
4949 });
50- System .out .println (" content tasks:" );
50+ final List <File > classesDirs = new ArrayList <>(2 );
51+ final List <File > resourcesOutputDirs = new ArrayList <>(2 );
5152 for (Task t : contentTasks .values ()) {
5253 File destDir = null ;
5354 if (t instanceof AbstractCompile compile ) {
5455 destDir = compile .getDestinationDirectory ().getAsFile ().get ();
56+ classesDirs .add (destDir );
5557 } else if (t instanceof ProcessResources resources ) {
5658 destDir = resources .getDestinationDir ();
59+ resourcesOutputDirs .add (destDir );
5760 } else if (t instanceof KotlinCompileTool kotlinCompile ) {
5861 destDir = kotlinCompile .getDestinationDirectory ().getAsFile ().get ();
62+ classesDirs .add (destDir );
5963 }
60- System .out .println (" - " + t .getName () + " " + destDir );
6164 }
6265
66+ final List <SourceDir > sourceDirs = new ArrayList <>(2 );
67+ final List <SourceDir > resourceDirs = new ArrayList <>(2 );
6368 for (SourceSet srcSet : srcSets ) {
64- System .out .println ("SourceSet " + srcSet .getName ());
65- for (var f : srcSet .getOutput ().getClassesDirs ().getFiles ()) {
66- System .out .println (" classes: " + f );
69+ for (var classesDir : srcSet .getOutput ().getClassesDirs ().getFiles ()) {
70+ if (classesDirs .contains (classesDir )) {
71+ for (var srcDir : srcSet .getAllJava ().getSrcDirs ()) {
72+ sourceDirs .add (new LazySourceDir (srcDir .toPath (), classesDir .toPath ())); // TODO findGeneratedSourceDir(destDir, sourceSet));
73+ }
74+ }
6775 }
68- System .out .println (" process resources task: " + srcSet .getProcessResourcesTaskName ());
69- System .out .println (" output dir: " + srcSet .getOutput ().getResourcesDir ());
70- }
7176
72- SourceSet sourceSet = null ;
73- if (classifier .isEmpty ()) {
74- sourceSet = srcSets .getByName (SourceSet .MAIN_SOURCE_SET_NAME );
75- } else if ("test-fixtures" .equals (classifier )) {
76- sourceSet = srcSets .getByName ("testFixtures" );
77+ final File resourcesOutputDir = srcSet .getOutput ().getResourcesDir ();
78+ if (resourcesOutputDirs .contains (resourcesOutputDir )) {
79+ for (var dir : srcSet .getResources ().getSrcDirs ()) {
80+ resourceDirs .add (new LazySourceDir (dir .toPath (), resourcesOutputDir .toPath ()));
81+ }
82+ }
7783 }
7884
79- if (sourceSet != null ) {
80- System .out .println ("ProjectDescriptorBuilder.buildForApp jar task for classifier '" + classifier + "'" );
81- System .out .println (" classes: " + sourceSet .getOutput ().getClassesDirs ().getFiles ());
82- System .out .println (" generated sources: " + sourceSet .getOutput ().getGeneratedSourcesDirs ().getFiles ());
83- System .out .println (" java: " + sourceSet .getJava ().getSourceDirectories ().getFiles ());
84- System .out .println (" all java: " + sourceSet .getAllJava ().getSourceDirectories ().getFiles ());
85- System .out .println (" compile task: " + sourceSet .getCompileJavaTaskName ());
86-
87- System .out .println (" process resources task: " + sourceSet .getProcessResourcesTaskName ());
88- var sources = new ClassifiedSources (classifier ,
89- sourceSet .getOutput ().getClassesDirs ().getFiles ());
90- builder .classifiedSources .put (sources .classifier , sources );
85+ if (!sourceDirs .isEmpty () || !resourceDirs .isEmpty ()) {
86+ builder .moduleBuilder .addArtifactSources (new DefaultArtifactSources (classifier , sourceDirs , resourceDirs ));
9187 }
9288 });
9389
94- evaluated .getTasks ().withType (AbstractCompile .class ).configureEach (builder ::readConfigurationFor );
95- builder .maybeConfigureKotlinJvmCompile (evaluated );
96- evaluated .getTasks ().withType (ProcessResources .class ).configureEach (builder ::readConfigurationFor );
90+ //builder.maybeConfigureKotlinJvmCompile(evaluated);
9791 });
9892
9993 return project .getProviders ().provider (() -> {
94+ /* @formatter:off
10095 System.out.println("ProjectDescriptorBuilder.buildForApp classified sources");
101- builder .classifiedSources . values (). forEach ( src -> {
102- System .out .println (" '" + src . classifier + "'" );
103- src . sources . forEach ( sod -> {
104- System . out . println ( " " + sod . src + " -> " + sod . output );
105- } );
106- });
107-
108- for ( var classifiedSources : builder . classifiedSources . values ()) {
109- builder . moduleBuilder . addArtifactSources ( classifiedSources . toArtifactSources ());
96+ for (var classifier : builder.moduleBuilder.getSourceClassifiers()) {
97+ System.out.println(" classifier '" + classifier + "'");
98+ var as = builder.moduleBuilder.getSources(classifier);
99+ for (var srcDir : as.getSourceDirs()) {
100+ System.out.println(" " + srcDir.getDir() + " -> " + srcDir.getOutputDir() );
101+ }
102+ for (var srcDir : as.getResourceDirs()) {
103+ System.out.println(" " + srcDir.getDir() + " -> " + srcDir.getOutputDir ());
104+ }
110105 }
106+ @formatter:on
107+ */
111108 return new DefaultProjectDescriptor (builder .moduleBuilder );
112109 });
113110 }
0 commit comments