Fixed snapshot resolution; fixes gh-79
This commit is contained in:
@@ -65,7 +65,6 @@ public class GradleUpdater {
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
private final Projects projects;
|
||||
private final ProjectVersion versionFromScRelease;
|
||||
private final boolean snapshotVersion;
|
||||
private final boolean assertSnapshots;
|
||||
|
||||
@@ -73,7 +72,6 @@ public class GradleUpdater {
|
||||
ProjectVersion versionFromScRelease, boolean assertSnapshots) {
|
||||
this.properties = properties;
|
||||
this.projects = projects;
|
||||
this.versionFromScRelease = versionFromScRelease;
|
||||
this.snapshotVersion = !assertSnapshots || versionFromScRelease.isSnapshot();
|
||||
this.assertSnapshots = assertSnapshots;
|
||||
}
|
||||
@@ -115,9 +113,9 @@ public class GradleUpdater {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
lineNumber++;
|
||||
boolean containsSnapshot = line.contains("BUILD-SNAPSHOT");
|
||||
boolean containsSnapshot = line.contains("SNAPSHOT");
|
||||
if (containsSnapshot) {
|
||||
throw new IllegalStateException("The file [" + path + "] contains a BUILD-SNAPSHOT "
|
||||
throw new IllegalStateException("The file [" + path + "] contains a SNAPSHOT "
|
||||
+ "version for a non snapshot release in line number [" + lineNumber + "]\n\n" + line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
@@ -38,6 +40,10 @@ import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
*/
|
||||
public class ProjectPomUpdater {
|
||||
|
||||
private static final List<String> IGNORED_SNAPSHOT_LINE_CHECKS = Arrays.asList(
|
||||
"replace="
|
||||
);
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectPomUpdater.class);
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
@@ -138,9 +144,10 @@ public class ProjectPomUpdater {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
lineNumber++;
|
||||
boolean containsSnapshot = line.contains("BUILD-SNAPSHOT");
|
||||
boolean containsSnapshot = line.contains("SNAPSHOT") &&
|
||||
IGNORED_SNAPSHOT_LINE_CHECKS.stream().noneMatch(line::contains);
|
||||
if (containsSnapshot) {
|
||||
throw new IllegalStateException("The file [" + path + "] contains a BUILD-SNAPSHOT "
|
||||
throw new IllegalStateException("The file [" + path + "] contains a SNAPSHOT "
|
||||
+ "version for a non snapshot release in line number [" + lineNumber + "]\n\n" + line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GradleUpdaterTests {
|
||||
|
||||
thenThrownBy(() -> new GradleUpdater(properties).updateProjectFromSCRelease(projectRoot,
|
||||
projects, new ProjectVersion("spring-cloud-contract", "1.0.0"), true))
|
||||
.hasMessageContaining("contains a BUILD-SNAPSHOT version for a non snapshot release in line number");
|
||||
.hasMessageContaining("contains a SNAPSHOT version for a non snapshot release in line number");
|
||||
}
|
||||
|
||||
private File file(String relativePath) throws URISyntaxException {
|
||||
|
||||
Reference in New Issue
Block a user