Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Mavenizing SmartGWT and the nightly builds

    Isomorphic, I don't know if this is of any use to you, but I've spent some time mavenizing smartgwt and I'm willing to share the code for what I've done.

    My prime motivator was two-fold: a) we don't like distributing our J2EE projects with jar files embedded and we use maven2 throughout our organization, so it was a problem having this one set of applications that didn't fit the mold b) Some of the packaged dependencies that come with the smartgwt.zip archive are actually quite old and I wanted to update them to fix some problems in those libraries.

    Essentially, what I've done is taken the standard SmartGWT zip archive; extracted the jar files created by Isomorphic; figured out what the transient dependencies are for those jars and for each of the 12 jars created a POM file; which could be uploaded along with the jar into a standard Maven2 repository (we use Artifactory;but other repo's should work as well); so that a project needing SmartGWT could declare those artifacts as dependencies.

    In addition, because we do seem to rely quite a bit on the nightly builds to fix urgent problems; I've also written an Ant script which can download a nightly build; extract the appropriate jar files; attach correctly formatted POM files for each jar and then upload all those into a repository.

    These nightly builds get pushed into the maven repo with a version similar to: "2.3-NIGHTLY-2010-11-21".

    It would theoretically be feasible to automate scheduling the script to run on a daily basis so that a developer or organization can essentially have a repository of artifacts that represent the nightly build

    I've tested the script both with the eval EE version and the licensed pro version (a version for which we have purchased a license) and it works fine for both. In the case of the eval version the script can do the actual download because its publicly available; in the case of the license Pro version, you need to manually download the zip archive and tell ant where it is (through a properties file) but this is fairly trivial.

    For the other versions (Licensed PowerEdition and EE) I can't test because I don't have a license for this. However, it shouldn't be very difficult for someone that does have a valid license for those versions to modify the ant script and get it to work for them.

    I'm willing to share what I've done with Isomorphic (the company :) and the community, if you thinks it's useful and can vet the approach. Personally, I haven't had any problems with developing SmartGWT this way - I am using newer versions of Hibernate and Spring than what's packaged with the standard SmartGWT distribution, for instance, but they seem to work fine for me.

    Anyway - if you're interested, let me know. We can figure out how to get the code to you.

    Cheers!

    #2
    We're definitely interested, we would like to make it easier for Maven aficionados (Maven mavens?) to work with SmartGWT.

    If the POM file and script are short enough to post, I'm sure a number of community members could benefit from them immediately, even before we've integrated them into our nightly build and release processes. If they're too long, email them and we'll put them somewhere public and provide links in this thread.

    Comment


      #3
      Great! I think the scripts and pom files would be a bit too long for forum post; but I can certainly email them. What email address should I send them to?

      Comment


        #4
        support@isomorphic.com will do. Thanks!

        Comment


          #5
          Ok, let me add a little bit of documentation and I'll get it to you within the next hour.

          Comment


            #6
            Sent! I added a READ_ME.txt as well, but don't hesitate to ask if something isn't clear.

            Comment


              #7
              Finally, let me include this as an example of what a POM file for one of our projects looks like:

              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
                <modelVersion>4.0.0</modelVersion>
                <groupId>com.mycompany</groupId>
                <artifactId>myapplication</artifactId>
                <packaging>war</packaging>
                <version>3.3.0</version>
                <name>My SmartGWT Application</name>
                 <properties>
                 
                 <org.springframework.version>3.0.0.RELEASE</org.springframework.version>
                 <com.isomorphic.smartgwt.version>2.3-NIGHTLY-2010-11-22</com.isomorphic.smartgwt.version>
                 <com.google.gwt.version>2.0.3</com.google.gwt.version>
                 
                </properties>
                
                <dependencies>
                
                  <!--  BEGIN Spring framework dependencies -->
                
              	  <!--
              	    Core utilities used by other modules.
              	    Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-core</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Expression Language (depends on spring-core)
              	    Define this if you use Spring Expression APIs (org.springframework.expression.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-expression</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Bean Factory and JavaBeans utilities (depends on spring-core)
              	    Define this if you use Spring Bean APIs (org.springframework.beans.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-beans</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans)
              	    Define this if you use Spring AOP APIs (org.springframework.aop.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-aop</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans)
              	    This is the central artifact for Spring's Dependency Injection Container and is generally always defined
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-context</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration
              	    Define this if you need any of these integrations
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-context-support</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context)
              	    Define this if you use Spring Transactions or DAO Exception Hierarchy
              	    (org.springframework.transaction.*/org.springframework.dao.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-tx</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx)
              	    Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-jdbc</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis.
              	    (depends on spring-core, spring-beans, spring-context, spring-tx)
              	    Define this if you need ORM (org.springframework.orm.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-orm</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans.
              	    (depends on spring-core, spring-beans, spring-context)
              	    Define this if you need OXM (org.springframework.oxm.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-oxm</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Web application development utilities applicable to both Servlet and Portlet Environments
              	    (depends on spring-core, spring-beans, spring-context)
              	    Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-web</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	  
              	  
              	  <!--
              	    Spring MVC for Servlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
              	    Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-webmvc</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              	
              	<!--
              	    Spring MVC for Portlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
              	    Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*)
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-webmvc-portlet</artifactId>
              	  <version>${org.springframework.version}</version>
              	</dependency>
              
              	<!--
              	    Support for testing Spring applications with tools such as JUnit and TestNG
              	    This artifact is generally always defined with a 'test' scope for the integration testing framework and unit testing stubs
              	-->
              	<dependency>
              	  <groupId>org.springframework</groupId>
              	  <artifactId>spring-test</artifactId>
              	  <version>${org.springframework.version}</version>
              	  <scope>test</scope>
              	</dependency>
              	
              	<dependency>
              		<groupId>org.springframework</groupId>
              		<artifactId>spring-aspects</artifactId>
              		<version>${org.springframework.version}</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
                
                <!--  END Springframework DEPENDENCIES -->
                
                <!--  BEGIN GWT dependencies -->
                
              	<dependency>
              		<groupId>com.google.code.gwt-log</groupId>
              		<artifactId>gwt-log</artifactId>
              		<version>2.6.2</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              	<dependency>
              		<groupId>com.google.gwt</groupId>
              		<artifactId>gwt-servlet</artifactId>
              		<version>${com.google.gwt.version}</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              	 <dependency>
              	    <groupId>com.google.gwt</groupId>
                  	<artifactId>gwt-user</artifactId>
                  	<version>${com.google.gwt.version}</version>
                  <scope>provided</scope>
                </dependency>
              
              <!--  END GWT Dependencies -->
              
              <!-- BEGIN SmartGWT Dependencies -->
              
              	<dependency>
              		<groupId>com.smartgwt</groupId>
              		<artifactId>isomorphic_core_rpc</artifactId>
              		<version>${com.isomorphic.smartgwt.version}</version>
              	</dependency>
              	<dependency>
              		<groupId>com.smartgwt</groupId>
              		<artifactId>isomorphic_spring</artifactId>
              		<version>${com.isomorphic.smartgwt.version}</version>
              	</dependency>
              	<dependency>
              		<groupId>com.smartgwt</groupId>
              		<artifactId>isomorphic_assembly</artifactId>
              		<version>${com.isomorphic.smartgwt.version}</version>
              	</dependency>
              	<dependency>
              		<groupId>com.smartgwt</groupId>
              		<artifactId>smartgwt</artifactId>
              		<version>${com.isomorphic.smartgwt.version}</version>
              	</dependency>
              	<dependency>
              		<groupId>com.smartgwt</groupId>
              		<artifactId>smartgwtpro</artifactId>
              		<version>${com.isomorphic.smartgwt.version}</version>
              	</dependency>
              <!--  END SmartGWT Dependencies  -->
                
              <!--  BEGIN Hibernate Dependencies -->
              
              	<dependency>
              		<groupId>org.hibernate</groupId>
              		<artifactId>hibernate</artifactId>
              		<version>3.2.7.ga</version>
              		<type>jar</type>
              	</dependency>
              	<dependency>
              		<groupId>org.hibernate</groupId>
              		<artifactId>hibernate-annotations</artifactId>
              		<version>3.4.0.GA</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              
              <!--  END Hibernate Dependencies -->
              
              	<!-- BEGING miscellaneous dependencies -->
              	
              	<dependency>
              		<groupId>org.apache.velocity</groupId>
              		<artifactId>velocity</artifactId>
              		<version>1.6.4</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              	<dependency>
              		<groupId>javassist</groupId>
              		<artifactId>javassist</artifactId>
              		<version>3.8.0.GA</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              	
              	
              	<dependency>
              		<groupId>org.testng</groupId>
              		<artifactId>testng</artifactId>
              		<version>5.11</version>
              		<type>jar</type>
              		<classifier>jdk15</classifier>
              		<scope>test</scope>
              	</dependency>
              	
              	<dependency>
              		<groupId>org.aspectj</groupId>
              		<artifactId>aspectjtools</artifactId>
              		<version>1.6.8</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              	<dependency>
              		<groupId>javax.mail</groupId>
              		<artifactId>mail</artifactId>
              		<version>1.4.1</version>
              		<type>jar</type>
              		<scope>provided</scope>
              	</dependency>
              	
                	<dependency>
              		<groupId>log4j</groupId>
              		<artifactId>log4j</artifactId>
              		<version>1.2.15</version>
              		<type>jar</type>
              		<scope>compile</scope>
              		<exclusions>
              			<exclusion>
              				<artifactId>mail</artifactId>
              				<groupId>javax.mail</groupId>
              			</exclusion>
              		</exclusions>
              	</dependency>
              	<dependency>
              		<groupId>org.slf4j</groupId>
              		<artifactId>slf4j-api</artifactId>
              		<version>1.5.11</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>
              	<dependency>
              		<groupId>org.slf4j</groupId>
              		<artifactId>slf4j-log4j12</artifactId>
              		<version>1.5.11</version>
              		<type>jar</type>
              		<scope>compile</scope>
              	</dependency>										
                
                  <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>3.8.1</version>
                    <scope>test</scope>
                  </dependency>
                  
                  <dependency>
                  	<groupId>mysql</groupId>
                  	<artifactId>mysql-connector-java</artifactId>
                  	<version>5.1.13</version>
                  	<scope>test</scope>
                  </dependency>
                  
                  <dependency>
              	<groupId>org.apache.velocity</groupId>
              	<artifactId>velocity-tools</artifactId>
              	<version>2.0</version>
              	<type>jar</type>
              	<scope>compile</scope>
                   </dependency>
              	<dependency>
              		<groupId>javax.annotation</groupId>
              		<artifactId>jsr250-api</artifactId>
              		<version>1.0</version>
              		<scope>test</scope>
              	</dependency>
                  
                  <!--  END Miscellaneous dependencies -->
                  
              	
                </dependencies>
                
                
                
                <build>
                  <finalName>myapplication</finalName>
                  <plugins>
                		<plugin>
                			<groupId>org.apache.maven.plugins</groupId>
                			<artifactId>maven-compiler-plugin</artifactId>
                			<configuration>
                				<source>1.5</source>
                				<target>1.5</target>
                			</configuration>
                		</plugin>
                		<plugin>
              	        <groupId>org.codehaus.mojo</groupId>
              	        <artifactId>gwt-maven-plugin</artifactId>
              	        <version>1.2</version>
              	        <executions>
              	            <execution>
              	            	<configuration>
              	            		<module>com.mycompany.MyApplication</module>
              	            	</configuration>
              	                <goals>
              	                     <goal>compile</goal>
              	                </goals>
              	            </execution>
              	        </executions>
                  	</plugin>
                  	<plugin>
              			<artifactId>maven-antrun-plugin</artifactId>
              			<executions>
              				<execution>
              					<id>env-prepare-package</id>
              					<phase>prepare-package</phase>
              					<goals>
              						<goal>run</goal>
              					</goals>
              					<configuration>
              						<tasks>
              						<copy todir="${project.build.outputDirectory}" overwrite="true" verbose="true">
              							<fileset dir="src/env-overrides/${environment}/resources">
              								<include name="**/*"/>
              							</fileset>
              						</copy>
              						<copy todir="${project.build.outputDirectory}/com/mycompany/myapp" overwrite="true" verbose="true">
              							<fileset dir="src/main/java/com/mycompany/myapp">
              								<include name="*.xml"/>
              							</fileset>	
              						</copy>
              						<copy todir="${project.build.outputDirectory}/com/mycompany/myapp/client" overwrite="true" verbose="true">
              							<fileset dir="src/main/java/com/mycompany/myapp/client">
              								<include name="**/*.java"/>
              							</fileset>
              						</copy>
              						</tasks>
              					</configuration>
              				</execution>
              			</executions>
              		</plugin>
              		<plugin>
              		 <groupId>org.apache.maven.plugins</groupId>
              	       <artifactId>maven-war-plugin</artifactId>
              	       <version>2.1-beta-1</version>
              	       <configuration>
              	         <webResources>
              	           <resource>
              	             <!-- this is relative to the pom.xml directory -->
              	             <directory>src/env-overrides/${environment}/webapp</directory>
              	           </resource>
              	         </webResources>
              	       </configuration>
              	    </plugin>
              	    <plugin>
              	    	<groupId>org.codehaus.mojo</groupId>
              	    	<artifactId>tomcat-maven-plugin</artifactId>
              	    	<version>1.0</version>
              	    	<configuration>
              	    		<server>local-tomcat</server>
              	    		<path>/myapplicationpath</path>
              	    	</configuration>
              	    </plugin>
                	</plugins>
                </build>
                
                 <distributionManagement>
              	  <repository>
              		  <id>mycompanyrepo</id>
              		  <name>mycompanyrepo-releases</name>
              		  <url>http://www.mycompany.com/artifactory/releases</url>
              	  </repository>
              	  <snapshotRepository>
              		  <id>mycompanyrepo</id>
              		  <name>mycompanyrepo-releases</name>
              		  <url>http://www.mycompany.com/artifactory/snapshots</url>
              	  </snapshotRepository>
                </distributionManagement>
              
              </project>
              This POM assumes that the nightly build has been mavenized with the ant script; you can see where the SmartGWT dependencies are declared in the dependencies section.

              The project is built the standard maven way (i.e. "mvn package") and installed to tomcat using the maven tomcat plugin ("mvn tomcat:deploy").

              I did end up creating a maven archetype that automatically sets up a new "SmartGWT project"; i.e. it puts the server.properties and the log4j.isc.config.xml in the right locations, creates an MyApplication.html file with the right SC initialization code in it, creates a web.xml that has all the servlets and mappings defined and so forth. However, it also ended up containing quite a bit of company-specific code (we have some base libraries all our projects include) so I'm a bit more hesitant in sharing that.
              Last edited by SiccoNaets; 22 Nov 2010, 14:56.

              Comment


                #8
                For anyone who needs them, here are the files provided by SiccoNaets, as-is. They have not yet been integrated into the SmartGWT build process. If you have improvements to these files you'd like to share, please post about them here.

                Comment


                  #9
                  I have mavenized the SmartGWT EE (evaluation edition) server side libraries (isomorphic*.jar) to be able to include it to any maven project. And I have also created an archetype using a simple Spring driven Data Source, JPA2 and the in-memory HyperSQL. So for ones preferring the Maven there is a way how you can see the running application example very fast. I did not spend much time by testing all this, so there might be some missing dependency. I hope it will be helpful and I'm looking forward for your feedback.

                  Cheers, Martin

                  Mavenization of a SmartGWT EE project

                  Comment


                    #10
                    Originally posted by Isomorphic
                    For anyone who needs them, here are the files provided by SiccoNaets, as-is. They have not yet been integrated into the SmartGWT build process. If you have improvements to these files you'd like to share, please post about them here.
                    This was a great start, but I have had a handful of problems with it. Do you still want updates via email? Any plans to include this or something like it with the distribution?

                    Comment


                      #11
                      If you'd like to suggest improvements, this thread is probably the best place (to get more contributors as well).

                      Comment

                      Working...
                      X