Join the DZone community and get the full member experience.Join For Free
Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!
I am a bit of a Maven fanboy. Actually I am more of a - use anything available to make your task easier, smoother and more efficient - person. And Maven has fit the bill perfectly for near about 3 - 4 years now.
I had written earlier about Maven here. In a very recent conversation around standardization of toolkit for software project / product lifecycle, I realized that Maven was perhaps one of the lowest common denominators to start from (speaking of Java world). I simultaneously - as I was rattling off the virtues of adopting Maven enterprise wide, to the audience - realized that I had not really written enough about it. And hence this article.
With some technology like Maven, I don't see much reason to write, yet again, about how to set up, how to use etc. You will find almost everything very neatly described in the Maven website. I have found loads of very good articles on Maven at this link as well. However, I think I will share a couple of tips here.
I dislike polluting (some people will disagree that this is "polluting") my system settings with product specific stuff e.g. JAVA_HOME etc. I have always found it much easier to use a simple batch file instead. I use that with Maven as well. I tend to have this (or some variation of this) batch file, which when run (after taking off the appropriate REMs) will do the basic stuff e.g. creating a java application, creating a web application, running them, executing a specific unit tests etc. These instructions are easily available, but I personally found it useful to have it handy and ready.
ECHO OFF REM ============================= REM Set the env. variables. REM ============================= SET PATH=%PATH%;C:\ProgramFiles\apache-maven-3.0.4\bin; SET JAVA_HOME=C:\ProgramFiles\Java\jdk1.7.0 REM ============================= REM Get a list of all template projects. REM ============================= REM mvn archetype:generate REM ============================= REM Standalone java application. REM ============================= REM call mvn archetype:generate ^ REM -DarchetypeArtifactId=maven-archetype-quickstart ^ REM -DinteractiveMode=false ^ REM -DgroupId=foo.bar ^ REM -DartifactId=standaloneJava001 REM ============================= REM Standalone java web application. REM ============================= REM call mvn archetype:generate ^ REM -DarchetypeArtifactId=maven-archetype-webapp ^ REM -DinteractiveMode=false ^ REM -DgroupId=foo.bar ^ REM -DartifactId=web001 REM ============================= REM Run the main class. REM ============================= REM mvn exec:java -Dexec.mainClass="foo.bar.Main" REM mvn exec:java -Dexec.mainClass="foo.bar.Main" -Dexec.args="arg0 arg1 arg2" REM ============================= REM Run unit tests. REM ============================= REM mvn test REM mvn -Dtest=myUnitTest test pause
This is all that I had time for today, but I will come back and add more tips to this page.
Opinions expressed by DZone contributors are their own.