0

I am trying to specify, in my maven settings.xml and my pom.xml, which jvm to use for my gwt project.

I am using the suggestion from https://stackoverflow.com/a/20787334/265119. I have used this on other, non-gwt projects successfully.

Now however it seems that maven is ignoring this, and continues to use java 8, whereas I have set the following in my settings.xml:

<profiles>        
<profile>
<id>default</id>
    <properties>
            <JAVA_1_7_HOME>/usr/lib/jvm/java-7-oracle/bin/javac</JAVA_1_7_HOME>
            <JAVA_1_8_HOME>/usr/lib/jvm/java-8-oracle/bin/javac</JAVA_1_8_HOME>
        </properties>
</profile>
  </profiles>
  <activeProfiles>
    <activeProfile>default</activeProfile>
</activeProfiles>

And in my pom.xml:

 <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <executable>${JAVA_1_7_HOME}</executable>
                    </configuration>
                </plugin>

Does anyone know why maven is ignoring these? Does the gwt maven plugin also need to specify the jvm version?

Thanks

Community
  • 1
  • 1
Magick
  • 4,603
  • 22
  • 66
  • 103

1 Answers1

0

Is the profile really activated? Your POM ought to work, but only if the profile is activated.

You can run mvn help:active-profiles to find out if your profile is active.

Also, in order for <executable> to work, you need to set <fork>true</fork> as well. As explained here: http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#executable

Daniel
  • 4,033
  • 4
  • 24
  • 33
  • Hi @Daniel, yes the profile is active. And I tried adding `true` but it did not solve the problem. Thanks – Magick Oct 09 '15 at 12:18
  • Is your compiler plugin specified in the `` section? – Daniel Oct 09 '15 at 12:28
  • Hi @Daniel, no, however, I think I am a step closer. The gwt-maven-plugin has a configuration setting for jvm. When I set this I can see it is now using 1.7. Unfortunately this causes a new error - ' javac: invalid flag: -Xmx512m'. The strange thing is this arg doesnt exist in my pom. – Magick Oct 09 '15 at 12:55
  • I think it may be the default. Check out the `` here: https://gwt-maven.googlecode.com/svn/docs/maven-googlewebtoolkit2-plugin/examples.html – Daniel Oct 09 '15 at 13:04
  • Thank you @Daniel, yes I think you are correct. Thanks. Any idea on how to get around the 'javac: invalid flag: -Xmx512m' error? Would you advice on opening a bug report with Larry Page and Sergey Brin ? – Magick Oct 09 '15 at 13:15
  • Try to blank out the field (``) or perhaps setting the flag to something innocuous that works for both the JVM and `javac`, like `-verbose`. – Daniel Oct 10 '15 at 07:44