Map project version from version capability

Closes gh-832
This commit is contained in:
Stephane Nicoll
2019-02-14 14:52:07 +01:00
parent 24887e1ab3
commit 701f3f6277
11 changed files with 56 additions and 36 deletions

View File

@@ -47,6 +47,8 @@ public class ProjectDescription {
private String artifactId;
private String version;
private String name;
private String description;
@@ -121,6 +123,14 @@ public class ProjectDescription {
this.artifactId = artifactId;
}
public String getVersion() {
return this.version;
}
public void setVersion(String version) {
this.version = version;
}
public String getName() {
return this.name;
}

View File

@@ -49,6 +49,8 @@ public final class ResolvedProjectDescription {
private final String artifactId;
private final String version;
private final String name;
private final String description;
@@ -66,6 +68,7 @@ public final class ResolvedProjectDescription {
this.language = description.getLanguage();
this.groupId = description.getGroupId();
this.artifactId = description.getArtifactId();
this.version = description.getVersion();
this.name = description.getName();
this.description = description.getDescription();
this.applicationName = description.getApplicationName();
@@ -115,6 +118,10 @@ public final class ResolvedProjectDescription {
return this.artifactId;
}
public String getVersion() {
return this.version;
}
public String getName() {
return this.name;
}

View File

@@ -40,9 +40,9 @@ class GradleBuildWriterTests {
void gradleBuildWithCoordinates() throws IOException {
GradleBuild build = new GradleBuild();
build.setGroup("com.example");
build.setVersion("0.0.1-SNAPSHOT");
build.setVersion("1.0.1-SNAPSHOT");
List<String> lines = generateBuild(build);
assertThat(lines).contains("group = 'com.example'", "version = '0.0.1-SNAPSHOT'");
assertThat(lines).contains("group = 'com.example'", "version = '1.0.1-SNAPSHOT'");
}
@Test

View File

@@ -40,11 +40,12 @@ class MavenBuildWriterTests {
MavenBuild build = new MavenBuild();
build.setGroup("com.example.demo");
build.setArtifact("demo");
build.setVersion("1.0.1-SNAPSHOT");
generatePom(build, (pom) -> {
assertThat(pom).textAtPath("/project/modelVersion").isEqualTo("4.0.0");
assertThat(pom).textAtPath("/project/groupId").isEqualTo("com.example.demo");
assertThat(pom).textAtPath("/project/artifactId").isEqualTo("demo");
assertThat(pom).textAtPath("/project/version").isEqualTo("0.0.1-SNAPSHOT");
assertThat(pom).textAtPath("/project/version").isEqualTo("1.0.1-SNAPSHOT");
});
}

View File

@@ -102,6 +102,9 @@ public abstract class AbstractProjectGenerationTester<SELF extends AbstractProje
if (projectDescription.getArtifactId() == null) {
projectDescription.setArtifactId("demo");
}
if (projectDescription.getVersion() == null) {
projectDescription.setVersion("0.0.1-SNAPSHOT");
}
if (projectDescription.getApplicationName() == null) {
projectDescription.setApplicationName("DemoApplication");
}