1. Karlos Kleiza
  2. fetcher-maven-plugin


# Welcome I wrote a lightweight maven-plugin, cause I get rid of the long up-time of the google app engine instances. This plugin is especially useful, when you don't want to miss spring MVC, Django, or similar MVC frameworks for template rendering and business logic, but have many mainly static html files. # Workflow The plugin 1. reads the sitemap.xml, 2. rewrites the urls to localhost, 3. fetched the htmls 4. and writes it into the target directory ready for packaging. It brings a huge benefit, when using in combination with spring + google app engine (GAE), cause so your app can delivery static content hyper fast, without loosing the flexibility of spring (e.g. for post requests). GAE don't have the typical delay of about 10-20 secs, when just delivering static content (even with springs DispatcherServlet included). Dispatchers are loaded lazily by default, so the delay occurs, then the user requests the non static fetched content for the first time. Off course you can add an ajax request to warmup the instances asynchronously for reasons of precaution. Its recommended to use client-site-MVC to personalize and/or customize the static html content. # Integration - clone repository and install the plugin into your local repository (as long a I didn't pushed it into repo) ``` #! git clone https://bitbucket.org/kkleiza/fetcher-maven-plugin.git cd fetcher-maven-plugin mvn install ``` - add plugin to your project. e.g.: ``` #! <plugin> <groupId>de.kleiza</groupId> <artifactId>fetcher-maven-plugin</artifactId> <version>1.0-SNAPSHOT</version> <executions> <execution> <id>createDirs</id> <goals><goal>prepare</goal></goals> <phase>prepare-package</phase> </execution> </executions> <configuration> <sitemap> sitemap.xml </sitemap> </configuration> </plugin> ``` - add the fetched-content dir to the maven-war-plugin as a resource dir. E.g.: ``` #!xml <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals><goal>war</goal></goals> <id>packageWithStaticContent</id> <configuration> <webResources> <resource> <directory>src/main/webapp</directory> <filtering>true</filtering> <includes> <include>**/appengine-web.xml</include> </includes> </resource> <resource> <directory>${project.build.directory}/fetched-content</directory> </resource> </webResources> </configuration> </execution> </executions> </plugin> ``` - deploy your app locally: ``` #! mvn gae:run ``` - execute the plugin asynchronously ( e.g. in another terminal): ``` #! mvn fetcher:fetch ``` - repackage your project, without clean (cause fetched content is stored now in the target dir): ``` #! mvn package or mvn gae:deploy ``` your *.war should be now packaged including the static htmls in the root dir. #Limitations 1. GAE delivers even static content for POST-request, so don't use same url for GET and POST together! 2. GAE derives the MIME-type of static content from the file name. So your url-mapping needs to end with .html, .htm, .xhtml,.... 3. Don't use url-rewriting for sessionId 3. you need a sitemap.xml ;) Have fun ;)