This is an automated email from the ASF dual-hosted git repository.

mbuenger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site.git


The following commit(s) were added to refs/heads/master by this push:
     new b429ffd8 Add new sources declaration to maven 4 guides (#1431)
b429ffd8 is described below

commit b429ffd8a6753588876b1afab3450fbdb0d342e4
Author: Matthias Bünger <[email protected]>
AuthorDate: Sat Oct 18 15:34:05 2025 +0200

    Add new sources declaration to maven 4 guides (#1431)
---
 .../guides/mini/guide-migration-to-mvn4.md         | 34 +++++++++++++++++++++
 content/markdown/whatsnewinmaven4.md               | 35 ++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/content/markdown/guides/mini/guide-migration-to-mvn4.md 
b/content/markdown/guides/mini/guide-migration-to-mvn4.md
index 01023d7a..19be292f 100644
--- a/content/markdown/guides/mini/guide-migration-to-mvn4.md
+++ b/content/markdown/guides/mini/guide-migration-to-mvn4.md
@@ -335,6 +335,40 @@ Maven 4 introduces several new [lifecycle 
phases](/ref/4-LATEST/maven-impl-modul
 They give users finer control over plugin execution, particularly in 
multi-project and concurrent builds.
 If you want to execute a plugin before/after all or each of your 
(sub-)projects, consider to use them.
 
+### New way to declare source directories
+
+Maven 3 has two explicitly named XML elements (`<sourceDirectory>` and 
`<testSourceDirectory>`) to declare the root directories of source code, as 
shown below:
+
+```xml
+<project>
+  <build>
+    <sourceDirectory>my-custom-dir/foo</sourceDirectory>
+    <testSourceDirectory>my-custom-dir/bar</testSourceDirectory>
+  </build>
+</project>
+```
+
+Maven 4 introduces the new `<sources>` element for this.
+This makes source directory declarations more flexible for future improvements.
+When migrate to Maven 4, you should use the new element.
+
+```xml
+<project>
+  <build>
+    <sources>
+      <source>
+        <scope>main</scope>
+        <directory>my-custom-dir/foo</directory>
+      </source>
+      <source>
+        <scope>test</scope>
+        <directory>my-custom-dir/bar</directory>
+      </source>
+    </sources>
+  </build>
+</project>
+```
+
 [versionpluginupdate]: 
https://www.mojohaus.org/versions/versions-maven-plugin/examples/display-plugin-updates.html
 [modelbuilderinterpolation]: 
https://maven.apache.org/ref/4-LATEST/maven-compat-modules/maven-model-builder/#model-interpolation
 [cifriendlyguide]: 
https://maven.apache.org/guides/mini/guide-maven-ci-friendly.html
diff --git a/content/markdown/whatsnewinmaven4.md 
b/content/markdown/whatsnewinmaven4.md
index bf72e9fd..23fbd094 100644
--- a/content/markdown/whatsnewinmaven4.md
+++ b/content/markdown/whatsnewinmaven4.md
@@ -204,6 +204,41 @@ properties.
 Starting with Maven 4 those properties were removed or marked as deprecated.
 See JIRA issue [MNG-7038][15] and the related [Pull Request for MNG-7038][16] 
for more information.
 
+### New way to declare source directories
+
+Maven 3 has two explicitly named XML elements (`<sourceDirectory>` and 
`<testSourceDirectory>`) to declare the root directories of source code, as 
shown below:
+
+```xml
+<project>
+  <build>
+    <sourceDirectory>my-custom-dir/foo</sourceDirectory>
+    <testSourceDirectory>my-custom-dir/bar</testSourceDirectory>
+  </build>
+</project>
+```
+
+Maven 4 introduces the new `<sources>` element for this.
+The `<source>` element can be repeated, thus allowing multiple source 
directories without the need to resort to external plugins.
+It also provides a unified way to declare include/exclude filters, makes 
easier to set up projects targeting multi Java releases, and enables module 
source hierarchy.
+The documentation of the Maven Compiler Plugin gives some examples.
+
+```xml
+<project>
+  <build>
+    <sources>
+      <source>
+        <scope>main</scope>
+        <directory>my-custom-dir/foo</directory>
+      </source>
+      <source>
+        <scope>test</scope>
+        <directory>my-custom-dir/bar</directory>
+      </source>
+    </sources>
+  </build>
+</project>
+```
+
 ### Alternate POM syntaxes
 
 While the syntax for the 4.0.0 consumer POM is set in stone, the build POM 
should be able to evolve.

Reply via email to