Java Mailing List Archive

http://www.java2.5341.com/

Home » Maven Users List »

getting POM default build locations

Jacob Danner

2008-10-02

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,
Sorry if this is a dumb question, I queried nabble and checked all the
docs I could find for an answer in advance.

I'm trying to find out how I can get the default values for a maven
pom. The POM reference (http://maven.apache.org/pom.html#Directories)
notes that the default sourceDirectory for a POM is:

${basedir}/src/main/java

and if the build/sourceDirectory element is not defined in the POM a call to

org.apache.maven.model.Model.getBuild().getSourceDirectory()
returns null.
I would like to know if there is a way (other than hard coding a value
to src/main/java) for me to retrieve the sourceDirectory value.

My code looks similar to:

       String src = ...
       URL pom = ...
       MavenXpp3Reader mxr = new MavenXpp3Reader();
       Model m = null;
       m = mxr.read(new InputStreamReader(pom.openStream()));

       MavenProject mp = new MavenProject(m);

       if(mp.getBuild().getSourceDirectory() == null)
           src = <HOW _TO_GET_DEFAULT_SRC_DIRECTORY>

Any help is appreciated,
-jacobd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.