Search code examples
javascriptjavamavengwtmaven-plugin

New GWT Maven plugin how pass parameters to compiler?


glad to ask you.

I am trying to migrate my old GWT eclipse project to the new GWT Maven Pulgin (not Mojos's). I want to know how this new pluging maganes the GWT compiler parameters like draftCompile and localWorkers, I have it not clear. Thank you in advice.

I tried the goal mvn gwt:compile -DdraftCompile=true, but I want to add this flag in the POM XML file.


Solution

  • In your pom.xml, you add a <configuration> node. For example:

        <plugin>
          <groupId>net.ltgt.gwt.maven</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>1.0.0</version>
          <extensions>true</extensions>
          <configuration>
            <sourceLevel>${maven.compiler.release}</sourceLevel>
            <moduleName>${gwtModule}</moduleName>
            <failOnError>true</failOnError>
            <logLevel>${gwt.logLevel}</logLevel>
            <style>${gwt.style}</style>
            <draftCompile>${gwt.draftCompile}</draftCompile>
            <localWorkers>${gwt.localWorkers}</localWorkers>
            <startupUrls>${gwtRunTargetUrl}</startupUrls>
            <codeserverArgs>
              <arg>-bindAddress</arg> <arg>0.0.0.0</arg>
            </codeserverArgs>
            <devmodeArgs>
              <devmodeArg> -bindAddress 0.0.0.0 </devmodeArg>
            </devmodeArgs>
            <jvmArgs>
              <jvmArg> -Xss4M </jvmArg>
              <jvmArg> -Dorg.eclipse.jetty.LEVEL=INFO </jvmArg>
              <jvmArg> -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog 
            </jvmArgs>
          </configuration>
        </plugin>
    

    In my example, some configuration values have been defined earlier in the properties section of the pom.xml. E.g.

    <properties>
      <gwtRunTargetUrl>app.html</gwtRunTargetUrl>
      <gwtModuleName>foo.WebFormApp</gwtModuleName>
      <gwtModuleShortName>WebFormApp</gwtModuleShortName>
      <gwt.localWorkers>2</gwt.localWorkers>
      <gwt.draftCompile>false</gwt.draftCompile>
      <gwt.style>OBFUSCATED</gwt.style>  <!-- OBFUSCATED/PRETTY/DETAILED -->
      <gwt.logLevel>INFO</gwt.logLevel>
    </properties>