elharo commented on code in PR #11702:
URL: https://github.com/apache/maven/pull/11702#discussion_r2813429987
##########
impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java:
##########
@@ -692,49 +692,102 @@ private void initProject(MavenProject project,
ModelBuilderResult result) {
}
/*
- * `sourceDirectory`, `testSourceDirectory` and
`scriptSourceDirectory`
- * are ignored if the POM file contains at least one enabled
<source> element
- * for the corresponding scope and language. This rule exists
because
- * Maven provides default values for those elements which may
conflict
- * with user's configuration.
+ * Source directory handling depends on project type and
<sources> configuration:
*
- * Additionally, for modular projects, legacy directories are
unconditionally
- * ignored because it is not clear how to dispatch their
content between
- * different modules. A warning is emitted if these properties
are explicitly set.
+ * 1. CLASSIC projects (no <sources>):
+ * - All legacy directories are used
+ *
+ * 2. MODULAR projects (have <module> in <sources>):
+ * - ALL legacy directories are rejected (can't dispatch
between modules)
+ * - Physical presence of default directories
(src/main/java) also triggers ERROR
Review Comment:
OK, I think I'm starting to see the issue. But I'm not yet convinced that
having a legacy source base and a modular source base si a deal breaker. Could
we run the compiler twice? Once to produce the no-module jar and once to
produce the modularized jars passing different sources each time?
It is possible to have Java projects that contain both modular and
non-modular jars on the classpath/module-path. So are we requiring that these
different jars be in separate Maven projects?
Traditionally a Maven pom.xml produced exactly one library jar (and maybe a
test jar, source jars, and so forth but we can ignore that for now). Now with
modules we have one pom.xml producing multiple jars. So why can't we take the
legacy code in the traditional src/main/java location and put it in the unnamed
module? That is, why are ALL legacy directories rejected in a modular project?
--
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]