This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Just starting using Maven after about ten years of ANT!
1. In ANT I could very easily write a target to move some files around my system and call this without calling anything else?
How do I do this in MAVEN
2. In ANT I could very easily crate a target to call a PMD task to run PMD on my source code - how do I do this in maven?
3.for a plugin what is the difference between an execution,a goal and a phase?
4. Is it possible to debug a POM.xml?
5. What is the nexus indexer?
6. Is it possible to configure what port maven uses when it searches the global repository?
Generally most things in maven are done using plugins and there are plugins for just about anything that can be found by just googling for it. I'll attempt to answer through.
1) There is a plugin for that. You can use the the maven resources plugin. If you don't specify a phase in the execution tag, then it won't execute as part of your normal build. You can execute it using mvn resource:copy-resources
2) There is a plugin for that. http://maven.apache.org/plugins/maven-pmd-plugin/ 3) Think of a goal as a method on the plugin, and think of execution as parameters to the method. A execution may or may not be tied to a phase. Maven goes through phases when it does the build, and for each phase it executes the executions that are tied to the phase
4) Not that I know of. However, maven logs plenty, and plenty more if you turn on verbose. I have been using maven for close to 2 years now, and haven;t found the need to debug a pom.xml
5) DOn't know how much you know about maven repositories. But, simply put, nexus is an implementation of a maven repository. Nexus is not the only one. There is Artifactory too. It is popular and reccomended because it does lazy caching of other maven repos. The way it works in maven is that you never checkin your dependent libraries in your source control. What you do is in your pom, you list out the libraries that your project needs. Maven downloads the jars from the maven repo. Now, if these libraries need libraries themselves, maven downloads them too. This prevents you from going into Jar Hell, where you have all these unrelated libraries checking into your SVN that you have no idea what they are being used for. The disadvantage of this is that since lot of people started using maven, the load on maven repo became a problem. So, they reccomended that people install their own maven repo mirror in their local networks, so they don't have to hit the central repo everytime. The problem is that maintaining the mirror is cumbersome. So, here comes Nexus indexer that makes it easy for you to mirror. You install Nexus in your local network, and configure your POM to get the libraries from your Nexus. If Nexus has it, it gives it to you, otherwise it gets it from central maven repo and puts it in it's own repo. Next time you need the library, Nexus will provide it from it's local storage instead of hitting the central repo
Joined: May 12, 2010
Thanks so much for your answer. I'm a little bit confused about defined the PMD plugin.
My understanding is I can define it in <build> or <reporting>? Which makes more sense?
Also how do I call it without calling other life cycle "phases"? My understanding is with maven say when you call say "test" it *always* calls previous life cycle phases?
Is it possible to define the PMD plugin in my pom.xml so that it can be run without anything else running?