Is there a way to run Maven Appengine Devserver to automatically update static files?

The latest version of the maven plugin allowed code to be updated every 5 seconds, which is a big improvement. But, if I don't configure this incorrectly, it does not seem to pick up static file changes, such as working in a Javascript process that connects application code.
Is there a way to change this behavior or do I just need to wait for a new version?

+8
java google-app-engine maven
source share
3 answers

Automatic updates cannot be performed using only one additional devserver. Strictly speaking, we need to wait.

But you can achieve the effect of seamlessly updating html / js / css / etc, hot-swapping Java code, etc. with the configuration below.

  • Configure Apache httpd or Nginx to serve static code directly from your military source and route to the servlet application engine. In my case, all html is available directly from the webapp directory, and servlets are called via / sim /. Using the nginx port and 7070, my working nginx configuration looks like this:

    server { listen 7070; root /home/pchauhan/Projects/my-company/my-mvn-gae-project/my-mvn-gae-project-war/src/main/webapp; location /sim/ { proxy_pass http://localhost:8080/sim/; } } 

Use this nginx documentation for more configurations.

Configure Eclipse and GAE separately.

  • Now you can directly make changes to the source and update them both for html (via nginx) and for servlets (via devserver).
  • Add this webapp folder to your Chrome Dev tools, Workspace sources and life will be easier. Small changes can be saved directly from chrome to src via ctrl

Please note that although this is great, you should only test your application once on 8080 (devserver port) before downloading, just in case there is an error in the maven configuration and the target is not created / served correctly.

An alternative idea for synchronization . If you don't want to use nginx / httpd for any reason, you can add the target ... webapp to the Chrome workspace, work right there for a seamless update, and then use lsyncd to sync the target back to src. I haven't tried it yet, but it looks doable, albeit a bit risky.

+2
source share

So far, the best way I have found was setting below the entries in pom.xml. This will automatically create your static files and appear on the page.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>process-classes</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <property name="target.webapp.dir" value="${project.build.directory}/${project.build.finalName}" /> <property name="src.webapp.dir" value="${basedir}/src/main/webapp" /> <sync verbose="true" todir="${target.webapp.dir}" includeEmptyDirs="true"> <fileset dir="${src.webapp.dir}" /> <preserveintarget> <include name="WEB-INF/lib/**" /> <include name="WEB-INF/classes/**" /> <include name="WEB-INF/appengine-generated/**" /> </preserveintarget> </sync> <!-- <sync verbose="true" todir="${target.webapp.dir}/WEB-INF/classes"> <fileset dir="${basedir}/target/classes" /> </sync> --> </target> </configuration> </execution> </executions> </plugin> 

And one more post after

 <pluginManagement> <plugins> <!-- This plugin configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <versionRange>[1.6,)</versionRange> <goals> <goal>run</goal> </goals> </pluginExecutionFilter> <action> <execute> <runOnIncremental>true</runOnIncremental> </execute> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> 

It works great. As soon as all the static files were changed and saved, they got to the page.

+2
source share

Like the PoojaC20, I was also unable to get this work to work with devserver alone, but I got another workaround that I thought I would share if others find it useful.

Now I host my static development files outside of the GAE devserver using grunt-serve . This allows you to use a large number of advantages, including:

  • Automatic page refresh when static files change - you don’t even need to click the refresh button.
  • Automatically convert advanced CSS like LESS
  • Automatically convert javascript-compiled languages ​​like CoffeeScript
  • A mechanism for minimizing and CDN-ification in development.

The deepest consequence of the above is that I need to move away from authentication based on an authentication session based on OAuth or OpenID Connect authentication and make all my web service services compatible with CORS. This is some work, but it also has one very important advantage:

  • Once your web server has switched to OpenID Connect authentication, it can now connect identically to its native (for example, mobile) client or web clients!
0
source share

All Articles