- Create a own profile - this allows more flexibility
<profile> <id>jetty-run</id> </profile>
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> <webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory> <scanIntervalSeconds>2</scanIntervalSeconds> <scanTargets> <scanTarget>src/main/java</scanTarget> </scanTargets> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
<properties> <maven.test.skip>true</maven.test.skip> </properties>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <executions> <execution> <id>default-war</id> <phase>none</phase> </execution> </executions> </plugin>
- Skip optimzation (we use the primefaces-extensions plugin for this)
<plugin> <groupId>org.primefaces.extensions</groupId> <artifactId>resources-optimizer-maven-plugin</artifactId> <executions> <execution> <id>optimize</id> <phase>none</phase> </execution> </executions> </plugin>
@Override protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final OutputStream ouputStream = response.getOutputStream(); response.setContentType(getServletConfig().getInitParameter("contentType"); final List<File> filesToMerge = getFiles(getServletContext().getRealPath(getServletConfig().getInitParameter("includeDirectory"))); for (final File fileToMerge : filesToMerge) { final FileInputStream inputStream = new FileInputStream(fileToMerge); IOUtils.copy(inputStream, ouputStream); inputStream.close(); } ouputStream.close(); }
We just create a second web.xml (this is just for localhost and jetty) with the name "web-localhost.xml" in your "src/main/webapp/WEB-INF" directory with the following servlet mapping
<servlet> <servlet-name>Merge Javascript Servlet</servlet-name> <servlet-class>xxx.servlet.MergeResourceServlet</servlet-class> <init-param> <param-name>includeDirectory</param-name> <param-value>/javascript/</param-value> </init-param> <init-param> <param-name>contentType</param-name> <param-value>application/x-javascript</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Merge Javascript Servlet</servlet-name> <url-pattern>/javascript/bundle.js</url-pattern> </servlet-mapping>
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <configuration> <webAppConfig> <overrideDescriptor>src/main/webapp/WEB-INF/web-localhost.xml</overrideDescriptor> </webAppConfig> ... </configuration> </plugin>Finished! You will be able to start jetty now via "mvn package -P jetty-run".
HI Thomas,
ReplyDeleteI read your article it was very informative.I have tried a web dynamic project in tomcat7 + jsf2+ Prime faces 3.4. It works well. But i could not start a same application in WAS8. Can u please guide in starting web dynamic project with prime faces 3.4+ jsf2 and not from maven.
Hi,
ReplyDeletesorry, i never used WAS but might it be possible that you ship the JSF jars in your WAR file? This is not required on a AS because they already has a JSF implementation.
Sorry but i always maven :)
You're always mavening? What about debugging?
ReplyDeleteAs for the question (although the answer's probably very late): Try http://examples.javacodegeeks.com/enterprise-java/jsf-2-0-eclipse-ide-support/. And chances are http://www.beyondjava.net will dedicate an article to the topic soon :).
Debugging is quite easy via "mvnDebug" instead "mvn" ;)
ReplyDelete
ReplyDeletethank u for sharing this postthank u for sharing this postcustom web application development
ReplyDeleteGood contentcustomized purchase software
Thank for the information, Such a good content.
ReplyDeleteSearching for Software Devlopment Company? 3sstudio is Considered as the most well-established Software Devlopment Company in Delhi offers you an entire range of Devlopment services as far as erp & Crm Devlopment, with more than 1000+ satisfied clients.
contact us on :+91 9811241103