desruisseaux commented on code in PR #2061: URL: https://github.com/apache/maven/pull/2061#discussion_r1932699313
########## api/maven-api-core/src/main/java/org/apache/maven/api/Project.java: ########## @@ -234,4 +239,32 @@ default String getId() { */ @Nonnull Optional<Project> getParent(); + + /** + * {@return all source root directories}, including the disabled ones, for all languages and scopes. + * For listing only the {@linkplain SourceRoot#enabled() enabled} source roots, + * the following code can be used: + * + * <pre>{@literal + * List<SourceRoot> enabledRoots = project.getSourceRoots() + * .stream().filter(SourceRoot::enabled).toList(); + * }</pre> + * + * The iteration order is the order in which the sources are declared in the POM file. + */ + @Nonnull + Collection<SourceRoot> getSourceRoots(); + + /** + * {@return all enabled sources that provide files in the given language for the given scope}. + * If the given scope is {@code null}, then this method returns the enabled sources for all scopes. + * If the given language is {@code null}, then this method returns the enabled sources for all languages. + * An arbitrary number of source roots may exist for the same scope and language. + * It may be, for example, the case of a multi-versions project. + * The iteration order is the order in which the sources are declared in the POM file. + * + * @param scope the scope of the sources to return, or {@code null} for all scopes + * @param language the language of the sources to return, or {@code null} for all languages + */ + Stream<SourceRoot> getEnabledSourceRoots(ProjectScope scope, Language language); Review Comment: Pushed addition of two `addSourceRoot` method (the second one is a convenience) and removed the 4 above-cited methods. Note: for interfaces such as `Project` that are intended to be unmodifiable, should be remove the `get` prefix? It would express the intent that those interfaces have no setter methods, and would allow to implement some of them with `record`. The latter may not be applicable to `DefaultProject`, but some other implementations may benefit from that. -- 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: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org