Using Maven 2

Updated Information.

To build you should just need

mvn -Dmaven.test.skip=true -Dmaven.tomcat.home=/Users/ieb/Caret/sakai22/tomcat clean install sakai:deploy

Where:
    *maven.tomcat.home* is your tomcat home directory
    *clean* cleans the m2-target for each module prior to building
    *install* installs the output of each module into the repository 
    *sakai:deploy* deploys from the repository to the tomcat home

Other switches that might help
    -o makes mvn go offline, which after the first build eliminates all network traffic

Other targets
    *site:site* will build a complete maven site for the whole of sakai, but it takes a while
    *javadoc:javadoc* builds all the javadoc.

These settings can be saved to a configuration file that will be loaded each time you run mvn. This file is called settings.xml, and should be stored in your home directory under .m2/settings.xml. Here's a sample settings.xml file:

<settings 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/xsd/settings-1.0.0.xsd">
   <profiles>
      <profile>
         <id>sakai</id>
         <properties>
            <maven.tomcat.home>/java/tomcat/</maven.tomcat.home>
            <maven.test.skip>true</maven.test.skip>
         </properties>
      </profile>
   </profiles>
   <activeProfiles>
      <activeProfile>sakai</activeProfile>
   </activeProfiles>
</settings>

There is also documention at Building With Maven2

Ian Boston

I have just committed about 400 pom.xml files for maven 2 to trunk. If you have responsibility for one of the projects and have modified your project.xml since r19343 you may want to check the pom.xml file (which will appear if you do an update) is correct. I have checked the commits and cant find any mods, but I could have missed one.

Going forwards, you should maintain your own pom.xml files (which may help you learn maven 2, if you don't already know it)

Please note,
The m2 build will run in parallel to maven 1.

Only the projects listed in https://source.sakaiproject.org/svn/sakai/trunk/.externals have been ported

and

Although the build/deploy works I am not 100% certain that the packaging is correct and the more complex project structures probably still need some work (osp, gradebook, sections, samigo)

If you feel brave and want to build with maven 2, then the build operates separately in parallel with maven 1 (using m2-target and a separate repository)

You will need to set maven.tomcat.home in a settings.xml file (see above) and run

mvn -Dmaven.test.skip=true install

to build .. and

mvn -Dmaven-test.skip=true sakai:deploy

to deploy

if you want to do it off-line (once you have built once) use -o

You may also find a new directory eg db-shared-deploy or util-common-deploy with just a pom.xml file.

These are the shared and common deployment descriptors that cant work in the main pom any more.

Once last thing, If you want to build a smaller distribution (eg a mini from the same code base) you cant edit the root pom.xml and comment out modules (providing the dependencies are fully resolved), and building in subdirs also works well.

Finally.... speed... maven 1 on my box is 15 minutes from clean, m2 is 11 from clean..... subdirs are much faster as there is no disk scan for project.xml files.

If you have any problems, or want to convert other projects just ask, I have some scripts (which are not perfect but eliminate most of the editing)

Update from Dec. 20, 2006

one last thing, until we get the latest sakai-plugin into the maven 2 repo, you will need to take it from svn trunk and install locally.

svn co https://source.sakaiproject.org/svn/maven2/trunk maven2trunk
cd maven2trunk
mvn install

Maven 2 and proxy servers

For those of you whose local networks use a proxy server, you will need to add a block like the following within the settings element of your settings.xml file:

<proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.somewhere.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
    </proxy>
  </proxies>

Labels

maven2 maven2 Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 02, 2007

    Ray Davis says:

    Why are you setting "Dmaventest.skip=true"? Is it because work needs to be done ...

    Why are you setting "-Dmaven-test.skip=true"? Is it because work needs to be done to make the JUnit tests Maven 2 compliant?

  2. Aug 23, 2007

    Ray Davis says:

    Here's another sample ".m2/settings.xml". I leave automatic JUnit tests at the...

    Here's another sample ".m2/settings.xml".

    • I leave automatic JUnit tests at their default, since that lets me know if I broke the build or if I'm inadvertently making everyone run automatic JUnit tests that shouldn't be run automatically.
    • Because I'm constantly switching between build environments (locally customized code vs. 2.4.x code vs. the full trunk vs. a Cafe build....), I want to choose the Tomcat target based on the system environment variable that determines which Tomcat will run.
    • I want the JUnit test outputs to be handled as they were in my Maven 1 builds.
    <settings>
      <profiles>
        <profile>
          <id>sakai</id>
          <properties>
            <maven.tomcat.home>${env.CATALINA_HOME}</maven.tomcat.home>
            <surefire.reportFormat>plain</surefire.reportFormat>
            <surefire.useFile>false</surefire.useFile>
          </properties>
        </profile>
      </profiles>
      <activeProfiles>
        <activeProfile>sakai</activeProfile>
      </activeProfiles>
    </settings>
  3. Dec 11, 2007

    Clay Fenlason says:

    Do we not need to specify remote repositories in the profile as well?

    Do we not need to specify remote repositories in the profile as well?