This dude has comments disabled on his post, and I just wanted to correct him on something.
“as long as you use the standard Maven directory structure” and
“Standard directory structure” sectionThat isn’t correct. All you have to do is configure your custom source
directory location, test source directory and any resource directories
and all things Maven will work just as if you were using the standard
convention.Maven also does a whole lot more you haven’t mentioned here, so just
to refer people:
http://maven.apache.org/maven-features.htmlNot to mention the hordes of plugins that are coming out.
Some of my take on the subject:
https://stubbisms.wordpress.com/2008/08/28/maven-is-to-ant-as-a-nail-gun-is-to-hammer-and-nails-you-need-to-move-on/
update
For Google’s sake, this is a reply to a blog post by Les Hazlewood regarding the issue of grafting Maven onto legacy projects, legacy being that they weren’t layed out with Maven in mind.
My reply to his post wasn’t going to come out right so here it is:
Hi Guys,
Good comments!
Here is the Maven POM you might be looking for, to build your sample app. I think it’s output is what you’re after, but I couldn’t check for sure as I had dificulty with your Ant build (fingers crossed this posts ok) 😉
<?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>org.jsecurity</groupId> <artifactId>jsecurity-spring-hibernate-sample</artifactId> <packaging>war</packaging> <version>0.9-SNAPSHOT</version> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>WEB-INF</directory> <targetPath>WEB-INF</targetPath> </resource> </webResources> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <artifactId>hibernate</artifactId> <groupId>org.hibernate</groupId> <version>3.2.6.ga</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.5</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.jsecurity</groupId> <artifactId>jsecurity</artifactId> <version>0.9.0-snapshot</version> </dependency> <dependency> <groupId>org.jsecurity</groupId> <artifactId>jsecurity-support</artifactId> <version>0.9.0-snapshot</version> </dependency> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.7</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> </dependency> </dependencies> </project>
I also add to add a POM to the ‘support-spring’ module:
<?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>org.jsecurity</groupId> <artifactId>jsecurity-support</artifactId> <version>0.9.0-snapshot</version> <name>JSecurity-support</name> <url>http://www.jsecurity.org</url> <dependencies> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.7.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.5</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.jsecurity</groupId> <artifactId>jsecurity</artifactId> <version>0.9.0-snapshot</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <version>2.3</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.3.1</version> <scope>test</scope> </dependency> </dependencies> <build> <!-- non-standard source locations --> <sourceDirectory>${basedir}/src</sourceDirectory> <testSourceDirectory>${basedir}/test</testSourceDirectory> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>${maven.compile.source}</source> <target>${maven.compile.target}</target> <encoding>${jsecurity.encoding}</encoding> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <!-- generate the IntelliJ project files --> <artifactId>maven-idea-plugin</artifactId> <configuration> <jdkLevel>${maven.compile.source}</jdkLevel> <downloadSources>true</downloadSources> </configuration> </plugin> <plugin> <!-- generate the Eclipse project files --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <downloadSources>true</downloadSources> <downloadJavadocs>false</downloadJavadocs> </configuration> </plugin> </plugins> </build> <properties> <!-- Default configuration for compiler source and target JVM --> <maven.compile.source>1.5</maven.compile.source> <maven.compile.target>1.5</maven.compile.target> <!-- Encoding of Java source files: Make sure, that the compiler and the javadoc generator use the right encoding. Subprojects may overwrite this, if they are using another encoding. --> <jsecurity.encoding>iso-8859-1</jsecurity.encoding> <jsecurity.docEncoding>${jsecurity.encoding}</jsecurity.docEncoding> </properties> </project>
Note that most of this would be cut down with the use of a parent POM, which I haven’t used here.
Note that you will also have to have jsecurity and the support module either ‘installed’ in your local repo (mvn install) or in your workspace in Elcipse when using m2eclipse.
The resultant structure looks like this:
Let me know if you have any queries…
Also if you add:
<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> </plugin>
to the plugins section of your pom, you can then run the application in place using jetty with:
mvn jetty:run-war
You must be logged in to post a comment.