Skip to content

Instantly share code, notes, and snippets.

@lofidewanto
Created March 20, 2018 08:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lofidewanto/2262441fe61f887158347f68418f04e3 to your computer and use it in GitHub Desktop.
Save lofidewanto/2262441fe61f887158347f68418f04e3 to your computer and use it in GitHub Desktop.
GWT Boot - Better Implementation
package hello.client;
import com.google.gwt.core.client.*;
import com.google.gwt.user.client.ui.*;
@GwtModule(renameTo="basic")
public class YourEntryPoint implements EntryPoint {
@Override
public void onModuleLoad() {
Button button = new Button("Click me");
button.addClickHandler(clickEvent -> {
Window.alert("Hello World!");
});
RootPanel.get("helloButton").add(button);
}
@GwtModuleProperty
public String inherits() {
return "com.github.gwtboot.starter.Starter";
}
@GwtModuleProperty
public String sourcePath() {
return "client";
}
@GwtModuleProperty
public Map setProperty() {
Map<String, String> map = new HashMap<>();
map.add("gwt.logging.logLevel", "INFO");
map.add("gwt.logging.enabled", "TRUE");
return map;
}
}
@hrstoyanov
Copy link

hrstoyanov commented Apr 3, 2018

I think the current design of GWT modules is centered around the whole module, not just the entry point. Sooner or later, J2CL will have to adopt the new Java 9+ modular system. Therefore, a better approach might be to start fresh with Java 9 and J2CL and implement modular annotations as shown in this GWT example module-info.java :

//You can have module-level annotations in Java 9!
@GwtModule(name="MyModule")
@GwtEntryPoint(MyEntryPoint.class) //How many entry points can we have? Errai allows for many

//With repeatable annotations, you can replace <define-property name="..." values="..." />
GwtProperty(name="formfactor",values="desktop,tablet,mobile")
GwtProperty(name="locale",values="en,fr")
module gwtproject.myModule {

   //replacement for  <inherits name=.../>
    requires static gwtproject.otherModule; 
 
   //transitive dependencies
    requires static transitive gwtproject.yetAnotherModule;   
}

notice the use of static - this is typically the case with GWT where the transpiler converts Java->JS, but none of the original code is needed at run-time.

@lofidewanto
Copy link
Author

Yes, I agree with you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment