How to switch target bytecode level in IntelliJ using Maven 3 profiles

I use maven profiles to switch between the two โ€œsettingsโ€ in Intelli J. How can I switch the target bytecode level? That is: I want to change the following parameter in compiler.xml

<bytecodeTargetLevel> <module name="finmath-lib" target="1.6" /> </bytecodeTargetLevel> 

Note. I tried to accomplish this through the next part in the corresponding Maven 3 profile.

 <profile> <id>java-8</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </profile> 

but it will not work!

Note: pom.xml etc. belong to the finmath lib project, and if you are interested, you can find it at www.finmath.net

+6
source share
4 answers

I am using IntelliJ IDEA 14.1.3 and works with the following configuration ...

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> 

Hope this is helpful. Thanks!

+5
source

The problem is that you want to change it to 1.8.

I tried switching the IntelliJ compiler version between 1.7 and 1.6 or 1.5, using the Maven profile successfully .

However, when you want to change it to 1.8, the config will be ignored.

I don't know if this is maven or Intellj's problem. It seems that JDK 1.8 is not supported now, which is understandable.

+4
source

You can open the Maven Projects tool window in IntelliJ and select the profile that you want to use from the list.

0
source

In IntelliJ 13, File > Project Structure set Project language level to 8.0.

-1
source

All Articles