It’s a common occurrence in the Java consulting world, as ridiculous as it is, I see it all the time. I do into a new development shop to help build a large webapp. Since it’s a large webapp, someone has decided they needed to buy licenses for Web* app server. And since they’re using the Web* app server for production, they decide to get developer licenses too. So, the development cycle looks like this:
Write some code, deploy to local Web* instance, wait 5 minutes for it to restart, and test.
Repeat.
The end result is that for every 2 minutes of coding, I wait 5 minutes for the local server instance to recycle. Now granted, many places have hot deploy set up, and many places do debugging. But the reality is for 80% of the enterprise web development going on today, local Web* instances are not needed, and not only are they not needed, they slow down development… a lot!
I’m on my third gig where I’ve come in and found this mode of development. And each time, I’ve been able to move the developers to a lightweight servlet container, Tomcat and/or Jetty. You can do all the things you’d do in the average development scenario, without the 5 minute wait.
Most recently, I’ve added the Jetty Plugin to a project managed by Maven. Here is the configuration I added to the pom.xml to use the plugin:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archiveClasses>false</archiveClasses>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<webResources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>js/ext-rtc.js</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<contextPath>/rtc-ui</contextPath>
<tmpDirectory>${project.build.directory}/tmp</tmpDirectory>
<webApp>${project.build.directory}/${project.artifactId}-${project.version}</webApp>
<webXml>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/web.xml</w
ebXml>
<stopPort>9980</stopPort>
<stopKey>rtc-ui</stopKey>
<systemProperties>
<systemProperty>
<name>rtc.env.runtime</name>
<value>dev</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
< ... />
<profile>
<id>js</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javascript-maven-plugin</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>extjs/**</exclude>
</excludes>
<descriptor>src/main/assemble/rtc-js.xml</descriptor>
<outputDirectory>${project.build.directory}/js</outputDirectory>
</configuration>
</execution>
<execution>
<id>war-package</id>
<goals>
<goal>war-package</goal>
</goals>
<configuration>
<includes>
<include>extjs/**</include>
</includes>
<scriptsDirectory>js</scriptsDirectory>
</configuration>
</execution>
</executions>
</plugin>
< ... />
<profile>
<id>js-compress</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javascript-maven-plugin</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
<extensions>true</extensions>
<executions>
<execution>
<id>compression</id>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<compressor>jsmin</compressor>
<optimizationLevel>9</optimizationLevel>
<scripts>js</scripts>
<webappDirectory>${project.build.directory}</webappDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
There are a few things going on here:
One, the project I’m working on is using extjs for the UI. There is a lot of javascript to copy around for deployment, so for conveince sake and performance, this project assembles all the javascript into one file. For production, it also compresses it. I’ve added that configuration in this example.
Because of the javascript configuration, I can’t just have the jetty plugin copy directly from a js directory, I have to make sure the js file is assembled and copy that one. This is accomplished using the -Pjs argument.
Secondly, notice the systemproperty element in the jetty configuration. env.rtc.runtime refers to which runtime properties file to use. It can be set to dev, prod, or qa, etc.
References:
This configuration guide is probably the most useful website.
This one has some useful info.
Eclipse debugging with this plugin
Post a Comment