tbroyer / gwt-maven-plugin

Starting fresh on building GWT projects with Maven
https://tbroyer.github.io/gwt-maven-plugin/
Apache License 2.0
167 stars 39 forks source link

Support using a different JVM than the one used to run Maven when forking GWT processes #130

Closed taxone closed 5 years ago

taxone commented 5 years ago

I know that the JVM is forked when the plugin invokes the GWT compiler, in fact it's possible to pass JVM parameters.

Is it possible to specify also the JVM executable, because I'd like to use a JDK different from the one used by the main Maven process? For example, the maven compiler plugin provides an "executable" configuration parameter for specifying the JDK executable.

Thanks in advance

tbroyer commented 5 years ago

It's not currently possible, no: https://github.com/tbroyer/gwt-maven-plugin/blob/644941dc7628986b717c59ea8737001a8dc36201/src/main/java/net/ltgt/gwt/maven/CommandLine.java#L22

As for how to add it, I'm torn. This is actually not like the maven-compiler-plugin, as that one invokes a javac tool, and not another JVM (java); it's more like maven-surefire-plugin for instance, which uses Toolchains to achieve that (and BTW gwt:test using Surefire, you'll likely prefer using the same configuration for gwt:compile than gwt:test, so Toolchains would rather be the way to go). Fwiw, maven-compiler-plugin is also toolchain-aware: https://maven.apache.org/guides/mini/guide-using-toolchains.html Now, maybe this plugin should support both Toolchains and an explicit executable, similar to the maven-compiler-plugin…

tbroyer commented 5 years ago

I just pushed some code to the toolchains branch, can you test it? (you can grab it through JitPack: https://jitpack.io/#tbroyer/gwt-maven-plugin/toolchains-SNAPSHOT, just configure a <pluginRepository> rather than a <repository>)

On gwt:compile, gwt:devmode and gwt:codeserver, you can configure the JVM either through a <jvm> property, with the path to the java executable, through a specific toolchain by using a <jdkToolchain> property (similar to that used by the maven-compiler plugin), through the maven-toolchains-plugin, or as fallback it will use the same JVM as the one used to run Maven (same as today). On gwt:test, the <jdkToolchain> is not present, as the code that's toolchain-aware is inherited from Surefire, so only <jvm>, the maven-toolchains-plugin, or the current JVM are an option.

taxone commented 5 years ago

It works! I wasn't able to use jitpack, I cloned and installed the code downloaded from the branch on GitHub. I verified using maven in debug mode that the JVM executable specified in the configuration was uded. Thank you very much. It would be nice merging the code into the master branch. Have a nice day.

tbroyer commented 5 years ago

I'll cut a new release soon (possibly this weekend), but in the mean time you can use the SNAPSHOT deployed to Sonatype OSSRH: https://central.sonatype.org/pages/ossrh-guide.html#accessing-repositories

jcompagner commented 4 years ago

any plans on making a new release with this toolchain support?

tbroyer commented 4 years ago

I just released the (long overdue) 1.0.0; now you just have to wait for it to appear in Central :wink:

agileabhi commented 1 year ago

which version of GWT-Plugin is toolchain aware? I am trying to use property with path to installed JDK. But it is not working.

tbroyer commented 1 year ago

Since version 1.0.0.

Don't hesitate to reach for help on https://groups.google.com/g/google-web-toolkit, and file a new issue here if the discussion there determines there's effectively a bug in the plugin (not impossible, this had only been manually tested 3 years ago when added, but there's no automated test so there might have been a regression)

agileabhi commented 1 year ago

is it possible to get the configuration for the toochain approach? Below is my pom.xml:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>

                <executions>
                    <execution>
                        <configuration>
                            <module>com.msci.eqa.prodqa.admin.ProdQAAdmin</module>
                            <webappDirectory>war</webappDirectory>
                        </configuration>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>1.8</version>
                            <vendor>oracle</vendor>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>

and below is toochain.xml:

<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
    <!-- JDK toolchains -->
    <toolchain>
        <type>jdk</type>
        <provides>
            <version>1.8</version>
            <vendor>oracle</vendor>
        </provides>
        <configuration>
            <jdkHome>C:\Program Files\Java\jdk1.8.0_341\bin</jdkHome>
        </configuration>
    </toolchain>
    </toolchains>
tbroyer commented 1 year ago

This is the repository for the net.ltgt.gwt.maven:gwt-maven-plugin plugin, not for org.codehaus.mojo:gwt-maven-plugin.

agileabhi commented 1 year ago

Sorry for asking on wrong forum. I didn't realize that. Thank You!