Skip to content

Issue348 Log message only if trying to change maven property from ant… - #349

Open
jbindel wants to merge 1 commit into
apache:masterfrom
jbindel:master
Open

Issue348 Log message only if trying to change maven property from ant…#349
jbindel wants to merge 1 commit into
apache:masterfrom
jbindel:master

Conversation

@jbindel

@jbindel jbindel commented Nov 5, 2025

Copy link
Copy Markdown

fixes #348

It is expected that some values may be different, specifically the special "ant.file" property can change between invocations of the antrun plugin (e.g., changing name from pom.xml to .flattened.pom.xml in some projects), and we do not want to issue warnings for such expected situations. Instead, we log an INFO message when we are skipping a value, and we log nothing for property values that are the same in Ant and Maven.

The old behavior was to log a debug message, and new behavior is logging an info message only for rare things that may be surprising, but are generally innocuous and expected.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

… task

It is expected that some values may be different, specifically the
special "ant.file" property can change between invocations of the antrun
plugin (e.g., changing name from pom.xml to .flattened.pom.xml in some
projects), and we do not want to issue warnings for such expected
situations. Instead, we log an INFO message when we are skipping a
value, and we log nothing for property values that are the same in Ant
and Maven.

The old behavior was to log a debug message, and new behavior is logging
an info message only for rare things that may be surprising, but are
generally innocuous and expected.

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needs tests, probably an integration test but maybe you can do this with a unit test

String mavenValue = mavenProperties.getProperty(key);
if (mavenValue != null) {
if (!mavenValue.equals(entry.getValue())) {
getLog().info("Ant property '" + key + "=" + entry.getValue()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a warning is appropriate here, at least some of the time. Possibly this can be a little pickier about when it warns but if it's warn or info, it should be warn.

getLog().warn("Ant property '" + key + "=" + mavenProperties.getProperty(key)
+ "' clashes with an existing Maven property, SKIPPING this Ant property propagation.");
String mavenValue = mavenProperties.getProperty(key);
if (mavenValue != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This part, checking if the maven property value matches the ant property value, seems like a good idea.

Copilot AI left a comment

Copy link
Copy Markdown

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 adjusts AntRunMojo.copyProperties(Project, MavenProject) logging to reduce build output noise when exportAntProperties encounters Maven properties that already exist, aligning behavior with Issue #348 (avoid per-property WARN spam, only surface surprising mismatches).

Changes:

  • Stores the existing Maven property value in a local variable before deciding whether to propagate an Ant property.
  • Skips propagation when a Maven property already exists, and logs at INFO only when the Ant and Maven values differ.
  • Avoids logging anything when Ant and Maven values are the same.

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

Comment on lines +464 to 472
String mavenValue = mavenProperties.getProperty(key);
if (mavenValue != null) {
if (!mavenValue.equals(entry.getValue())) {
getLog().info("Ant property '" + key + "=" + entry.getValue()
+ "' clashes with an existing Maven property value '" + mavenValue
+ "', SKIPPING this Ant property propagation.");
}
continue;
}
Comment on lines +466 to +470
if (!mavenValue.equals(entry.getValue())) {
getLog().info("Ant property '" + key + "=" + entry.getValue()
+ "' clashes with an existing Maven property value '" + mavenValue
+ "', SKIPPING this Ant property propagation.");
}

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the original code only prints the key clashes. The new code prints values as well which can leak sensitive information into log files. Only the key should be logged.

@jbindel

jbindel commented Aug 2, 2026

Copy link
Copy Markdown
Author

I appreciate the suggestions, and I'll plan to address them soon.

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.

There is now multiple build WARNING output on every use of exportAntProperties as of 3.2.0

3 participants