From 3a709511c4a8aaf434dc8a2061b183883cc37dea Mon Sep 17 00:00:00 2001 From: Arlo O'Keeffe Date: Fri, 23 Dec 2016 14:20:13 +0100 Subject: [PATCH] Notify BuildContext of changed build-info file Update Maven plugin to inform the BuildContext when changes are made to the `build-info` file. Prior to this commit Eclipse could continually trigger refreshes whenever "Refresh using native hooks or polling" was enabled and the file was written to `src/main/resources`. Closes gh-7741 --- spring-boot-parent/pom.xml | 5 +++++ spring-boot-tools/spring-boot-maven-plugin/pom.xml | 4 ++++ .../java/org/springframework/boot/maven/BuildInfoMojo.java | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/spring-boot-parent/pom.xml b/spring-boot-parent/pom.xml index cfea33eee90..1bcf0300dd5 100644 --- a/spring-boot-parent/pom.xml +++ b/spring-boot-parent/pom.xml @@ -222,6 +222,11 @@ kotlin-runtime 1.0.4 + + org.sonatype.plexus + plexus-build-api + 0.0.7 + org.zeroturnaround zt-zip diff --git a/spring-boot-tools/spring-boot-maven-plugin/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/pom.xml index 49da63144e6..a36e808c419 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/pom.xml +++ b/spring-boot-tools/spring-boot-maven-plugin/pom.xml @@ -170,6 +170,10 @@ org.codehaus.plexus plexus-utils + + org.sonatype.plexus + plexus-build-api + org.apache.maven.plugins diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java index 341438236eb..482c4eb9c81 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java @@ -22,10 +22,12 @@ import java.util.Map; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.sonatype.plexus.build.incremental.BuildContext; import org.springframework.boot.loader.tools.BuildPropertiesWriter; import org.springframework.boot.loader.tools.BuildPropertiesWriter.NullAdditionalPropertyValueException; @@ -41,6 +43,9 @@ import org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetail @Mojo(name = "build-info", defaultPhase = LifecyclePhase.GENERATE_RESOURCES, threadSafe = true) public class BuildInfoMojo extends AbstractMojo { + @Component + private BuildContext buildContext; + /** * The Maven project. */ @@ -67,6 +72,7 @@ public class BuildInfoMojo extends AbstractMojo { .writeBuildProperties(new ProjectDetails(this.project.getGroupId(), this.project.getArtifactId(), this.project.getVersion(), this.project.getName(), this.additionalProperties)); + this.buildContext.refresh(this.outputFile); } catch (NullAdditionalPropertyValueException ex) { throw new MojoFailureException(