Ryan Shillington
Ryan Shillington

Reputation: 25147

How do I get GWT Super Dev Mode / SuperDevMode to include my html file?

I was following this answer (thanks Ed) and found that he hadn't completely solved the problem.

I've got SuperDevMode / CodeServer up and running, but it doesn't include my html file(s), which makes it kinda useless. Do I really need to run 2 web servers?

I'm using Gradle, if that matters at all.

Upvotes: 1

Views: 1819

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64551

If you don't have anything server-side, then you can simply put your HTML host page in your public path instead of within a war folder, it'll then be served by the SuperDevMode CodeServer, as it's now part of the module. Don't forget to adjust your <script>: the *.nocache.js will be sibling of the page.

Upvotes: 2

Ryan Shillington
Ryan Shillington

Reputation: 25147

Here's the answer I came up with. In my HTML file, I removed the script that loads my *.nocache.js and instead generated it dynamically, like so:

<script type="text/javascript">
    function loadScript(scriptSrc)
    {
        var scriptTag = document.createElement('script');
        scriptTag.type = 'text/javascript';
        scriptTag.async = true;
        scriptTag.src = scriptSrc;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(scriptTag, s);
    }

    // Load the GWT script
    loadScript(('file:' == document.location.protocol ? "http://localhost:9876/" : "") + "admin/admin.nocache.js");
</script>

My Gradle task for running code Server looks like this:

task codeServer(dependsOn: "war") << {
    println("*----------------------------------------------------------------------------------------------*")
    println("   Ignore what this says below about going to http://localhost:9876/")
    println("   Instead, once the server below is up, in a separate command line, type:")
    println("       start $buildDir\\exploded\\Admin.html")
    println("*----------------------------------------------------------------------------------------------*")

    def gwtTempDir = "$buildDir/gwtTemp"
    (new File(gwtTempDir)).mkdirs()

    ant.java(classname: "com.google.gwt.dev.codeserver.CodeServer", failonerror: "true", fork: "true") {
        classpath {
            pathElement(location: "src/main/java")
            pathElement(location: "src/main/resources")
            pathElement(location: "$buildDir/classes/main")
            pathElement(path: configurations.compile.asPath)
        }
        jvmarg(value: "-Xmx512m")
        sysproperty(key: "java.util.logging.SimpleFormatter.format", value: System.getProperty("java.util.logging.SimpleFormatter.format"));
        arg(line: "-workDir " + gwtTempDir)
        arg(line: "-src " + "src/main/java")
        arg(value: "com.onlyinsight.oventio.Admin")
    }
}

So now, instead of having a second webserver, I can point my browser to file:///F:/projects/ConferenceModule/build/exploded/Admin.html and it all works.

I hope that helps somebody else.

Upvotes: 1

Related Questions