Thursday, November 8, 2012

How to list down all maven available properties?

It will be very important for you to know all the available maven properties when you are working with maven project. We know few properties. Some of those properties are ${project.groupId}, ${project.version} and few more. I intended to give you a technique to find out all the available properties given by maven which will be very helpful for you. 

Here is the way. You can create a new simple maven project. It may be either jar project or war project. Even you can use one of your existing project too. Open the project pom.xml file and see the following section is in your pom.xml file.


Since, We are going to use maven-antrun-plugin, we need to add this plugin into our project pom.xml file. If the above section is not in our pom.xml file, you have to add above section into your pom.xml file. Next copy and past the following plugin inside <plugins> section.
                        <echoproperties />

The maven-antrun-plugin allows us to run ant targets with maven. The above ant target will execute when we run 'clean install' maven goal. Notice that I have specified 'install' as the phase which means that this ant target will execute with the maven 'install' goal runs. Navigate to your project directory using command line.

$cd <path to your project directory>
$mvn clean install

It will start the building the project and meanwhile, lists down all the maven properties. You will get similar output as follows.
[echoproperties] #Ant properties
[echoproperties] #Thu Nov 08 19:57:30 IST 2012
[echoproperties] ant.core.lib=/home/vinesh/.m2/repository/org/apache/ant/ant/1.8.2/ant-1.8.2.jar
[echoproperties] ant.file=/home/vinesh/workspace-maaven/shims/shims-web/pom.xml
[echoproperties] ant.file.maven-antrun-=/home/vinesh/workspace-maaven/shims/shims-web/target/antrun/build-main.xml
[echoproperties] ant.file.type.maven-antrun-=file
[echoproperties] ant.project.default-target=main
If you don't know how to create maven projects, please look the following URL. 

How to create multi module project with maven.

You may also like:


Post a Comment