vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

No obvious way to set JDT settings

Open erindru opened this issue 6 years ago • 3 comments

I would like to use the "Text Blocks" feature of Java 13. I have the Java 13 JDK installed and that is being picked up correctly by VSCode.

In addition, I have modified my "pom.xml" file to include the "--enable-preview" JVM argument that turns on this feature, like so:

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<jvmArguments>--enable-preview</jvmArguments>
				</configuration>
			</plugin>
		</plugins>
	</build>

I also attempted to edit the .settings/org.eclipse.jdt.core.prefs file and set org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled but any changes to this file are overwritten when the "Clean the java language workspace" task is run

Environment
  • Operating System: Linux
  • JDK version: 13
  • Visual Studio Code version: 1.40.1
  • Java extension version: 0.53.1
Steps To Reproduce
  1. Create Java project with Java 13
  2. Attempt to use Text Block syntax
Current Result

Screenshot from 2019-11-28 11-59-08

Expected Result

I expect to be able to enable preview features in JDT and for Text Blocks to work with no compiler error

erindru avatar Nov 27 '19 23:11 erindru

Sorry I missed this one. But it should work, if the maven-compiler-plugin is configured correctly:

Maven project should automatically configure org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled in the JDT preferences, if the --enable-preview flag is added to the maven-compiler-plugin configuration:

<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>twelve</groupId>
  <artifactId>twelve</artifactId>
  <version>0.0.1-SNAPSHOT</version>
 <properties>
  	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>12</release>
          <compilerArgs>--enable-preview</compilerArgs>
        </configuration>
      </plugin>
	</plugins>
  </build>
</project>

fbricon avatar Mar 19 '20 22:03 fbricon

See also https://github.com/redhat-developer/vscode-java/issues/671#issuecomment-477379761 for non-Maven cases

fbricon avatar Mar 19 '20 22:03 fbricon

https://github.com/microsoft/vscode-java-pack/issues/839#issuecomment-3474738311 looks relevant to this as well (if it works, I haven't tested it, yet).

vorburger avatar Nov 09 '25 12:11 vorburger