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.
<build> <plugins> <plugin> .............. </plugin> </plugins> </build>
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.
<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>install</phase> <configuration> <target> <echoproperties /> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
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.
If you don't know how to create maven projects, please look the following URL.
[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.java.version=1.6 [echoproperties] ant.project.default-target=main .................... ....................
How to create multi module project with maven.
0 comments:
Post a Comment