-1

This question might sound similar to the one over here. My case is given below.

  1. I have written a project in groovy but now I want to use it as javascript in browser applications (web based GUIs). Went through Google Web Toolkit, and learned that it needs strongly typed Java code. Please let me know if I'm wrong about GWT.
  2. Assuming that I want to stick with GWT, is there any way to convert a groovy project to java project? Else, would it be possible to have the javascript version of my groovy project using GWT or any other framework?

Thanks.

Community
  • 1
  • 1
freax
  • 169
  • 1
  • 5
  • 12

2 Answers2

0

The GWT compiler is really a Java source to JavaScript source translator; it is a specific compiler which consumes Java files (article is 2008, but this main concept probably didn't changed). A GWT Groovy-to-JS would be needed.

You can try using Grooscript, which transcompiles Groovy to Javascript.

A Groovy-to-Java transcompiler seems out of hand (thread is 2009, but it's concepts haven't changed).

Also noteworthy: Groovy and GWT: Combining both paradigms

Community
  • 1
  • 1
Will
  • 14,348
  • 1
  • 42
  • 44
  • Yes, I knew about the pros and cons of Grails and GWT on the server side. Looks like if I want to stick with GWT, I'd have to refrain from writing Groovy code. Not really sure about Grooscript, have to test that. – freax Dec 30 '14 at 01:25
0

A bit late to the party...

You can use TeaVM it compiles Java bytecode (.class) to JavaScript - that means it does not matter if it is compiled from Java, Kotlin, Scala or Groovy.

There is a challenge though, since TeaVM does not support reflection (which dynamic Groovy uses) you have to annotate the code with @CompileStatic

dauer
  • 96
  • 4