James Adams
James Adams

Reputation: 65

How to disable pruning with GWT compiler

How do I disable pruning in the GWT compiler?

(I'm trying to use the GWT compiler to create a Javascript version of a some game logic written in Java)

Maybe pruning is not the issue? I'm testing with the following Java class and none of the fields or the string "test123" are in the generated .js file;

Test1.java

package com.joyplay.web.games.mmrb.shared.d1;

public class Test1 {
    public String field1;
    public int field2=0;

    public void onModuleLoad() {
        field1 = "test123";
    }

    public int doSomething1(int a){
        return a+555;
    }

    public int doSomething2(){
        return ++field2;
    }    
}

Test1.gwt.xml

<module rename-to="hello">
    <inherits name="com.google.gwt.core.Core" />
    <source path="d1"/>
    <entry-point class="com.joyplay.web.games.mmrb.shared.d1.Test1"/>
</module>

Upvotes: 2

Views: 608

Answers (3)

Thomas Broyer
Thomas Broyer

Reputation: 64541

(I'm trying to use the GWT compiler to create a Javascript version of a some game logic written in Java)

Have a look at the gwt-exporter project.

Upvotes: 0

jusio
jusio

Reputation: 9900

GWT compiler will remove all of the code above, since it is doing nothing. You can turn off optimization using -draftCompile or -optimize 0 flags

Upvotes: 0

Igor Konoplyanko
Igor Konoplyanko

Reputation: 9374

Mainly this depends on how you build it.

For maven:

<gwt.jsStyle>PRETTY</gwt.jsStyle>

Or regarding to the official documentation:

-style Script output style: OBF[USCATED], PRETTY, or DETAILED (defaults to OBF)

Upvotes: -1

Related Questions