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

choosing Java 11 causes java.version to be set to 1.8 in pom.xml file #739

Closed
martinlippert opened this issue Sep 27, 2018 · 10 comments
Closed

Comments

@martinlippert
Copy link

I create a project and select Java 11 + maven, but the project gets <java.version>1.8</java.version> generated.

@kdvolder
Copy link

Just to add, it is the same for gradle projects too. Selecting Java 11 generates a build.gradle that has this line in it:

sourceCompatibility = 1.8

@wilkinsona
Copy link
Contributor

wilkinsona commented Sep 27, 2018

What version of Boot did you use? You need to select Spring Boot 2.1 to use Java 11, otherwise the Java version is deliberately downgraded to 8 as Boot 2.0 and earlier do not support Java 11.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Sep 27, 2018
@martinlippert
Copy link
Author

@wilkinsona haha, you are absolutely right, that is the piece that I stumbled upon.... Lets close this again.

@wilkinsona wilkinsona added status: invalid and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 27, 2018
@kdvolder
Copy link

I just used what the wizard selects by default. So 2.0.5 release. Arguably this 'silent downgrade' is a bit confusing. Though I guess generating an invalid combination of Boot 2.0 with Java 11, is probably worse.

@wilkinsona
Copy link
Contributor

Yeah, our opinion is that the silent downgrade is the least bad option. A better one may be some metadata that describes the valid combinations so that it can be sorted out on the client-side. That wouldn't help users creating projects using curl though, and would require changes in the service and clients before it became useful.

@kdvolder
Copy link

Perhaps we should put some thought into these kinds of scenarios so that the initializer service might provide some kind of diagnostic feedback when user selects a 'invalid' combination of option. I think that would be preferable over just silently changing some of the options. Maybe the service could provide an endpoint to 'validate' a selection of options and it could return a some result indiicating 'this looks okay' or some sensible error message that the wizard could display to the user?

Just a thought. Not sure it is worth the effort to develop this.

@asarkar
Copy link

asarkar commented Sep 6, 2019

@wilkinsona I found this problem using 2.1.7.RELEASE. See build.gradle below. This ticket should be reopened.

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
	id("org.springframework.boot") version "2.1.7.RELEASE"
	id("io.spring.dependency-management") version "1.0.8.RELEASE"
	kotlin("jvm") version "1.2.71"
	kotlin("plugin.spring") version "1.2.71"
}

group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
	mavenCentral()
}

dependencies {
	implementation("org.springframework.boot:spring-boot-starter-webflux")
	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
	implementation("org.jetbrains.kotlin:kotlin-reflect")
	implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
	testImplementation("org.springframework.boot:spring-boot-starter-test")
	testImplementation("io.projectreactor:reactor-test")
}

tasks.withType<KotlinCompile> {
	kotlinOptions {
		freeCompilerArgs = listOf("-Xjsr305=strict")
		jvmTarget = "1.8"
	}
}

@wilkinsona
Copy link
Contributor

This is the expected behaviour when using Kotlin. Kotlin generates Java 8 byte code and doesn't make any use of Java 11's features (note the stdlib-jdk8 dependency, for example). So, for consistency with that, the Java version is downgraded to match.

#211 and #773 are tracking some changes in this area which may be of interest.

@asarkar
Copy link

asarkar commented Sep 6, 2019

@wilkinsona I think some sort of indication would be very helpful. Either the Java 8+ options could be disabled, or a pop up with the explanation you provided...anything but crickets.

@wilkinsona
Copy link
Contributor

I've opened spring-io/start.spring.io#250 so that we can consider our options.

sayeedap pushed a commit to sayeedap/initializr that referenced this issue Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants