Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed javaVersion to jvmVersion #1468

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class ProjectRequestDocument {

private String artifactId;

private String javaVersion;
private String jvmVersion;

private String language;

Expand Down Expand Up @@ -100,12 +100,12 @@ public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}

public String getJavaVersion() {
return this.javaVersion;
public String getJvmVersion() {
return this.jvmVersion;
}

public void setJavaVersion(String javaVersion) {
this.javaVersion = javaVersion;
public void setJvmVersion(String jvmVersion) {
this.jvmVersion = jvmVersion;
}

public String getLanguage() {
Expand Down Expand Up @@ -175,7 +175,7 @@ public String toString() {
.add("buildSystem='" + this.buildSystem + "'")
.add("groupId='" + this.groupId + "'")
.add("artifactId='" + this.artifactId + "'")
.add("javaVersion='" + this.javaVersion + "'")
.add("javaVersion='" + this.jvmVersion + "'")
.add("language='" + this.language + "'")
.add("packaging='" + this.packaging + "'")
.add("packageName='" + this.packageName + "'")
Expand Down Expand Up @@ -327,7 +327,7 @@ public static class ErrorStateInformation {

private boolean invalid = true;

private Boolean javaVersion;
private Boolean jvmVersion;

private Boolean language;

Expand All @@ -343,12 +343,12 @@ public boolean isInvalid() {
return this.invalid;
}

public Boolean getJavaVersion() {
return this.javaVersion;
public Boolean getJvmVersion() {
return this.jvmVersion;
}

public void setJavaVersion(Boolean javaVersion) {
this.javaVersion = javaVersion;
public void setJvmVersion(Boolean jvmVersion) {
this.jvmVersion = jvmVersion;
}

public Boolean getLanguage() {
Expand Down Expand Up @@ -394,7 +394,7 @@ public void setMessage(String message) {
@Override
public String toString() {
return new StringJoiner(", ", "{", "}").add("invalid=" + this.invalid)
.add("javaVersion=" + this.javaVersion)
.add("javaVersion=" + this.jvmVersion)
.add("language=" + this.language)
.add("packaging=" + this.packaging)
.add("type=" + this.type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public ProjectRequestDocument createDocument(ProjectRequestEvent event) {
document.setVersion(determineVersionInformation(request));
document.setClient(determineClientInformation(request));

document.setJavaVersion(request.getJavaVersion());
if (StringUtils.hasText(request.getJavaVersion())
&& metadata.getJavaVersions().get(request.getJavaVersion()) == null) {
document.triggerError().setJavaVersion(true);
document.setJvmVersion(request.getJvmVersion());
if (StringUtils.hasText(request.getJvmVersion())
&& metadata.getJvmVersions().get(request.getJvmVersion()) == null) {
document.triggerError().setJvmVersion(true);
}

document.setLanguage(request.getLanguage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ void publishDocumentWithInvalidLanguage() {
}

@Test
void publishDocumentWithInvalidJavaVersion() {
void publishDocumentWithInvalidJvmVersion() {
ProjectRequest request = createProjectRequest();
request.setGroupId("com.example.acme");
request.setArtifactId("test");
request.setType("gradle-project");
request.setBootVersion("2.1.0.RELEASE");
request.setDependencies(Arrays.asList("web", "data-jpa"));
request.setLanguage("java");
request.setJavaVersion("1.2");
request.setJvmVersion("1.2");
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request, this.metadata);
this.mockServer.expect(requestTo("https://example.com/elastic/initializr/_doc/"))
.andExpect(method(HttpMethod.POST))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void createDocumentForSimpleProject() {
assertThat(document.getErrorState()).isNull();
assertThat(document.getGenerationTimestamp()).isEqualTo(event.getTimestamp());
assertThat(document.getGroupId()).isEqualTo("com.example");
assertThat(document.getJavaVersion()).isEqualTo("1.8");
assertThat(document.getJvmVersion()).isEqualTo("1.8");
assertThat(document.getLanguage()).isEqualTo("java");
assertThat(document.getPackageName()).isEqualTo("com.example.demo");
assertThat(document.getPackaging()).isEqualTo("jar");
Expand Down Expand Up @@ -160,14 +160,14 @@ void createDocumentWithUserAgentNoVersion() {
}

@Test
void createDocumentInvalidJavaVersion() {
void createDocumentInvalidJvmVersion() {
ProjectRequest request = createProjectRequest();
request.setJavaVersion("1.2");
request.setJvmVersion("1.2");
ProjectGeneratedEvent event = createProjectGeneratedEvent(request);
ProjectRequestDocument document = this.factory.createDocument(event);
assertThat(document.getJavaVersion()).isEqualTo("1.2");
assertThat(document.getJvmVersion()).isEqualTo("1.2");
assertThat(document.getErrorState().isInvalid()).isTrue();
assertThat(document.getErrorState().getJavaVersion()).isTrue();
assertThat(document.getErrorState().getJvmVersion()).isTrue();
assertThat(document.getErrorState().getLanguage()).isNull();
assertThat(document.getErrorState().getPackaging()).isNull();
assertThat(document.getErrorState().getType()).isNull();
Expand All @@ -182,7 +182,7 @@ void createDocumentInvalidLanguage() {
ProjectRequestDocument document = this.factory.createDocument(event);
assertThat(document.getLanguage()).isEqualTo("c++");
assertThat(document.getErrorState().isInvalid()).isTrue();
assertThat(document.getErrorState().getJavaVersion()).isNull();
assertThat(document.getErrorState().getJvmVersion()).isNull();
assertThat(document.getErrorState().getLanguage()).isTrue();
assertThat(document.getErrorState().getPackaging()).isNull();
assertThat(document.getErrorState().getType()).isNull();
Expand All @@ -197,7 +197,7 @@ void createDocumentInvalidPackaging() {
ProjectRequestDocument document = this.factory.createDocument(event);
assertThat(document.getPackaging()).isEqualTo("ear");
assertThat(document.getErrorState().isInvalid()).isTrue();
assertThat(document.getErrorState().getJavaVersion()).isNull();
assertThat(document.getErrorState().getJvmVersion()).isNull();
assertThat(document.getErrorState().getLanguage()).isNull();
assertThat(document.getErrorState().getPackaging()).isTrue();
assertThat(document.getErrorState().getType()).isNull();
Expand All @@ -212,7 +212,7 @@ void createDocumentInvalidType() {
ProjectRequestDocument document = this.factory.createDocument(event);
assertThat(document.getType()).isEqualTo("ant-project");
assertThat(document.getErrorState().isInvalid()).isTrue();
assertThat(document.getErrorState().getJavaVersion()).isNull();
assertThat(document.getErrorState().getJvmVersion()).isNull();
assertThat(document.getErrorState().getLanguage()).isNull();
assertThat(document.getErrorState().getPackaging()).isNull();
assertThat(document.getErrorState().getType()).isTrue();
Expand All @@ -237,7 +237,7 @@ void createDocumentInvalidDependency() {
ProjectRequestDocument document = this.factory.createDocument(event);
assertThat(document.getDependencies().getValues()).containsExactly("web", "data-jpa");
assertThat(document.getErrorState().isInvalid()).isTrue();
assertThat(document.getErrorState().getJavaVersion()).isNull();
assertThat(document.getErrorState().getJvmVersion()).isNull();
assertThat(document.getErrorState().getLanguage()).isNull();
assertThat(document.getErrorState().getPackaging()).isNull();
assertThat(document.getErrorState().getType()).isNull();
Expand All @@ -253,7 +253,7 @@ void createDocumentWithProjectFailedEvent() {
new IllegalStateException("my test message"));
ProjectRequestDocument document = this.factory.createDocument(event);
assertThat(document.getErrorState().isInvalid()).isTrue();
assertThat(document.getErrorState().getJavaVersion()).isNull();
assertThat(document.getErrorState().getJvmVersion()).isNull();
assertThat(document.getErrorState().getLanguage()).isNull();
assertThat(document.getErrorState().getPackaging()).isNull();
assertThat(document.getErrorState().getType()).isNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void customizeRegisterSpringBootPlugin() {
}

@Test
void customizeSetJavaVersion() {
void customizeSetJvmVersion() {
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().build();
MutableProjectDescription description = initializeDescription();
description.setLanguage(new JavaLanguage("11"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public InitializrMetadataTestBuilder addAllDefaults() {

public InitializrMetadataTestBuilder addBasicDefaults() {
return addDefaultTypes().addDefaultPackagings()
.addDefaultJavaVersions()
.addDefaultJvmVersions()
.addDefaultLanguages()
.addDefaultBootVersions();
}
Expand Down Expand Up @@ -136,17 +136,17 @@ public InitializrMetadataTestBuilder addPackaging(String id, boolean defaultValu
return this;
}

public InitializrMetadataTestBuilder addDefaultJavaVersions() {
return addJavaVersion("1.6", false).addJavaVersion("1.7", false).addJavaVersion("1.8", true);
public InitializrMetadataTestBuilder addDefaultJvmVersions() {
return addJvmVersion("1.6", false).addJvmVersion("1.7", false).addJvmVersion("1.8", true);
}

public InitializrMetadataTestBuilder addJavaVersion(String version, boolean defaultValue) {
public InitializrMetadataTestBuilder addJvmVersion(String version, boolean defaultValue) {
this.builder.withCustomizer((it) -> {
DefaultMetadataElement element = new DefaultMetadataElement();
element.setId(version);
element.setName(version);
element.setDefault(defaultValue);
it.getJavaVersions().addContent(element);
it.getJvmVersions().addContent(element);
});
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class KotlinDslGradleBuildWriter extends GradleBuildWriter {

private final Map<String, String> sourceCompatibilitiesToJavaVersion = new HashMap<>();
private final Map<String, String> sourceCompatibilitiesToJvmVersion = new HashMap<>();

@Override
protected void writeBuildscript(IndentingWriter writer, GradleBuild build) {
Expand Down Expand Up @@ -84,13 +84,13 @@ private String shortPluginNotation(String pluginId) {
protected void writeJavaSourceCompatibility(IndentingWriter writer, GradleBuildSettings settings) {
writer.println("java {");
writer.indented(() -> writer.println(
String.format("sourceCompatibility = %s", getJavaVersionConstant(settings.getSourceCompatibility()))));
String.format("sourceCompatibility = %s", getJvmVersionConstant(settings.getSourceCompatibility()))));
writer.println("}");
writer.println();
}

private String getJavaVersionConstant(String jvmVersion) {
return this.sourceCompatibilitiesToJavaVersion.computeIfAbsent(jvmVersion, (key) -> {
private String getJvmVersionConstant(String jvmVersion) {
return this.sourceCompatibilitiesToJvmVersion.computeIfAbsent(jvmVersion, (key) -> {
StringBuilder sb = new StringBuilder("JavaVersion.");
if (jvmVersion == null) {
return sb.append("VERSION_11").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class InitializrMetadata {
private final SingleSelectCapability packagings = new SingleSelectCapability("packaging", "Packaging",
"project packaging");

private final SingleSelectCapability javaVersions = new SingleSelectCapability("javaVersion", "Java Version",
private final SingleSelectCapability jvmVersions = new SingleSelectCapability("javaVersion", "Java Version",
"language level");

private final SingleSelectCapability languages = new SingleSelectCapability("language", "Language",
Expand Down Expand Up @@ -91,8 +91,8 @@ public SingleSelectCapability getPackagings() {
return this.packagings;
}

public SingleSelectCapability getJavaVersions() {
return this.javaVersions;
public SingleSelectCapability getJvmVersions() {
return this.jvmVersions;
}

public SingleSelectCapability getLanguages() {
Expand Down Expand Up @@ -133,7 +133,7 @@ public void merge(InitializrMetadata other) {
this.types.merge(other.types);
this.bootVersions.merge(other.bootVersions);
this.packagings.merge(other.packagings);
this.javaVersions.merge(other.javaVersions);
this.jvmVersions.merge(other.jvmVersions);
this.languages.merge(other.languages);
this.name.merge(other.name);
this.description.merge(other.description);
Expand Down Expand Up @@ -245,7 +245,7 @@ public Map<String, Object> defaults() {
defaults.put("type", defaultId(this.types));
defaults.put("bootVersion", defaultId(this.bootVersions));
defaults.put("packaging", defaultId(this.packagings));
defaults.put("javaVersion", defaultId(this.javaVersions));
defaults.put("javaVersion", defaultId(this.jvmVersions));
defaults.put("language", defaultId(this.languages));
defaults.put("groupId", this.groupId.getContent());
defaults.put("artifactId", this.artifactId.getContent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void customize(InitializrMetadata metadata) {
metadata.getTypes().merge(this.properties.getTypes());
metadata.getBootVersions().merge(this.properties.getBootVersions());
metadata.getPackagings().merge(this.properties.getPackagings());
metadata.getJavaVersions().merge(this.properties.getJavaVersions());
metadata.getJvmVersions().merge(this.properties.getJvmVersions());
metadata.getLanguages().merge(this.properties.getLanguages());
this.properties.getGroupId().apply(metadata.getGroupId());
this.properties.getArtifactId().apply(metadata.getArtifactId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class InitializrProperties extends InitializrConfiguration {
* Available java versions.
*/
@JsonIgnore
private final List<DefaultMetadataElement> javaVersions = new ArrayList<>();
private final List<DefaultMetadataElement> jvmVersions = new ArrayList<>();

/**
* Available programming languages.
Expand Down Expand Up @@ -116,8 +116,8 @@ public List<DefaultMetadataElement> getPackagings() {
return this.packagings;
}

public List<DefaultMetadataElement> getJavaVersions() {
return this.javaVersions;
public List<DefaultMetadataElement> getJvmVersions() {
return this.jvmVersions;
}

public List<DefaultMetadataElement> getLanguages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void mergeMetadata() {
assertThat(metadata.getTypes().getContent()).hasSize(1);
assertThat(metadata.getBootVersions().getContent()).hasSize(2);
assertThat(metadata.getPackagings().getContent()).hasSize(2);
assertThat(metadata.getJavaVersions().getContent()).hasSize(1);
assertThat(metadata.getJvmVersions().getContent()).hasSize(1);
assertThat(metadata.getLanguages().getContent()).hasSize(3);
assertThat(metadata.getName().getContent()).isEqualTo("metadata-merge");
assertThat(metadata.getDescription().getContent()).isEqualTo("Demo project for metadata merge");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ initializr:
- name: War
id: war
default: false
javaVersions:
jvmVersions:
- id: 1.6
default: false
- id: 1.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ initializr:
- name: Groovy
id: groovy
default: false
javaVersions:
jvmVersions:
- id: 11
default: true
- id: 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String write(InitializrMetadata metadata, String appUrl) {
dependencies(delegate, metadata.getDependencies());
type(delegate, metadata.getTypes());
singleSelect(delegate, metadata.getPackagings());
singleSelect(delegate, metadata.getJavaVersions());
singleSelect(delegate, metadata.getJvmVersions());
singleSelect(delegate, metadata.getLanguages());
singleSelect(delegate, metadata.getBootVersions(), this::mapVersionMetadata, this::formatVersion);
text(delegate, metadata.getGroupId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void convert(ProjectRequest request, MutableProjectDescription descriptio
description.setBuildSystem(getBuildSystem(request, metadata));
description.setDescription(request.getDescription());
description.setGroupId(cleanInputValue(request.getGroupId()));
description.setLanguage(Language.forId(request.getLanguage(), request.getJavaVersion()));
description.setLanguage(Language.forId(request.getLanguage(), request.getJvmVersion()));
description.setName(cleanInputValue(request.getName()));
description.setPackageName(cleanInputValue(request.getPackageName()));
description.setPackaging(Packaging.forId(request.getPackaging()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ProjectRequest {

private String packageName;

private String javaVersion;
private String jvmVersion;

// The base directory to create in the archive - no baseDir by default
private String baseDir;
Expand Down Expand Up @@ -159,12 +159,12 @@ public void setPackageName(String packageName) {
this.packageName = packageName;
}

public String getJavaVersion() {
return this.javaVersion;
public String getJvmVersion() {
return this.jvmVersion;
}

public void setJavaVersion(String javaVersion) {
this.javaVersion = javaVersion;
public void setJvmVersion(String jvmVersion) {
this.jvmVersion = jvmVersion;
}

public String getBaseDir() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void initializeRemoteConfig() throws Exception {
assertThat(metadata.getTypes().getContent()).hasSameSizeAs(localMetadata.getTypes().getContent());
assertThat(metadata.getBootVersions().getContent()).hasSameSizeAs(localMetadata.getBootVersions().getContent());
assertThat(metadata.getPackagings().getContent()).hasSameSizeAs(localMetadata.getPackagings().getContent());
assertThat(metadata.getJavaVersions().getContent()).hasSameSizeAs(localMetadata.getJavaVersions().getContent());
assertThat(metadata.getJvmVersions().getContent()).hasSameSizeAs(localMetadata.getJvmVersions().getContent());
assertThat(metadata.getLanguages().getContent()).hasSameSizeAs(localMetadata.getLanguages().getContent());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void convertShouldSetPlatformVersionFromRequest() {
@Test
void convertShouldSetLanguageForProjectDescriptionFromRequest() {
ProjectRequest request = createProjectRequest();
request.setJavaVersion("1.8");
request.setJvmVersion("1.8");
ProjectDescription description = this.converter.convert(request, this.metadata);
assertThat(description.getLanguage().id()).isEqualTo("java");
assertThat(description.getLanguage().jvmVersion()).isEqualTo("1.8");
Expand Down
Loading