o Extended model with fields to track source file and project directory

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@778494 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-25 20:43:01 +00:00
parent 1ace747678
commit 89d7b13fd6
2 changed files with 63 additions and 16 deletions

View File

@ -50,7 +50,11 @@ public class DefaultModelReader
throw new IllegalArgumentException( "input file missing" );
}
return read( ReaderFactory.newXmlReader( input ), options );
Model model = read( ReaderFactory.newXmlReader( input ), options );
model.setPomFile( input );
return model;
}
public Model read( Reader input, Map<String, Object> options )

View File

@ -566,20 +566,64 @@
<version>4.0.0</version>
<code>
<![CDATA[
/**
* The POM from which this model originated. This is transient runtime state and therefore not managed by Modello.
*/
private java.io.File pomFile;
/**
* Gets the POM file from which this model originated. This can either be a {@code pom.xml} of some project being
* built or the {@code *.pom} of some artifact being resolved from the repository.
*
* @return The POM file from which this model originated or {@code null} if unknown.
*/
public java.io.File getPomFile()
{
return pomFile;
}
public void setPomFile( java.io.File pomFile )
{
this.pomFile = pomFile;
}
/**
* The base directory for the corresponding project (if any). This is transient runtime state and therefore not
* managed by Modello.
*/
private java.io.File projectDirectory;
/**
* Gets the base directory for the corresponding project (if any). Note that this is really a separate piece of
* information and not necessarily equivalent to the parent directory of {@link #getPomFile()}.
*
* @return The base directory for the corresponding project or {@code null} if this model does not belong to a local
* project but describes the metadata of some artifact from the repository.
*/
public java.io.File getProjectDirectory()
{
return projectDirectory;
}
public void setProjectDirectory( java.io.File projectDirectory )
{
this.projectDirectory = projectDirectory;
}
/**
* @return the model id as <code>groupId:artifactId:packaging:version</code>
*/
public String getId()
{
StringBuffer id = new StringBuffer();
StringBuilder id = new StringBuilder( 64 );
id.append( getGroupId() == null ? "[inherited]" : getGroupId() );
id.append( ( getGroupId() == null ) ? "[inherited]" : getGroupId() );
id.append( ":" );
id.append( getArtifactId() );
id.append( ":" );
id.append( getPackaging() );
id.append( ":" );
id.append( getVersion() == null ? "[inherited]" : getVersion() );
id.append( ( getVersion() == null ) ? "[inherited]" : getVersion() );
return id.toString();
}
@ -1878,7 +1922,7 @@
*/
public String toString()
{
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder( 128 );
sb.append("PatternSet [includes: {");
for (java.util.Iterator i = getIncludes().iterator(); i.hasNext(); )
@ -1963,14 +2007,13 @@
*/
public String getId()
{
StringBuffer id = new StringBuffer();
StringBuilder id = new StringBuilder( 64 );
id.append( getGroupId() );
id.append( ":" );
id.append( getArtifactId() );
id.append( ":" );
id.append( "pom" );
// id.append( getPackaging() );
id.append( ":" );
id.append( getVersion() );