Skip to content

Conversation

@ebourg
Copy link
Member

@ebourg ebourg commented Jun 17, 2023

@ebourg
Copy link
Member Author

ebourg commented Jun 17, 2023

This is incomplete, the path separators have to be normalized too.

@slawekjaranowski slawekjaranowski added the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Feb 18, 2025
@desruisseaux desruisseaux self-assigned this Mar 15, 2025
desruisseaux added a commit to Geomatys/maven-compiler-plugin that referenced this pull request Mar 15, 2025
@desruisseaux
Copy link
Contributor

Done on a clone of the master branch (not yet merged). The fix in this pull request could not be applied on master, but could be applied on the 3.x branch. Should we redirect the target branch to 3.x, or close as "fixed" (after merge of aa4509b)?

@github-actions github-actions bot removed the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Mar 15, 2025
@slawekjaranowski

This comment was marked as resolved.

@desruisseaux desruisseaux removed their assignment Mar 15, 2025
@desruisseaux desruisseaux changed the base branch from master to maven-compiler-plugin-3.x March 15, 2025 18:48
desruisseaux added a commit to Geomatys/maven-compiler-plugin that referenced this pull request Mar 24, 2025
desruisseaux added a commit to Geomatys/maven-compiler-plugin that referenced this pull request Mar 26, 2025
desruisseaux added a commit to Geomatys/maven-compiler-plugin that referenced this pull request Apr 2, 2025
desruisseaux added a commit to Geomatys/maven-compiler-plugin that referenced this pull request Apr 2, 2025
desruisseaux added a commit to Geomatys/maven-compiler-plugin that referenced this pull request Apr 6, 2025
@slawekjaranowski
Copy link
Member

@ebourg can you look at commit: aa4509b I don't see if was or not merged

but look like better implementation

@slawekjaranowski
Copy link
Member

ok, was merged with #320 - one big PR 😄

@jira-importer
Copy link

Resolve #626

@slawekjaranowski slawekjaranowski added the waiting-for-feedback Waiting for 90 days until issues or pull request will be closed label Jun 20, 2025
@github-actions

This comment was marked as resolved.

@github-actions github-actions bot added the Stale label Aug 20, 2025
@gnodet gnodet added the 3.x label Oct 13, 2025
@gnodet gnodet closed this Oct 15, 2025
@gnodet gnodet reopened this Oct 15, 2025
@github-actions github-actions bot added the Stale label Dec 15, 2025
@github-actions github-actions bot removed the Stale label Dec 24, 2025
@apache apache deleted a comment from github-actions bot Jan 11, 2026
@slachiewicz slachiewicz requested a review from Copilot January 11, 2026 22:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make Maven compiler plugin builds reproducible by converting absolute paths to relative paths in the generated jpms.args file, addressing JIRA issue MCOMPILER-397.

Changes:

  • Modified path handling in JPMS runtime arguments to replace absolute paths with relative paths using "." as the base directory

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (value == null) {
entry = entryIter.next();
value = entry.getKey();
value = entry.getKey().replaceAll(new File("").getAbsolutePath(), ".");
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The new path replacement logic for making builds reproducible lacks test coverage. Consider adding a test case that verifies absolute paths in JPMS arguments are correctly converted to relative paths in the generated jpms.args file.

Copilot uses AI. Check for mistakes.
if (value == null) {
entry = entryIter.next();
value = entry.getKey();
value = entry.getKey().replaceAll(new File("").getAbsolutePath(), ".");
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Creating a new File object on every iteration is inefficient. Consider computing the absolute path once outside the loop and storing it in a variable for reuse.

Copilot uses AI. Check for mistakes.
if (value == null) {
entry = entryIter.next();
value = entry.getKey();
value = entry.getKey().replaceAll(new File("").getAbsolutePath(), ".");
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The path replacement approach is fragile. This assumes that entry.getKey() always contains absolute paths starting with the current directory's absolute path, which may not be true in all cases. If entry.getKey() doesn't contain the absolute path prefix, this replacement will have no effect. Consider validating that the replacement actually occurred or using a more robust approach like converting absolute paths to relative paths using Path.relativize().

Copilot uses AI. Check for mistakes.
if (value == null) {
entry = entryIter.next();
value = entry.getKey();
value = entry.getKey().replaceAll(new File("").getAbsolutePath(), ".");
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

On Windows systems, File.getAbsolutePath() returns paths with backslashes which are regex special characters. When used with replaceAll (which treats the first parameter as a regex), this will cause a PatternSyntaxException. Additionally, dots in the path (which are common, e.g., in version numbers in parent directories) are also regex metacharacters that will cause incorrect matching.

Suggested change
value = entry.getKey().replaceAll(new File("").getAbsolutePath(), ".");
value = entry.getKey().replace(new File("").getAbsolutePath(), ".");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x waiting-for-feedback Waiting for 90 days until issues or pull request will be closed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants