You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Seal, Devjyoti" <De...@atosorigin.com> on 2007/03/07 13:50:48 UTC

Reading pom.xml in Java

Hi All,

I need to read the version from the pom.xml through Java and display it
on my application, can you please suggest if there any Maven API which
helps in reading the POM in Java. I am using Maven 2.0.

Please let me know which API provides that?

Thanks you in advance

Devjyoti Seal


Disclaimer: This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted. 

Re: Reading pom.xml in Java

Posted by konkere <em...@inbox.ru>.
same question but for writing POMs. MavenXpp3Writer writes empty pom.xml for
unknown reason.
-- 
View this message in context: http://www.nabble.com/Reading-pom.xml-in-Java-tp9352387s177p15976681.html
Sent from the Maven Developers mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Reading pom.xml in Java

Posted by Franz Allan Valencia See <fr...@gmail.com>.
Good day to you, Devjyoti Seal,

If you want to read a pom file, you can use the MavenXpp3Reader#read(
... ) ( see [1] ).

But if you simply want to get the version of your currently running
maven project inside your pom ( which is usually the case ), you can
simply do

[snippet]
/**
 * @parameter expression="${project.version}"
 */
private String version;
[/snippet]

( see [2] for more info on Mojo Development )

Also, if you have a maven project ( similar to the contents of its pom
except that inheritance is already applied ) and want to get its
version, you can use MavenProject#getVersion() ( see [3] )

Cheers,
Franz

[1] http://maven.apache.org/ref/current/maven-model/apidocs/
[2] http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook
[3] http://maven.apache.org/ref/current/maven-project/apidocs/

On 3/7/07, Seal, Devjyoti <De...@atosorigin.com> wrote:
> Hi All,
>
> I need to read the version from the pom.xml through Java and display it
> on my application, can you please suggest if there any Maven API which
> helps in reading the POM in Java. I am using Maven 2.0.
>
> Please let me know which API provides that?
>
> Thanks you in advance
>
> Devjyoti Seal
>
>
> Disclaimer: This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org