jiakuan / gwt-gradle-plugin

Gradle plugin to support GWT related tasks.
https://gwt-gradle.docstr.org
Other
63 stars 34 forks source link

GwtSuperDev refresh does not work #45

Closed lluisgener closed 3 years ago

lluisgener commented 3 years ago

Hi.

GwtSuperDev just seems to work fine on the first load, but when a page refresh is issued, it complains "Unable to load Super Dev Mode version of XXX".

In Intellij I can see that it's looking for a file that does not exist (because a "null" is prepended to the path and I don't know why).

GET /XXX/nullgwt/clean/clean.css
   Sent error page: not found: C:\MYGROUP\XXX\web-project\build\gwt\work\XXX\compile-2\war\XXX\nullgwt\clean\clean.css.gz

build.gradle:

group 'my.group'
version = '1.71'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'gwt'

//Java version compatibility to use when compiling Java source.
sourceCompatibility = 1.7
//Java version to generate classes for.
targetCompatibility = 1.7

buildscript {
    repositories {
        jcenter() 
        maven {
          url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'org.wisepersist:gwt-gradle-plugin:1.1.12'
    }
}

repositories {
    mavenCentral()
    maven {
        url "http://maven.geomajas.org/"
        name "HighCharts"
    }   
    flatDir {
        dirs 'lib'
    }
}

dependencies {
    compile group: 'org.moxieapps.gwt', name: 'highcharts', version: '1.7.0'
    compile group: 'com.smartgwt', name: 'smartgwt', ext:'jar'
    compile group: 'com.smartgwt', name: 'smartgwt-skins', ext:'jar'
    compile group: 'com.google.code', name: 'gwt-eye-candy-0.3', ext:'jar'    
}

sourceSets {    
    main {      
        java {
            srcDirs "src"            
        }        
    }
}

compileJava {
    //enable incremental compilation
    options.incremental = true
}

gwt {
    gwtVersion='2.8.1'
    modules 'xxx'         
    maxHeapSize="2048m"
    minHeapSize="1024m"

    superDev {
        port = 8080
    }
}

Is this an error or some configuration related issue?

Thanks in advance.

jiakuan commented 3 years ago

Did you use GWT’s Clean style?

On Thu, 27 May 2021 at 6:33 pm, lluisgener @.***> wrote:

Hi.

GwtSuperDev just seems to work fine on the first load, but when a page refresh is issued, it complains "Unable to load Super Dev Mode version of XXX".

In Intellij I can see that it's looking for a file that does not exist (because a "null" is prepended don't know why).

GET /XXX/nullgwt/clean/clean.css Sent error page: not found: C:\MYGROUP\XXX\web-project\build\gwt\work\XXX\compile-2\war\XXX**null**gwt\clean\clean.css.gz

build.gradle:

`group 'my.group' version = '1.71'

apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'gwt'

//Java version compatibility to use when compiling Java source. sourceCompatibility = 1.7 //Java version to generate classes for. targetCompatibility = 1.7

buildscript { repositories { jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'org.wisepersist:gwt-gradle-plugin:1.1.12' } }

repositories { mavenCentral() maven { url "http://maven.geomajas.org/" name "HighCharts" } flatDir { dirs 'lib' } }

dependencies { compile group: 'org.moxieapps.gwt', name: 'highcharts', version: '1.7.0' compile group: 'com.smartgwt', name: 'smartgwt', ext:'jar' compile group: 'com.smartgwt', name: 'smartgwt-skins', ext:'jar' compile group: 'com.google.code', name: 'gwt-eye-candy-0.3', ext:'jar' }

sourceSets { main { java { srcDirs "src" } } }

compileJava { //enable incremental compilation options.incremental = true }

gwt { gwtVersion='2.8.1' modules 'xxx' maxHeapSize="2048m" minHeapSize="1024m"

superDev { port = 8080 }

}`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jiakuan/gwt-gradle-plugin/issues/45, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECF5A4AUM7MLEWRZ3IFZDTPYNZFANCNFSM45T66S6A .

