Access Keys:
Skip to content (Access Key - 0)
 
Toggle Sidebar

Maven for Newbies

Added by Nathan Anderson, last edited by Duncan Jauncey on Jul 10, 2007 06:04

(None)

This page is intended to be a place to document my impressions about Maven and AppFuse 2.x as I take my AppFuse 1.9.x experience and move forward into the future of webapp development.

Now for a bit of background about me. I'm the Development Supervisor for Sum-Ware, Inc., which basically means I make sure the other developer and network admin have something to do and I have to get done the stuff that's left.

I'm taking a two pronged approach to learning AppFuse 2.x. At work I have a Windows desktop running Sun Java 1.6 and Eclipse 3.2. The project I'm starting at work uses the "appfuse-basic-struts" archtype. At home I'm doing a different project on my Ubuntu laptop with Sun Java 1.6 and Eclipse 3.2 (I may switch to IDEA on this project--dunno yet). This project is built on the "appfuse-modular-struts" archtype.

I'm sticking with Struts 2 (at least for now) for simplicity and my own sanity. I'd like to limit the number of variables as much as I can during this learning process.


Targets v. Goals

  • The first thing that I noticed is the maven "goals" are similar, but different than ant "targets." Goals are cool because they are universal and apply to all maven projects, but targets are a bit easier to figure out because they exist entirely within your build.xml file (more or less). The Maven 2 page has a good list of commonly used goals and what they are for.
  • I must say even if it is not obvious how to use Maven in the beginning I must say it is pretty easy to get started with it. Once the prerequisites were installed (none of which were hard to do), I had AppFuse running within 10 minutes. And most of that time was spent letting maven fetch dependencies.

IDE integration

  • Eclipse integration is pretty nice. But I did have a couple of weird things happen.
    • When creating my POJO I had to clean the project a couple of times to get the Eclipse to recognize the annotations
    • I ran the command to create the M2_REPO stuff in my project. That did work, I could see all the dependant JAR's listed in the project, but it didn't fix the annotation problem mentioned above.
    • I had to add the M2_REPO variable to the environment as well. After that things went pretty smooth.
  • I have not used IDEA with AppFuse 2.x yet, but I hear it is better than Eclipse.

Dependency downloads

  • This is really cool and a bit weird at the same time. I have gotten a number of Warning and Error messages while maven is downloading dependencies. But the really weird part is stuff seems to still work. Check out this output for example:
    [INFO] Wrote settings to /home/nathan/src/fetch-calendar/web/.settings/org.eclipse.jdt.core.prefs
    [INFO] Wrote Eclipse project for "fetch-calendar-webapp" to /home/nathan/src/fetch-calendar/web.
    [INFO] 
           Sources for some artifacts are not available.
           List of artifacts without a source archive:
             o org.apache.struts:struts2-core:2.0.6
             o commons-fileupload:commons-fileupload:1.1.1
             o opensymphony:clickstream:1.0.2
             o org.apache.struts:struts2-spring-plugin:2.0.6
             o velocity-tools:velocity-tools-view:1.0
             o javax.servlet:jsp-api:2.0
             o org.apache.struts:struts2-codebehind-plugin:2.0.6
             o freemarker:freemarker:2.3.8
             o org.tuckey:urlrewrite:2.5.2
    
    [INFO] 
    [INFO] 
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] ------------------------------------------------------------------------
    [INFO] AppFuse Modular Application ........................... SUCCESS [6.338s]
    [INFO] AppFuse Modular Application - Core .................... SUCCESS [57.907s]
    [INFO] AppFuse Modular Application - Web (Struts 2) .......... SUCCESS [2:20.721s]
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESSFUL
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3 minutes 27 seconds
    [INFO] Finished at: Tue Apr 03 22:05:12 PDT 2007
    [INFO] Final Memory: 48M/63M
    [INFO] ------------------------------------------------------------------------

    How can struts2-core fail to download, yet I can run "mvn jetty:run-war" perfectly? I have no idea... :?
    Okay... I'm dumb. I just realized it can't get the source packages, but the binaries ware downloaded just fine. Maybe someone else will read this and avoid public humiliation

Hello World

I'm sure there is a reason for the App.java and AppTest.java (and Core.java for modular archtypes) classes that get created when you make a new project. I just have no idea what that is. Maybe someone could link to an answer?

Maven and HTTP proxy settings

If your local network is behind a HTTP proxy (note that this is different from a Maven repository proxy) you will see something like 'Error transferring file'. Find out the hostname and port of your proxy and add the following to your command-line: -DproxySet=true -DproxyHost=<your proxy host> -DproxyPort=<your proxy port>

Note: if you've tried and failed a few times, the central repository may have become blacklisted. Add the -U command line option to force an update.

Adaptavist Theme Builder (3.1.4) Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.7 Build:#813 Aug 28, 2007)
Free theme builder license