Fix BuildInfo up-to-date check when group, name, or version changes
Previously, if the project's group, name, or version changed the BuildInfo task would still be considered up-to-date as the values of the project's properties were not reflected in the fields of the BuildInfo instance. This commit updates BuildInfo to copy the value of the project's property to the corresponding BuildInfo field when the property is read using its getter method on BuildInfo. Closes gh-12266
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -84,6 +85,16 @@ public class BuildInfoIntegrationTests {
|
||||
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() {
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildResult result = this.gradleBuild.build("buildInfo", "-PnullTime",
|
||||
"-PprojectVersion=0.2.0");
|
||||
System.out.println(result.getOutput());
|
||||
assertThat(result.task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
private Properties buildInfoProperties() {
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/build-info.properties");
|
||||
|
||||
Reference in New Issue
Block a user