mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 10:08:22 +08:00
Map project version from version capability
Closes gh-832
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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");
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user