1

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.

Community
  • 1
  • 1
Ryan Shillington
  • 23,006
  • 14
  • 93
  • 108

2 Answers2

2

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.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Awesome suggestion. I hadn't thought of that. In fact, I could put the rest of my server-side stuff (images, html) in that public path too and then the code server would work much better. I actually gave up on this project, after about 4 hours of playing with it. I thing Super Dev Mode is still a little premature. It took 23s to compile my module, which I would need to wait for after each code change. That's far enough north of my current 5-10 seconds to wait for dev mode to make it a deal killer. – Ryan Shillington Nov 21 '12 at 18:47
  • By _anything server-side_, I was talking about _code_: an image is not _something server-side_. As for SuperDevMode performances, there's indeed room for improvement: generators have to support running incrementally (caching their result rather than regenerating it every time), and for now only RPC and ClientBundle do: not UiBinder, not Editor, not RequestFactory, etc. each of those will slow the compilation down. Expect better performances in later releases. There's a reason SuperDevMode is labelled as _experimental_ ;-) – Thomas Broyer Nov 22 '12 at 03:03
1

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.

Ryan Shillington
  • 23,006
  • 14
  • 93
  • 108