I have Maven 2.2.1, which uses JAVA 1.6. But I need to compile and execute my project with 1.7. I don't want to change JAVA_HOME variable because of other projects, bur as far I know, I can configurate that in pom.
With the code below, I can compile my project, but I cannot execute it because of minor version. What do I do wrong? Or is it impossible to do it all in pom? Or does it have something to do with maven version (2.2.1).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
<executable>...path-to-my-1.7-javac...</executable>
<compilerVersion>1.7</compilerVersion>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
EDIT: SOLUTION WITH MAVEN-EXEC-PLUGIN
Problem solved with adding the configuration below:
<properties>
<arg0>defaultParam1</arg0>
</properties>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>path-to-java-1.7/bin/java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>${main.class}</argument>
<argument>${arg0}</argument>
</arguments>
</configuration>
</plugin>