desruisseaux commented on code in PR #11700:
URL: https://github.com/apache/maven/pull/11700#discussion_r2777419848
##########
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:
I don't think that there is a consensus. I tend to use `var` when it avoids
a redundancy on the same line, especially when the redundancy is verbose. For
example:
```java
MyFooWithLongName foo = new MyFooWithLongName();
```
However, when we don't see the type on the same line (as in `for (var
transformer : transformers)`), I agree that it is good to keep the type. I
usually try to stick to the rule "use `var` only if we can see the type on the
same line", but I may sometime use `var` by mistake.
--
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]