lluisgener commented 3 years ago

Yes, but if I remove it, it happens too, with the XXX.nocache.js file.

File: gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='XXX'>
  <inherits name='com.google.gwt.user.User'/>

  <inherits name='com.google.gwt.json.JSON'/>

  <inherits name='com.google.gwt.user.theme.clean.Clean'/>

  <inherits name='org.moxieapps.gwt.highcharts.Highcharts'/>  
  <inherits name='com.smartgwt.SmartGwtNoTheme'/>  
  <inherits name='com.smartclient.tools.SmartClientTools'/>
  <inherits name='com.smartclient.theme.graphite.Graphite'/>     

  <entry-point class='my.group.XXX'/>    
  <source path='xxx/web-project/client'/>
  <extend-property name="locale" values="es_ES"/>      
  <add-linker name="xsiframe"/>
  <set-configuration-property name="devModeRedirectEnabled" value="true"/>
  <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>    

</module>
jiakuan commented 3 years ago

Are you able to prepare a minimum test project to reproduce the issue? Then I will have a look on the weekend.

On Thu, 27 May 2021 at 6:50 pm, lluisgener @.***> wrote:

Yes, but if I remove it, it happens too, with the XXX.nocache.js file.

<?xml version="1.0" encoding="UTF-8"?>

< add-linker name="xsiframe"/>

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/jiakuan/gwt-gradle-plugin/issues/45#issuecomment-849533393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECF5BUPIAJHH73JHE7BK3TPYPWPANCNFSM45T66S6A .

lluisgener commented 3 years ago

Find attached a very minimal demo.

