|
MONK : Maven For MONKS
This page last changed on Jan 21, 2008 by chartra@mcmaster.ca.
The latest version of the MONK middleware (aka the MONK Proxy, aka MONK Web Services) uses Maven2 (http://maven.apache.org/) to manage builds and dependencies (dependencies are java jar files required by a project). Maven is like ANT but adopts certain conventions so that common build functions can be provided by Maven rather than requiring the developer to write the build in full. Anyhow, some hopefully helpful hints: 1. How to add a dependency (this example adds the XStream jar): Add an entry like the following to <dependencies> in the pom.xml file (the pom.xml file is in the root directory of the project): <dependency> <groupId>xstream</groupId> <artifactId>xstream</artifactId> <version>1.1.3</version> </dependency> This will download the file http://repo1.maven.org/maven2/xstream/xstream/1.1.3/xstream-1.1.3.jar at build time, and put it in a local repository (~/.m2/repository) The groupID, artifactID, and version specified above can be looked up in the appropriate maven-metadata.xml file in the appropriate directory of the maven repository at http://repo1.maven.org/maven2 or 2. How to add a new local jar to the MONK repository Sometimes you'll want to add a new project specific jar file as a dependency, i.e., a jar file that isn't available in any public repository. The MONK project has a MONK specific repository for hosting local jars: http://www.monkproject.org/maven2/ To add this repository to a pom.xml file (it has already been added to the MONK middleware POM) add the following to the <repositories> section: <repository> <id>monk</id> <url>http://www.monkproject.org/maven2</url> </repository> To add a jar file to the MONK repository: Create a new subdirectory structure in the monk repository (in the web server's file system). Use the existing subdirectories as an example of how to structure your directories. Also, following the existing structure as an example, create the appropriate pom.xml file that lists any dependencies of your new jar, and create the appropriate maven-metadata.xml files that describe your jar (id, version, etc.) Don't forget to include a copy of your new jar. Finally add your new jar as a dependency to the main project pom.xml file (i.e., the one in the root directory of the project) just as you would any other dependency. 3. Developing in Eclipse using Maven: Check out (from terminal) the project: e.g., svn checkout svn://nora.lis.uiuc.edu/MonkMiddleWare/trunk middleware Run: mvn eclipse:eclipse (from terminal) (if you have trouble with maven repo here try deleting ~/.m2 directory, i.e., the local maven repository import project into eclipse You'll get missing class file errors so set the maven local repo location in eclipse by running this from the command line: mvn -Declipse.workspace=~/Documents/workspaceMONK/ eclipse:add-maven-repo or if that doesn't work (it didn't work for me): set it manually in Eclipse preferences, Java/BuildPath/ClassPathVariables: M2_REPO=~/.m2/repository run: mvn jetty:run (from terminal) setup eclipse to debug jetty instance as described here: Gotcha: sometimes you'll get an error saying a remote repository isn't valid or that a certain file can't be retrieved. Try deleting the local maven rep (~/.m2) and then run your build again. |
| Document generated by Confluence on Apr 19, 2009 15:04 |