Skip to content

Delete also the directories specified in <targetPath>#276

Merged
desruisseaux merged 2 commits into
apache:masterfrom
Geomatys:fix/target-path
Oct 26, 2025
Merged

Delete also the directories specified in <targetPath>#276
desruisseaux merged 2 commits into
apache:masterfrom
Geomatys:fix/target-path

Conversation

@desruisseaux

Copy link
Copy Markdown
Contributor

Each <source> element (new in Maven 4) can have an optional <targetPath> element. If this element is specified, it should also be deleted by the Maven Clean Plugin. This change completes the current Maven 3 behaviour, which deletes also the directories specified by the <sourceDirectory> and <testSourceDirectory> elements.

This pull request also modifies the list of directories for removing redundancies. For example, if the plugin deletes the target directory, there is no need to keep an entry for the target/classes directory. Likewise, the reportDirectory field is removed because its value (read-only) was identical to outputDirectory (also read-only). A side effect of this change is that the following logs, which was previously emitted by the default integration test, are now gone:

[DEBUG] Skipping non-existing directory (…snip…)/target/it/default/target/classes
[DEBUG] Skipping non-existing directory (…snip…)/target/it/default/target/test-classes
[DEBUG] Skipping non-existing directory (…snip…)/target/it/default/target/classes

… the `<targetPath>` child of `<source>` elements.

Remove the `reportDirectory` field because its value (read-only) was identical to `outputDirectory` (also read-only).

@slawekjaranowski slawekjaranowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we add a test for it?

@desruisseaux

Copy link
Copy Markdown
Contributor Author

Oups! Right, I forget that. Will do this weekend.

@desruisseaux

Copy link
Copy Markdown
Contributor Author

Added the integration test. Also modified the code for resolving relative paths against ${maven.build.outputDirectory} (usually target/classes), as specified in maven.mdo.

Note: this change assumes that apache/maven#11322 is accepted, i.e. that the specification in maven.mdo is incomplete and should said that relative paths are rather resolved against ${maven.build.testOutputDirectory} when the scope is test.

@desruisseaux desruisseaux merged commit 25c53b6 into apache:master Oct 26, 2025
8 checks passed
@github-actions github-actions Bot added this to the 4.0.0-beta-3 milestone Oct 26, 2025
@github-actions

Copy link
Copy Markdown

@desruisseaux Please assign appropriate label to PR according to the type of change.

@desruisseaux desruisseaux deleted the fix/target-path branch October 26, 2025 17:16
@desruisseaux desruisseaux added bug Something isn't working java Pull requests that update Java code labels Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants