Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8395] Redirect the <sourceDirectory> element to <Source> #2061

Merged
merged 14 commits into from
Jan 30, 2025

Conversation

desruisseaux
Copy link
Contributor

Notable changes:

  • Add a SourceRoot interface for the properties declared in the POM's <Source> element.
  • In the POM, deprecate the sourceDirectory, testSourceDirectory, scriptSourceDirectory, resources, testResources elements and the Resource structure. They are replaced by <source> elements.
  • In the MavenProject class, replace the compileSourceRoots, testCompileSourceRoots and scriptSourceRoots fields by redirections to the new sources field with paths wrapped in SourceRoot objects. The resource fields are not completely replaced, information are duplicated.
  • The getters and setters methods for above-cited fields are deprecated.
  • This commit contains other opportunistic deprecations on methods which were receiving or returning instances of types that were already deprecated.

In the POM file, the above-cited deprecated properties are ignored if a corresponding <source> element exists. For example, if there is a source with <scope>main</scope> and <lang>java</lang>, then <sourceDirectory> is ignored. This rule exits because Maven sets default values to those fields, which can interfere with user's setting.

Note: the SourceRoot API uses method names without the get prefix in anticipation for possible use of records in the future.

… `<Source>` element.

The API use method names without `get` prefix in anticipation for possible use of records in the future.

In the `MavenProject` class, the `compileSourceRoots`, `testCompileSourceRoots` and `scriptSourceRoots`
fields are replaced by redirections to the new `sources` field with paths wrapped in `SourceRoot` objects.
The getters and setters methods for the previous fields are deprecated.
This commit contains other opportunistic deprecations on methods working with deprecated interfaces.

In the POM file, the above-cited properties are ignored if a corresponding `<Source>` element exists.
This rule exits because Maven sets default values to those fields, which can interfer with user's setting.
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc fixes

@gnodet gnodet self-requested a review January 26, 2025 23:01
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a @Deprecated annotation.

api/maven-api-model/src/main/mdo/maven.mdo Show resolved Hide resolved
…d returns only enabled sources.
…Language)` methods accessible from the `Project` interface.
@desruisseaux desruisseaux force-pushed the feat/redirect-to-sources branch from b9e5cc1 to 9648557 Compare January 28, 2025 11:31
- Add `addSourceRoot(Project, …)` methods.
- Deprecate `get/addResource(Project, …)` methods.
- Deprecate `get/addCompileSourceRoots(Project, …)` methods.
This is done in a separated commit in case we need to revert.
@gnodet
Copy link
Contributor

gnodet commented Jan 28, 2025

I think we also need to move the Project#getSourceRoots() and Project#getEnabledSourceRoots(ProjectScope,Language) to ProjectManager as they return values that are not meant to be immutable (as they can change by adding sources). I know from an implementation POV, they are still managed by the underlying MavenProject itself, but the idea would be to get rid of the underlying Maven 3 layer in the future.

@desruisseaux desruisseaux force-pushed the feat/redirect-to-sources branch from ea672ac to 9af4ac9 Compare January 29, 2025 10:12
@gnodet gnodet changed the title Redirect the <sourceDirectory> element to <Source> [MNG-8395] Redirect the <sourceDirectory> element to <Source> Jan 30, 2025
@gnodet
Copy link
Contributor

gnodet commented Jan 30, 2025

Thx, a few minor changes in Geomatys#1
At some point, it would be nice to have an IT that would use the new source element, as this is supposed to work even with the current set of plugins I think.

gnodet and others added 4 commits January 30, 2025 11:35
On the ProjectManager interface, Intellij warns me about overridden parameters not being annotated
@gnodet gnodet merged commit 7b4a4bf into apache:master Jan 30, 2025
13 checks passed
@gnodet gnodet added this to the 4.0.0-rc-3 milestone Jan 30, 2025
@desruisseaux desruisseaux deleted the feat/redirect-to-sources branch January 30, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants