0

I switched from the Google App Engine plugin to Google Cloud SDK plugin with Java app engine components.

Now when I run the server from Eclipse, it copies all the files for my web application into a temporary directory inside .metadata.plugins\org.eclipse.wst.server.core\tmp1

When I modify a JS file on the file system they are not automatically published to the temp1 folder, so when I refresh the browser, it loads the old version of the JS file.

With the old Google App Engine plugin I would modify a JS file and refresh the browser and it would instantly load the changes.

Is there some setting I need to modify to get it to work the way I want it to?

I found a file in workspace/Server/App Engine Standard at localhost.server. But I'm not sure what auto-publish-setting means.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<server auto-publish-setting="2" auto-publish-time="0" hostname="localhost" id="App Engine Standard at localhost" name="App Engine Standard at localhost" runtime-id="App Engine Standard Runtime" server-type="com.google.cloud.tools.eclipse.appengine.standard.server" server-type-id="com.google.cloud.tools.eclipse.appengine.standard.server" start-timeout="240" stop-timeout="240" timestamp="12">
  <list key="app-engine-server-modules-list" value0="org.eclipse.jst.jee.server:CodeAvengers"/>
  <list key="modules" value0="CodeAvengers::org.eclipse.jst.jee.server:CodeAvengers::jst.web::3.1"/>
</server>

Here are the settings for static files in appengine-web.xml

<static-files>
    <include path="/js/**" expiration="1s" />
    <include path="/i/**" expiration="1s" />
    <include path="/audio/**" expiration="1s" />
    <include path="/image/**" expiration="1s" />
    <include path="/images/**" expiration="1s" />
    <include path="/css/**" expiration="1s" />
    <include path="**.nocache.*" expiration="1s"/>
    <include path="/d-md/**" expiration="1s" />
    <include path="**" expiration="30d"/>

    <exclude path="/d/**" />
    <exclude path="/ca/**" />
    <exclude path="/files/**" />
</static-files>

With the old Google App Engine eclipse plugin, these settings worked totally fine.

I checked the temp1 folder and it seems the auto republishing is not working. When I modify a file in the source folder, those changes are not getting auto published.

Is there some setting somewhere else that is overriding the auto publish setting?

Victor M Perez
  • 2,185
  • 3
  • 19
  • 22
Mike
  • 3,855
  • 5
  • 30
  • 39

1 Answers1

1

The auto-publish-setting="2" is a Eclipse setting that you modify when you right click on the server and select 'open'. Go to the 'Publishing' category on the right. There are three options, each corresponds to a number. The number 2 corresponds to 'Automatically publish when resources change'. See image below:

enter image description here

If you want to see changes in the static files, you should set a low expiration attribute to the file in the appengine-web.xml. It would be something like:

<static-files>
  <include path="/**.png" expiration="4d 5h" />
</static-files>

In the example above you can use s for seconds. See the appengine-web.xml reference especially the <static-files> and the static cache expiration section, for a list of configuration options.

On the other hand, if you use a high expiration attribute, you won't see the changes immediately. As this section explains:

".. After a file is transmitted with a given expiration time, there is generally no way to clear it out of intermediate caches, even if the user clears their own browser cache. Re-deploying a new version of the app will not reset any caches..."

Victor M Perez
  • 2,185
  • 3
  • 19
  • 22
  • I've updated my question to show my settings for static files in app-engine.xml. These settings worked fine with the old "Google App Engine" plugin. – Mike Dec 13 '17 at 20:56
  • What is the situation now ? Did a combination of the Eclipse settitng + the expiration attribute work ? – Victor M Perez Dec 13 '17 at 21:04
  • Thanks for the response!! I already had both of those set. I just updated my answer. The problem seems to be that the auto publishing is not working. I am assuming it is supposed to copy over changes from my source folder into the temp1 directory. When I refresh my browser is loads the version from the temp1 folder. At once stage I did see an error message about difficulties copying over to the temp1 folder. I'll try restarting eclipse in admin mode and see if that fixes the auto publishing. – Mike Dec 13 '17 at 21:09
  • Try in **Window > Preferences > Server > Launching** see [this doc](https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.wst.server.ui.doc.user%2Ftopics%2Ftwsrtins.html) – Victor M Perez Dec 13 '17 at 21:23
  • I tried that... it is still not working. When I restart the server, all the changes get copied/published from the source directory into the temporary directory. But any changes made once the server is running, are not being auto published. – Mike Dec 14 '17 at 02:21
  • I tried creating a new blank app engine project, and the auto publishing worked ok with the new project. With my old project, it is not working. I might try creating a new project, and copy across all the old files, and see if that has any effect. – Mike Dec 14 '17 at 12:32
  • Ok. You can try on a file by file basis until you see when the problem appears. – Victor M Perez Dec 14 '17 at 12:50
  • OK. Have some more details now. I created a new app engine project in eclipse, then added a JS file. When I update the file in Eclipse the JS file is auto republished. When I update the JS file in a text editor outside of Eclipse, the auto publishing doesn't happen. – Mike Dec 14 '17 at 19:20
  • I found the solution: https://stackoverflow.com/questions/13470311/eclipse-refresh-files-edited-by-external-editor – Mike Dec 14 '17 at 20:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/161271/discussion-between-victor-herasme-perez-and-mike). – Victor M Perez Dec 15 '17 at 08:27
  • The refresh with native hooks option worked well with a small application but was still quite slow with my application which has a lot of files. It takes a few seconds to update. – Mike Jan 09 '18 at 22:34