AppFuse -> Maven2
[ topping ] 21:40, Friday, 3 February 2006

I recently started some work with a young company that was using AppFuse. Ant isn't my cup of tea, and this entry makes an attempt to document many of the issues I came to confront.

When I started with these folks, their code looks very manageable. AppFuse provides a strong set of patterns to build an application by, and the gentleman that developed this particular app did so with the Spring/Struts combination. He already had substantial unit tests complete, and it should have been simple to port to Maven. I've done this kind of thing before and I estimated two days to get it working under Maven 1.x.

So I promptly decided to use Maven 2. And XDoclet 2 for good measure.

Well, a couple weeks later, I'm glad I did, because I have a mostly functioning build with Maven 2. I ended up having to use XDoclet 1 because X2 templates were a) not complete and b) sometimes had different tag names. I've used XDoclet 2 extensively in the past, but with Dentaku in an environment with UML profiles that were generated for a descriptor output (via the DTD). In that case, you can visually remember what tag you need and select it from the choices, but that doesn't work if you are typing them from memory. They should be the same as the XML that is generated (like X1).

Then there was the problem of getting either XDoclet to run under M2. This is about where I started learning how to develop MOJOs. MOJOs are plugins for Maven2. They are written in Java, and they are fast! Maven2 is really really fast as a result. You'll like it!

Matt's done a really fine job of integrating a lot of technologies into the build process of AppFuse, so most of the work you'll invest in getting your project ported will be for getting these plugins configured. The Mojo project at Codehaus has a growing selection of contributed plugins for M2, and in the course of this port I contributed development versions of a rip of the SQL task for Ant, as well as a new DBUnit plugin. These two, plus the existing X1 plugin, will get you most of the way you need.

When I set up the project layout, I did so as a master project that had three subprojects. The three subprojects were model, service and web. If you are familiar with AppFuse, the components that will go into each should be fairly obvious. The nice thing with M2 is you simply add the top-level dependency, not the transitive dependencies. All those should be brought in by default.

On the subject of dependencies, you'll find that there are several that are not in the Maven central repository. Some of these are missing because they are JARs from sekrit deeth star projects at the Sun mother ship. (Oh wait, these are common system JARs with a paranoid license, never mind...) You'll need to read up on how to add those dependencies manually to your repo.

The next tricky part is getting the Spring configurations distributed. You want to make sure that the Spring config files are located on the classpath of each JAR that is generated, then adjust the configuration loader wildcards to match the location you put the configs on the classpath. For instance, if you put all the Spring configs in META-INF, they will be visible from any of the other JARs. Note that in some cases (like tests), you want to override some of the beans, so make sure your tests load those test configurations last. I did this by putting the test configuration on a different path, then added that file as a specific load in the configuration loader setup string.

The beefy part is in the pom.xml that was generated. Most are pretty similar, and you'll have to add the dependencies by hand. This POM is *almost* complete, but I need to get Canoe web test integrated as well as get variable substitution (filtering) for resources implemented. I've attached that to the end of this post. This one is from the web subproject.

Once you get stable project, working in M2 is a dream. It's so fast. The IDEA plugin works like a champ. I haven't been able to figure out how to set the name of my preferred JDK in settings.xml so that the IDEA plugin generates perfect project files, and I believe subprojects of the same master build should have project dependencies instead of JAR file dependencies, but for small projects these are minor details.

If there's enough demand, I can post the stripped-down m2 directory structure (with POMs), but with all the client's meaty bits removed.

Have fun!


    4.0.0
    com.seabridgeinc.portal
    topspin-web
    war
    1.0-SNAPSHOT
    Topspin Web
    http://maven.apache.org
    
        
            displaytag
            displaytag
            http://displaytag.sourceforge.net/m2repo/
        
    
    
        
            com.seabridgeinc.portal
            topspin-model
            1.0-SNAPSHOT
        
        
            com.seabridgeinc.portal
            topspin-service
            1.0-SNAPSHOT
        
        
            junit
            junit
            3.8.1
            test
        
        
            strutstestcase
            strutstestcase
            2.1.2-1.1-2.3
            test
        
        
            springframework
            spring-web
            1.2.6
            test
        
        
            dumbster
            dumbster
            1.6
            test
        
        
            springframework
            spring-mock
            1.2.6
        
        
            struts
            struts
            1.2.8
        
        
            struts
            struts-html-el
            1.2.8
            tld
        
        
            struts
            struts-logic-el
            1.2.8
            tld
        
        
            struts
            struts-bean-el
            1.2.8
            tld
        
        
            struts
            struts-el
            1.2.8
        
        
            javax.servlet
            servlet-api
            2.3
            provided
        
        
            javax.servlet
            jstl
            1.0
        
        
            javax.servlet
            jsp-api
            2.0
            provided
        
        
            javax.activation
            activation
            1.0.2
        
        
            displaytag
            displaytag
            1.1-SNAPSHOT
        
        
            displaytag
            displaytag-export-poi
            1.1-SNAPSHOT
        
        
            clickstream
            clickstream
            1.0.3
        
        
            struts-menu
            struts-menu
            2.3
        
        
            sitemesh
            sitemesh
            2.2.1
        
        
            oscache
            oscache
            2.2
        
        
            urlrewrite
            urlrewrite
            2.6.0
        
    
    
        topspin-web
        
            
                org.codehaus.mojo
                xdoclet-maven-plugin
                
                    
                        generate-sources
                        
                            xdoclet
                        
                        
                            ${project.build.directory}/generated-sources/java
                            
                                
                                    



substituteWith="webapp.form"/>


force="false"
mergedir="src/merge"
excludedtags="@version,@author"
verbose="true">







servletspec="2.3" sessiontimeout="10"
destdir="target/topspin-web/WEB-INF" distributable="false"
displayname="topspin">




description="Custom tag library for this application"
shortName="lakers" filename="lakers.tld" />









javax.servlet
jsp-api
2.0


struts
struts
1.2.8
runtime


ant
ant
1.6.5
runtime


velocity
velocity
1.4
runtime











TrackBack
Comments

F*** an A dude - you rock! M2 integration for AppFuse is one of the primary objectives for 2.0. I'm *very* interested in the work you've done!

--Matt Raible, February 3, 2006 10:38 PM

Really? Nice!

Let me in there and I'll take care of it for ya!! :-)

--Brian Topping, February 4, 2006 08:54 AM

This rocks!

Hardly can wait for the release of Appfuse 2.0!!

--Mark Johansson, February 7, 2006 08:32 PM

Is there any progress of publishing this pom.xml

--SKF, March 22, 2006 12:16 AM

I was initially pretty gung-ho about helping make the port happen, but I had limited time and it took some effort to get a repository set up where things could be worked out of. I had http://appmuse.codehaus.org set up when there was some confusion about where to set up, let's work out of there. Please subscribe to the lists and post!

--Brian Topping, March 22, 2006 09:13 AM

I would be very interested in being kept abreast of your progress with this project.

Best Regards,

John Boyd

--John Boyd, April 5, 2006 02:02 AM
Post a comment









Remember personal info?