• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Simple MAVEN questions

 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just starting using Maven after about ten years of ANT!

Some questions:

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?

 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Thanks.

 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the documentation on the plugin in my link above. Read the goals and usage. It has examples on how to call the goals directly and how to bind it to a phase
 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:Look at the documentation on the plugin in my link above. Read the goals and usage. It has examples on how to call the goals directly and how to bind it to a phase



In the first link, copy-resource goal is configured to run during the phase validate for the mavane-resources-plugin.
How do I know what phases a plugin has?


 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some update, manged to get something to work.

I added the following into <build>...<plugins>.../<plugins> </build>



PMD has four goals: pmd, cpd, pmd:check, pmd:cpcheck

To execute the first goal pmd, I did:
>mvn pmd:pmd

This outputs pmd results to:

%project-home%\target\site


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic