GWT compile

Hello, can someone explain me please how to do the gwt compiling, here an example in ant:

<java classpathref="myproject-classpath" classname="com.google.gwt.dev.Compiler" fork="true" failonerror="true">
   <jvmarg value="-Xmx1024M" />
   <jvmarg value="-Xss1024k" />
   <jvmarg value="-Djava.awt.headless=true" />
   <arg value="-style" />
   <arg value="PRETTY" />
     <arg value="-localWorkers" />
   <arg value="5" />
     <arg value="-war" />
   <arg value="${build.dir}/war" />
   <arg value=""com.myproject.FrontEnd"" />
  </java>
    <javac debug="on" destdir="${build.dir}/war/WEB-INF/classes">
   <src path="${build.dir}/webapp-src">
   </src>
   <classpath>
    <fileset dir="${basedir}/lib">
     <include name="**/*.jar" />
    </fileset>
   </classpath>
  </javac>

Well my solution was like this but I have got nothing:

task gwtcompile(type:JavaExec)<<{
    group="myproject"
    main="com.google.gwt.dev.Compiler"
    classpath project.configurations.myproject
    jvmArgs "-Xmx1024M"
    jvmArgs "-Xss1024k"
    jvmArgs "-Djava.awt.headless=true"
    args "-style"
    args "PRETTY"
    args "-localWorkers"
    args "5"
    args "-war"
    args "$buildDir/war"
    args "com.myproject.FrontEnd"
  }
task compilemyproject(type:JavaCompile)<<{
        source = sourceSets.myproject.javasrcDirs
    classpath = sourceSets.myproject.runtimeClasspath
    destinationDir="$buildDir/war/WEB-INF/classes"
  }

You’ll have to remove the ‘<<’ (twice). Otherwise, the tasks are going to get configured after they have been executed.

actually I would like to run this in the execution phase, that’s why I have used “<<”. Can you please explain us how to do the gwt compiling, there is a solution using ant task call from gradle, but I always prefer to use pure gradle functions. Thank you Peter

The task gets run in the execution phase in any case, but it needs to be configured before it gets run. So you must remove the << (twice). And no, I can’t tell you what the right way to execute ‘com.google.gwt.dev.Compiler’ is.

I have modified my solution

task gwtcompile(type:JavaExec){
  classpath project.configurations.gwt
  main "com.google.gwt.dev.Compiler"
  jvmArgs "-Xmx1024M"
  jvmArgs "-Xss1024k"
  jvmArgs "-Djava.awt.headless=true"
  args "com.myproject.FrontEnd"
  args "-style"
  args "PRETTY"
  args "-localWorkers"
  args "5"
  args "-war"
  args "$buildDir/war"
  }

but I still always get errors

* What went wrong:
Execution failed for task ':gwtcompile'.
> Process 'command 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 1

Although I never found a specification of jvm return codes, it usually means, that your main class was not found (You can easily check it, by running the compiler on the command line). Also, the JavaExec task usually prints the outputs of java, so you should check for that in your gradle log.

Are you positive, that your Ant example is working? If so, you should check the myproject-classpath Classpath ref and compare it to your configuration gwt. (Maybe you can also post the configuration here)

Hello, I have updated my code like this:

task gwtcompile( type:JavaExec){
  main="com.google.gwt.dev.Compiler"
     classpath{
    [
      configurations.gwt,
      sourceSets.myproject.java.srcDirs,
      sourceSets.myproject.runtimeClasspath
    ]
  }
    args "-style"
  args "PRETTY"
  args "-localWorkers"
  args "5"
  args "-war"
  args "$buildDir/war"
  args "-logLevel"
  args "ERROR"
  args "com.myproject.FrontEnd"
    jvmArgs "-Xmx1024M"
  jvmArgs "-Xss1024k"
  jvmArgs "-Djava.awt.headless=true"
   }

Can anyone explain me why including

"sourceSets.myproject.runtimeClasspath"

cause me an jvm error

createprocess error=2

Well this due to long classpath or extension problem. So how can I update my classpath to get all configurations for dependencies and all java sources included.

Thank you

Check out https://github.com/mdavis95/gradle-gwt

I have already solved this problem by putting some dependency in seperate classpath. But if you are interested in digging deeper to this problem check out my non answered question in the link below: http://forums.gradle.org/gradle/topics/javaexec_classpath_configurations_problem Perhaps this may look like wierd question because I am newbie in Gradle and I was trying to migrate an advanced Ant build to gradle one. Fianlly I think that we share the same vision and thank you for replying :slight_smile: