ascheman commented on code in PR #11700:
URL: https://github.com/apache/maven/pull/11700#discussion_r2771034659
##########
impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java:
##########
@@ -660,46 +660,75 @@ private void initProject(MavenProject project,
ModelBuilderResult result) {
return build.getDirectory();
}
};
- boolean hasScript = false;
- boolean hasMain = false;
- boolean hasTest = false;
+ // Extract modules from sources to detect modular projects
+ Set<String> modules = extractModules(sources);
+ boolean isModularProject = !modules.isEmpty();
+
+ logger.trace(
+ "Module detection for project {}: found {} module(s)
{} - modular project: {}.",
+ project.getId(),
+ modules.size(),
+ modules,
+ isModularProject);
+
+ // Create source handling context for unified tracking of all
lang/scope combinations
+ SourceHandlingContext sourceContext =
+ new SourceHandlingContext(project, baseDir, modules,
isModularProject, result);
+
+ // Process all sources, tracking enabled ones and detecting
duplicates
for (var source : sources) {
- var src = DefaultSourceRoot.fromModel(session, baseDir,
outputDirectory, source);
- project.addSourceRoot(src);
- Language language = src.language();
- if (Language.JAVA_FAMILY.equals(language)) {
- ProjectScope scope = src.scope();
- if (ProjectScope.MAIN.equals(scope)) {
- hasMain = true;
- } else {
- hasTest |= ProjectScope.TEST.equals(scope);
- }
- } else {
- hasScript |= Language.SCRIPT.equals(language);
+ var sourceRoot = DefaultSourceRoot.fromModel(session,
baseDir, outputDirectory, source);
Review Comment:
Personally I agree with you, but perhaps its more a question of programming
style. `var` is already used in other places of this codebase, e.g.,
DefaultModelBuilder.java:
```java
for (var problem : e.getResult().getProblemCollector()...
for (var transformer : transformers) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]