Launch with gradlew gwtSuperDev (I'm on Windows 10) and browse to http://127.0.0.1:8080/XXX/XXX.html.

"LOADED" should show in the page, and "LOADED IN CONSOLE" in the console.

Refresh with F5 and the error appears. I need to kill super dev and launch it again.

demo.zip

Thanks in advance.

jiakuan commented 3 years ago

@lluisgener It seems not a good idea to use the code server as the app web server directly. Normally we would run the code server separately from the app web server. That is, you can run you app web server from IDE, and run the code server from your Terminal (command line).

I tested your code last weekend. I saw the same errors if only the code server was running. But If I ran them separately, everything worked fine. I also changed the code structure slightly. Please see attached.

demo-v2.zip

lluisgener commented 3 years ago

Hi.

With the new structure, the main difference is that SuperDev binds to default port 9876 instead of 8080. Also, when launching the url that is suggested by the output of the gwtSuperDev task, the index.html is no where to be found (the plugin seems to publish the "public" folder, not the webapp one).

`2021-06-07 11:09:07.699:INFO:oejs.Server:main: jetty-9.2.14.v20151106 2021-06-07 11:09:07.732:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@7f9a2fc8{/,null,AVAILABLE} 2021-06-07 11:09:07.763:INFO:oejs.ServerConnector:main: Started ServerConnector@43cabf8d{HTTP/1.1}{127.0.0.1:9876} 2021-06-07 11:09:07.764:INFO:oejs.Server:main: Started @12409ms

The code server is ready at http://127.0.0.1:9876/`

image

When clicking the Dev Mode On button:

image

When clicking the XXX link (no index.html):

image

jiakuan commented 3 years ago

That’s how we should use the code server. Drag and drop the two compiling buttons to your browser’s bookmarks bar. Run the web server separately using IDE or any web server plugin like Jetty.

Please read this doc (http://www.gwtproject.org/articles/superdevmode.html) to understand how the superDevMode and bookmarklets work.

On Mon, 7 Jun 2021 at 5:15 pm, lluisgener @.***> wrote:

Hi.

With the new structure, the main difference is that SuperDev binds to default port 9876 instead of 8080. Also, when launching the url that is suggested by the output of the gwtSuperDev task, the index.html is no where to be found (the plugin seems to publish the "public" folder, not the webapp one.

`2021-06-07 11:09:07.699:INFO:oejs.Server:main: jetty-9.2.14.v20151106 2021-06-07 11:09:07.732:INFO:oejsh.ContextHandler:main: Started @.{/,null,AVAILABLE} 2021-06-07 11:09:07.763:INFO:oejs.ServerConnector:main: Started @.{HTTP/1.1}{127.0.0.1:9876} 2021-06-07 11:09:07.764:INFO:oejs.Server:main: Started @12409ms

The code server is ready at http://127.0.0.1:9876/`

[image: image] https://user-images.githubusercontent.com/22933112/120990975-730ef200-c781-11eb-9650-498f7a81777a.png

When clicking the GWT Modules button: [image: image] https://user-images.githubusercontent.com/22933112/120991039-81f5a480-c781-11eb-8377-74f02095181b.png

When clicking the XXX link: [image: image] https://user-images.githubusercontent.com/22933112/120991063-8c17a300-c781-11eb-9c5d-0369b4562b84.png

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/jiakuan/gwt-gradle-plugin/issues/45#issuecomment-855759235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECF5HCYXSL62EPH4E6V4TTRSE3DANCNFSM45T66S6A .

lluisgener commented 3 years ago

Ok, I've been able to make it work like you say with Gretty in gradle.... (I had to update the index.html to look for the nocache.js file on localhost:9876). But I must insist, on Eclipse you could run the app and just refresh and an AUTO-compile happened, there was no need to bookmark the button, use another webserver, and hit the DevModeOn button to make a compilation...

I looked at the source but I couldn't understand how the urls are being built, but if you could find where the "null" is appended and why, everything would be fixed.

jiakuan commented 3 years ago

Sorry I don’t use Eclipse. I guess it’s error-prone if we use the code server directly. It’s not its job to serve the content of the web app.

The plug-in code doesn’t contain any IDE code any more, so I couldn’t see anything to do with the plug-in code.

On Mon, 7 Jun 2021 at 6:00 pm, lluisgener @.***> wrote:

Ok, I've been able to make it work like you say with Gretty in gradle.... (I had to update the index.html to look for the nocache.js file on localhost:9876). But I must insist, on Eclipse you could run the app and just refresh and an AUTO-compile happened, there was no need to bookmark the button, use another webserver, and hit the DevModeOn button to make a compilation...

I looked at the source but I couldn't understand how the urls are being built, but if you could find where the "null" is appended and why, everything would be fixed.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/jiakuan/gwt-gradle-plugin/issues/45#issuecomment-855790490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECF5F24RERV4QM2XITJ6TTRSKDVANCNFSM45T66S6A .

lluisgener commented 3 years ago

It happens that finally I've been able to fix it.

In my html, due to some problems found long ago, I was loading the nocache.js file dynamically, appending a random date as a parameter to skip a cache hit:

<script type="text/javascript"> document.write("<"+"script src='XXX.nocache.js?today=" + new Date().getTime() + "'><"+"/script>"); </script>

If I replace this with a static script tag, the problem is gone:

<script type="text/javascript" language="javascript" src="XXX.nocache.js"></script>

Thanks anyway for your help.

jiakuan commented 3 years ago

Glad to see it’s fixed.

Normally we could also append timestamp on HTML server side rendering. Or, configure the Http response header with no-cache.

On Tue, 8 Jun 2021 at 1:27 am, lluisgener @.***> wrote:

It happens that finally I've been able to fix it.

In my html, due to some problems found long ago, I was loading the nocache.js file dynamically, appending a random date as a parameter to skip a cache hit:

If I replace this with a static script tag, the problem is gone:

<script type="text/javascript" language="javascript" src="XXX.nocache.js">

Thanks anyway for your help.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/jiakuan/gwt-gradle-plugin/issues/45#issuecomment-856122428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECF5HZB5PZVTVFO4EXGILTRT6RBANCNFSM45T66S6A .