Skip to content

Commit

Permalink
[MARTIFACT-64] add inheritence diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Oct 13, 2024
1 parent 0834ef9 commit c81edae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/it/check-buildplan-ok/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.

invoker.goals=artifact:check-buildplan
invoker.goals=artifact:check-buildplan -Ddiagnose
2 changes: 1 addition & 1 deletion src/it/check-buildplan-ok/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<packaging>pom</packaging>

<properties>
<project.build.outputTimestamp>2011-11-11T11:11:11Z</project.build.outputTimestamp>
<project.build.outputTimestamp>0</project.build.outputTimestamp>
</properties>

<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ static boolean hasBadOutputTimestamp(
boolean diagnose) {
Instant timestamp =
MavenArchiver.parseBuildOutputTimestamp(outputTimestamp).orElse(null);
String effective = ((timestamp == null) ? "disabled" : DateTimeFormatter.ISO_INSTANT.format(timestamp));

if (diagnose) {
log.info("outputTimestamp = " + outputTimestamp + " => "
+ ((timestamp == null) ? "disabled" : DateTimeFormatter.ISO_INSTANT.format(timestamp)));
log.info("outputTimestamp = " + outputTimestamp
+ (effective.equals(outputTimestamp) ? "" : (" => " + effective)));

String projectProperty = project.getProperties().getProperty("project.build.outputTimestamp");
String modelProperty = project.getModel().getProperties().getProperty("project.build.outputTimestamp");
Expand All @@ -185,11 +186,29 @@ static boolean hasBadOutputTimestamp(
log.info("plugin outputTimestamp parameter diagnostics:" + System.lineSeparator()
+ " - plugin outputTimestamp parameter (defaultValue=\"${project.build.outputTimestamp}\") = "
+ outputTimestamp + System.lineSeparator()
+ " - project project.build.outputTimestamp property = " + projectProperty
+ " - project.build.outputTimestamp property from project = " + projectProperty
+ System.lineSeparator()
+ " - model project.build.outputTimestamp property = " + modelProperty
+ " - project.build.outputTimestamp property from project model = " + modelProperty
+ System.lineSeparator()
+ " - original model project.build.outputTimestamp property = " + originalModelProperty);
+ " - project.build.outputTimestamp property from project original model = "
+ originalModelProperty);

MavenProject parent = project.getParent();
if (parent != null) {
StringBuilder sb = new StringBuilder("Inheritance analysis property:" + System.lineSeparator()
+ " - current " + project.getId() + " property = " + projectProperty);
while (parent != null) {
String parentProperty = parent.getProperties().getProperty("project.build.outputTimestamp");
sb.append(System.lineSeparator());
sb.append(" - " + (reactorProjects.contains(parent) ? "reactor" : "external") + " parent "
+ parent.getId() + " property = " + parentProperty);
if (!projectProperty.equals(parentProperty)) {
break;
}
parent = parent.getParent();
}
log.info(sb.toString());
}
}

if (timestamp == null) {
Expand All @@ -209,7 +228,7 @@ static boolean hasBadOutputTimestamp(

if (log.isDebugEnabled()) {
log.debug("project.build.outputTimestamp = \"" + outputTimestamp + "\" => "
+ DateTimeFormatter.ISO_INSTANT.format(timestamp));
+ (effective.equals(outputTimestamp) ? "" : (" => " + effective)));
}

// check if timestamp defined in a project from reactor: warn if it is not the case
Expand Down

0 comments on commit c81edae

Please sign in to comment.