Using Maven With geWorkbench Web

From Informatics

Jump to: navigation, search

This is the instruction of setting up maven project with geWorkbench web application in both command line and eclipse.

Pre-Requirements

1. Install maven for command line(http://maven.apache.org/download.cgi)

2. Install Maven Integration for Eclipse (http://marketplace.eclipse.org/content/maven-integration-eclipse-juno-and-newer)

Eclipse With Maven

1. Start eclipse and check out the maven project from https://github.com/geworkbench-group/geworkbench-web (If it is the first time to clone the repository, from eclipe menu, choose Import -> Git -> Projects from Git -> Clone URI. Do NOT choose to create a new maven project.)

WARN: you may see an alarming error message caused by m2e plugin when you first set up your workspace for geworkbench web. It is generally safe to use eclipse "Quick Fix" to ignore it. For the detail, see http://wiki.eclipse.org/M2E_plugin_execution_not_covered

2. Right click on project name, choose "Run as -> Maven build ...", you can enter value "compile", or "package", or "test", or "jetty:run", or other build Lifecycle for "Goals".

   * compile - compile the source code of the project
   * test - test the compiled source code using a suitable unit testing framework.  
   * package - take the compiled code and package it in its distributable format, such as a WAR.
   * jetty:run - the idea of the Jetty Runner is extremely simple–run a webapp from eclipes, 
                 then you can try http://localhost:8080/geworkbench/

How to change the port number of the jetty server (in maven): open the run configurations dialog for the configuration of jetty:run goal, click on "Add" button to add parameter name "jetty.port" with value of the new port number, say, 9999. This is equivalent to command line option like mvn -Djetty.port=9999 jetty:run. See http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html

3. How to deploy geWorkbench.war from eclipse to tomcat 7:

    1) first, add an user with administrator access right for Tomcat. To add Tomcat user, 
      edit this file – “%TOMCAT_PATH%/conf/tomcat-users.xml“.         
         <tomcat-users>
         <role rolename="manager-gui"/>
         <role rolename="admin"/>
         <user username="username" password="password" roles="admin,manager-gui"/>
         </tomcat-users> 
     2) in maven side, you need to add the same user authentication and profiles information in 
        C:/Users/${username}/.m2/settings.xml. 
        <servers>
            <server>
                <id>LocalTomcatServer</id>
                <username>username</username>
                <password>password</password>
            </server>
            <server>
               <id>TestTomcatServer</id>
               <username>username</username>
               <password>password</password>
            </server>
         </servers>
         <profiles>
            <profile>
               <id>env-dev</id>
               <activation>
                   <property>
                   <name>env</name>
                   <value>dev</value>
                   </property>
               </activation>
               <properties>
                  <tomcatUrl>http://localhost:8080/manager/html</tomcatUrl>
                  <serverName>LocalTomcatServer</serverName>
               </properties>
            </profile>
         <profile>
            <id>env-test</id>
            <activation>
               <property>
                  <name>env</name>
                  <value>test</value>
               </property>
            </activation>
            <properties>
               <tomcatUrl>http://afdev.c2b2.columbia.edu:8082/manager/html</tomcatUrl>
               <serverName>TestTomcatServer</serverName>
            </properties>
         </profile>   
      </profiles>
   3) Declare “Maven-Tomcat plugin” and related Tomcat server detail in the pom.xml file. 
      <plugin>
         <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
            <url>${tomcatUrl}</url>
            <server>${serverName}</server>
            </configuration>
      </plugin>
   4) Right click on project name, choose "Run as -> Maven build ...", you can enter value
      "tomcat7:deploy -Denv=dev" to deploy geWorkbench.war to your local tomcat. 
   5) Right click on project name, choose "Run as -> Maven build ...", you can enter value
      "tomcat7:deploy -Denv=test" to deploy geWorkbench.war to http://afdev.c2b2.columbia.edu:8082
      Remember to change the database configuration in persistence.xml. 

PLEASE NOTE:

      * When compiling the widget set you can disregard the "ERROR" labels, 
        they are just an issue with the Vaadin Plugin for Maven. 
      * When you checkout pom.xml, eclipse may complain that "Plugin execution not covered". Please
        use quick fix to create "ignore" mapping. The issue will be resolved in vaadin 7 plugin.  
      * The tomcat installation to use: /ifs/data/c2b2/af_lab/cagrid/apache-tomcat-7.0.30, a tomcat 
        user is already added to tomcat-user.xml.
      * Make sure the target tomcat server is running prior to deploying the maven project.

Command Line Maven

1. Check out the maven project from https://github.com/geworkbench-group/geworkbench-web

2. need to add the same user authentication and profiles information in “%MAVEN_PATH%/conf/settings.xml“.

3. "mvn clean" : clean the target directory.

4. "mvn compile" : compile the source code of the project

5. "mvn package" : take the compiled code and package it in its distributable format, such as a WAR.

6. "mvn test" : test the compiled source code using a suitable unit testing framework.

7. "mvn tomcat7:deploy -Denv=dev" : deploy geWorkbench.war to your local tomcat

8. "mvn tomcat7:deploy -Denv=test" : deploy geWorkbench.war to your test server http://afdev.c2b2.columbia.edu:8082

Personal tools