Hopefully fixed wrong version bumping; fixes #62
This commit is contained in:
@@ -128,6 +128,7 @@ public class ReleaserProperties {
|
||||
this.numberOfCheckedMilestones = numberOfCheckedMilestones;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Pom {
|
||||
|
||||
/**
|
||||
@@ -163,6 +164,7 @@ public class ReleaserProperties {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Maven {
|
||||
|
||||
/**
|
||||
|
||||
@@ -124,11 +124,17 @@ class PomUpdater {
|
||||
private List<VersionChange> updateParentIfPossible(ModelWrapper wrapper, Versions versions,
|
||||
Model model, List<VersionChange> sourceChanges) {
|
||||
String rootProjectName = wrapper.projectName();
|
||||
String rootProjectGroupId = wrapper.groupId();
|
||||
List<VersionChange> changes = new ArrayList<>(sourceChanges);
|
||||
if (model.getParent() == null || isEmpty(model.getParent().getVersion())) {
|
||||
log.debug("Can't set the value for parent... Will return {}", sourceChanges);
|
||||
return changes;
|
||||
}
|
||||
if (model.getGroupId() != null && !model.getGroupId().equals(rootProjectGroupId)) {
|
||||
log.info("Will not update the project's [{}] parent [{}] since its group id [{}] is not equal the parent group id [{}]",
|
||||
model.getArtifactId(), model.getParent().getArtifactId(), model.getGroupId(), rootProjectGroupId);
|
||||
return changes;
|
||||
}
|
||||
String parentGroupId = model.getParent().getGroupId();
|
||||
String parentArtifactId = model.getParent().getArtifactId();
|
||||
log.debug("Searching for a version of parent [{}:{}]", parentGroupId, parentArtifactId);
|
||||
@@ -158,9 +164,14 @@ class PomUpdater {
|
||||
private List<VersionChange> updateVersionIfPossible(ModelWrapper wrapper, Versions versions,
|
||||
Model model, List<VersionChange> sourceChanges) {
|
||||
String rootProjectName = wrapper.projectName();
|
||||
String rootProjectGroupId = wrapper.groupId();
|
||||
List<VersionChange> changes = new ArrayList<>(sourceChanges);
|
||||
String groupId = groupId(model);
|
||||
String artifactId = model.getArtifactId();
|
||||
if (model.getGroupId() != null && !model.getGroupId().equals(rootProjectGroupId)) {
|
||||
log.info("Will not update project [{}] since its group id [{}] is not equal the parent group id [{}]", model.getArtifactId(), model.getGroupId(), rootProjectGroupId);
|
||||
return changes;
|
||||
}
|
||||
log.debug("Searching for a version [{}:{}]", groupId, artifactId);
|
||||
String oldVersion = model.getVersion();
|
||||
String version = versions.versionForProject(rootProjectName);
|
||||
@@ -209,6 +220,14 @@ class ModelWrapper {
|
||||
return this.model.getArtifactId();
|
||||
}
|
||||
|
||||
String groupId() {
|
||||
if (this.model.getGroupId() != null) {
|
||||
return this.model.getGroupId();
|
||||
}
|
||||
return this.model.getParent() != null ?
|
||||
this.model.getParent().getGroupId() : "";
|
||||
}
|
||||
|
||||
boolean isDirty() {
|
||||
return !this.sourceChanges.isEmpty() || this.versions.shouldSetProperty(this.model.getProperties());
|
||||
}
|
||||
|
||||
@@ -172,6 +172,36 @@ public class PomUpdaterTests {
|
||||
.containsEntry("foo.version", "1.2.0.BUILD-SNAPSHOT");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_only_update_the_props_when_group_ids_dont_match() throws Exception {
|
||||
File originalPom = pom("/projects/project/children", "pom_different_group.xml");
|
||||
File pomInTemp = tmpFile("/project/children/pom_different_group.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion()).isEqualTo("1.2.2.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion()).isEqualTo("1.5.8.RELEASE");
|
||||
// the rest is the same
|
||||
BDDAssertions.then(overriddenPomModel.getProperties())
|
||||
.containsEntry("spring-cloud-sleuth.version", "0.0.3.BUILD-SNAPSHOT");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_update_the_project_if_group_doesnt_match() throws Exception {
|
||||
File originalPom = pom("/projects/project/children", "pom_case_from_contract.xml");
|
||||
File pomInTemp = tmpFile("/project/children/pom_case_from_contract.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-contract", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp, this.versions);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions, pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isEqualTo(asString(originalPom));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_the_child_pom_if_parent_is_matched_via_sc_dependencies_parent() throws Exception {
|
||||
File originalPom = pom("/projects/project/children", "pom_matching_parent.xml");
|
||||
@@ -274,6 +304,13 @@ public class PomUpdaterTests {
|
||||
return new ModelWrapper(parent);
|
||||
}
|
||||
|
||||
private ModelWrapper model(String projectName, String groupId) {
|
||||
Model parent = new Model();
|
||||
parent.setArtifactId(projectName);
|
||||
parent.setGroupId(groupId);
|
||||
return new ModelWrapper(parent);
|
||||
}
|
||||
|
||||
private File tmpFile(String relativePath) {
|
||||
return new File(this.temporaryFolder, relativePath);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
|
||||
Copyright 2013-2017 the original author or authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.blogspot.toomuchcoding.frauddetection</groupId>
|
||||
<artifactId>frauddetection</artifactId>
|
||||
<version>1.2.2.BUILD-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.3.5.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- verifier test dependencies-->
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud-verifier-plugin.version>${it-plugin.version}</spring-cloud-verifier-plugin.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- tag::plugin[] -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
|
||||
<version>${spring-cloud-verifier-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>convert</goal>
|
||||
<goal>generateStubs</goal>
|
||||
<goal>generateTests</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<contractsDirectory>src/test/contracts</contractsDirectory>
|
||||
<basePackageForTests>com.blogspot.toomuchcoding.frauddetection</basePackageForTests>
|
||||
<testMode>MOCKMVC</testMode>
|
||||
<testFramework>JUNIT</testFramework>
|
||||
<classifier>stubs</classifier>
|
||||
<nameSuffixForTests>Test</nameSuffixForTests>
|
||||
<ruleClassForTests>org.junit.rules.ErrorCollector</ruleClassForTests>
|
||||
<staticImports>
|
||||
<staticImport>com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers.*</staticImport>
|
||||
</staticImports>
|
||||
<imports>
|
||||
<import>com.blogspot.toomuchcoding.frauddetection.matchers.CustomMatchers</import>
|
||||
</imports>
|
||||
<ignoredFiles>
|
||||
<ignoredFile>broken**</ignoredFile>
|
||||
</ignoredFiles>
|
||||
<excludedFiles>
|
||||
<param>shouldMarkClientAsFraud.groovy</param>
|
||||
</excludedFiles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<baseClassForTests>com.blogspot.toomuchcoding.frauddetection.BaseAccurest</baseClassForTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- end::plugin[] -->
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2013-2017 the original author or authors.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>http-server-dsl</artifactId>
|
||||
<version>1.2.2.BUILD-SNAPSHOT</version>
|
||||
|
||||
<name>Spring Cloud Contract Verifier Http Server Sample</name>
|
||||
<description>Spring Cloud Contract Verifier Http Server Sample</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.8.RELEASE</version>
|
||||
<relativePath />
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<spring-cloud-sleuth.version>1.3.1.BUILD-SNAPSHOT</spring-cloud-sleuth.version>
|
||||
</properties>
|
||||
</project>
|
||||
Reference in New Issue
Block a user