Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I switch the bytecode target level in IntelliJ using Maven 3 profiles

I am using maven profiles to switch between two "setups" in Intelli J. How can I switch the bytecode target level? That is: I want to change the following setting in compiler.xml

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

Note: I tried to perform this via the following part in the respective 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 this does not work!

Note: The pom.xml etc. belongs to the finmath lib project, and if you are interested, it can be found at www.finmath.net

like image 302
Christian Fries Avatar asked Jan 22 '14 18:01

Christian Fries


People also ask

How do I change the target bytecode version in IntelliJ?

I went into Settings>Build, Execution, Deployment>Compiler>Java and saw that the target bytecode version for one of my modules was set to 1.5, so I changed it to 1.8, compiled, and it worked.


1 Answers

I am using IntelliJ IDEA 14.1.3 and it works with following config ...

<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!

like image 72
Madan Sapkota Avatar answered Sep 28 '22 01:09

Madan Sapkota