1919package org .apache .maven .api ;
2020
2121import java .nio .file .Path ;
22+ import java .util .Collection ;
2223import java .util .List ;
2324import java .util .Optional ;
25+ import java .util .stream .Stream ;
2426
2527import org .apache .maven .api .annotations .Experimental ;
2628import org .apache .maven .api .annotations .Nonnull ;
4951public interface Project {
5052
5153 /**
52- * Returns the project groupId.
54+ * {@return the project groupId} .
5355 */
5456 @ Nonnull
5557 String getGroupId ();
5658
5759 /**
58- * Returns the project artifactId.
60+ * {@return the project artifactId} .
5961 */
6062 @ Nonnull
6163 String getArtifactId ();
6264
6365 /**
64- * Returns the project version.
66+ * {@return the project version} .
6567 */
6668 @ Nonnull
6769 String getVersion ();
6870
6971 /**
70- * Returns the project packaging.
72+ * {@return the project packaging} .
7173 * <p>
7274 * Note: unlike in legacy code, logical checks against string representing packaging (returned by this method)
7375 * are NOT recommended (code like {@code "pom".equals(project.getPackaging)} must be avoided). Use method
@@ -79,7 +81,7 @@ public interface Project {
7981 Packaging getPackaging ();
8082
8183 /**
82- * Returns the project language. It is by default determined by {@link #getPackaging()}.
84+ * {@return the project language} . It is by default determined by {@link #getPackaging()}.
8385 *
8486 * @see #getPackaging()
8587 */
@@ -89,7 +91,7 @@ default Language getLanguage() {
8991 }
9092
9193 /**
92- * Returns the project POM artifact, which is the artifact of the POM of this project. Every project have a POM
94+ * {@return the project POM artifact} , which is the artifact of the POM of this project. Every project have a POM
9395 * artifact, even if the existence of backing POM file is NOT a requirement (i.e. for some transient projects).
9496 *
9597 * @see org.apache.maven.api.services.ArtifactManager#getPath(Artifact)
@@ -100,7 +102,7 @@ default ProducedArtifact getPomArtifact() {
100102 }
101103
102104 /**
103- * Returns the project main artifact, which is the artifact produced by this project build, if applicable.
105+ * {@return the project main artifact} , which is the artifact produced by this project build, if applicable.
104106 * This artifact MAY be absent if the project is actually not producing any main artifact (i.e. "pom" packaging).
105107 *
106108 * @see #getPackaging()
@@ -113,7 +115,7 @@ default Optional<ProducedArtifact> getMainArtifact() {
113115 }
114116
115117 /**
116- * Returns the project artifacts as immutable list. Elements are the project POM artifact and the artifact
118+ * {@return the project artifacts as immutable list} . Elements are the project POM artifact and the artifact
117119 * produced by this project build, if applicable. Hence, the returned list may have one or two elements
118120 * (never less than 1, never more than 2), depending on project packaging.
119121 * <p>
@@ -129,13 +131,15 @@ default Optional<ProducedArtifact> getMainArtifact() {
129131 List <ProducedArtifact > getArtifacts ();
130132
131133 /**
132- * Returns the project model.
134+ * {@return the project model} .
133135 */
134136 @ Nonnull
135137 Model getModel ();
136138
137139 /**
138140 * Shorthand method.
141+ *
142+ * @return the build element of the project model
139143 */
140144 @ Nonnull
141145 default Build getBuild () {
@@ -170,19 +174,19 @@ default Build getBuild() {
170174 Path getBasedir ();
171175
172176 /**
173- * Returns the project direct dependencies (directly specified or inherited).
177+ * {@return the project direct dependencies (directly specified or inherited)} .
174178 */
175179 @ Nonnull
176180 List <DependencyCoordinates > getDependencies ();
177181
178182 /**
179- * Returns the project managed dependencies (directly specified or inherited).
183+ * {@return the project managed dependencies (directly specified or inherited)} .
180184 */
181185 @ Nonnull
182186 List <DependencyCoordinates > getManagedDependencies ();
183187
184188 /**
185- * Returns the project ID, usable as key.
189+ * {@return the project ID, usable as key} .
186190 */
187191 @ Nonnull
188192 default String getId () {
@@ -216,6 +220,7 @@ default String getId() {
216220 * Gets the root directory of the project, which is the parent directory
217221 * containing the {@code .mvn} directory or flagged with {@code root="true"}.
218222 *
223+ * @return the root directory of the project
219224 * @throws IllegalStateException if the root directory could not be found
220225 * @see Session#getRootDirectory()
221226 */
@@ -234,4 +239,32 @@ default String getId() {
234239 */
235240 @ Nonnull
236241 Optional <Project > getParent ();
242+
243+ /**
244+ * {@return all source root directories}, including the disabled ones, for all languages and scopes.
245+ * For listing only the {@linkplain SourceRoot#enabled() enabled} source roots,
246+ * the following code can be used:
247+ *
248+ * <pre>{@literal
249+ * List<SourceRoot> enabledRoots = project.getSourceRoots()
250+ * .stream().filter(SourceRoot::enabled).toList();
251+ * }</pre>
252+ *
253+ * The iteration order is the order in which the sources are declared in the POM file.
254+ */
255+ @ Nonnull
256+ Collection <SourceRoot > getSourceRoots ();
257+
258+ /**
259+ * {@return all enabled sources that provide files in the given language for the given scope}.
260+ * If the given scope is {@code null}, then this method returns the enabled sources for all scopes.
261+ * If the given language is {@code null}, then this method returns the enabled sources for all languages.
262+ * An arbitrary number of source roots may exist for the same scope and language.
263+ * It may be, for example, the case of a multi-versions project.
264+ * The iteration order is the order in which the sources are declared in the POM file.
265+ *
266+ * @param scope the scope of the sources to return, or {@code null} for all scopes
267+ * @param language the language of the sources to return, or {@code null} for all languages
268+ */
269+ Stream <SourceRoot > getEnabledSourceRoots (ProjectScope scope , Language language );
237270}
0 commit comments