You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2003/12/31 02:32:36 UTC
cvs commit: maven/src/java/org/apache/maven MavenUtils.java
brett 2003/12/30 17:32:36
Modified: src/java/org/apache/maven Tag: MAVEN-1_0-BRANCH
MavenUtils.java
Log:
cleanup project creation, make inheritence work
Revision Changes Path
No revision
No revision
1.107.4.4 +49 -42 maven/src/java/org/apache/maven/MavenUtils.java
Index: MavenUtils.java
===================================================================
RCS file: /home/cvs/maven/src/java/org/apache/maven/MavenUtils.java,v
retrieving revision 1.107.4.3
retrieving revision 1.107.4.4
diff -u -r1.107.4.3 -r1.107.4.4
--- MavenUtils.java 10 Dec 2003 23:08:44 -0000 1.107.4.3
+++ MavenUtils.java 31 Dec 2003 01:32:36 -0000 1.107.4.4
@@ -115,7 +115,7 @@
public class MavenUtils
{
/** Log. */
- private static final Log logger = LogFactory.getLog( MavenUtils.class );
+ private static final Log log = LogFactory.getLog( MavenUtils.class );
/** Internal encoding used for Jelly interpolation. */
private static final String INTERNAL_ENCODING = "ISO-8859-1";
@@ -166,7 +166,32 @@
/**
* Create a Project object given a file descriptor and optionally a parent Jelly
- * context. We are doing several things when creating a POM object, the phases
+ * context.
+ *
+ * @param projectDescriptor a maven project.xml {@link File}
+ * @param parentContext the parent context for the new project
+ * @param useParentPom whether a parent project should be respected
+ * @return the MavenSession project object for the given project descriptor
+ * @throws Exception when any errors occur - TODO [RC2] bad
+ */
+ public static Project getProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
+ throws Exception
+ {
+ Project project = getNonJellyProject( projectDescriptor, parentContext, useParentPom );
+ project = getJellyProject( project );
+ project.setFile( projectDescriptor );
+
+ // Fully initialize the project.
+ project.initialize();
+
+ return project;
+ }
+
+ /**
+ * Get a project, but not a Jelly-ised project. ie Don't evaluate the
+ * variables. We are doing several things when creating a POM object, the phases
* are outlined here:
*
* 1) The project.xml file is read in using betwixt which creates for us a
@@ -177,33 +202,27 @@
* own context. See the createContext() method for the details context creation
* process.
*
- * 3) We check to see if the <extend> tag is being employed. If so, the parent
+ * 3) We check to see if the <extend> tag is being employed. If so, the parent
* project.xml file is read in. At this point we have a child and parent POM
* and the values are merged where the child's values override those of the
* parent.
- *
- * 4) The POM we have at this point is then processed through Jelly.
- *
- * @todo should cache all project xml files with the right context , merged down to the leafs in inheritence
- * @param projectDescriptor a maven project.xml {@link File}
+ * @param projectDescriptor the project file
* @param parentContext the parent context for the new project
* @param useParentPom whether a parent project should be respected
- * @return the MavenSession project object for the given project descriptor
- * @throws Exception when any errors occur
+ * @return the project
+ * @throws Exception when any errors occur - TODO [RC2] bad
*/
- public static Project getProject( File projectDescriptor,
- MavenJellyContext parentContext,
- boolean useParentPom )
+ private static Project getNonJellyProject( File projectDescriptor,
+ MavenJellyContext parentContext,
+ boolean useParentPom )
throws Exception
{
- //if ( pom.get())
-
// 1)
Project project = (Project) getProjectBeanReader().parse( projectDescriptor );
// 2)
- MavenJellyContext context = MavenUtils.createContext( projectDescriptor.getParentFile(),
- parentContext );
+ MavenJellyContext context = MavenUtils.createContext( projectDescriptor.getParentFile(), parentContext );
+
// 3)
String pomToExtend = project.getExtend();
@@ -222,15 +241,11 @@
Project parent = (Project) parentPoms.get( parentPom.getCanonicalPath() );
if ( parent == null )
{
- parent = (Project) getProjectBeanReader().parse( parentPom );
+ parent = getNonJellyProject( parentPom, null, true );
parent.setFile( parentPom );
parentPoms.put( parentPom.getCanonicalPath(), parent );
-// TODO [RC2] - check -vvv-
- MavenJellyContext pContext = MavenUtils.createContext( projectDescriptor.getParentFile(),
- parentContext );
-parent.setContext(pContext);
-context.setParent(pContext);
-// TODO [RC2] - check -^^^-
+
+ context.setParent( parent.getContext() );
}
Properties properties = loadProjectBuildProperties( parentPom.getParentFile() );
@@ -246,13 +261,6 @@
project.setContext( context );
context.setProject( project );
- // 4)
- project = getJellyProject( project );
- project.setFile( projectDescriptor );
-
- // Fully initialize the project.
- project.initialize();
-
return project;
}
@@ -329,8 +337,7 @@
private static Project getJellyProject( Project project )
throws Exception
{
- // Save the original context because we null it temporarly
- // while we funnel it through betwixt.
+ // Keep a copy of the original context
MavenJellyContext originalContext = project.getContext();
// We don't want any taglib references in the context or Jelly
@@ -656,7 +663,7 @@
File projectBuildPropertiesFile =
new File( directory, "build.properties" );
- logger.debug( "Using projectBuildPropertiesFile: " + projectBuildPropertiesFile.getAbsolutePath() );
+ log.debug( "Using projectBuildPropertiesFile: " + projectBuildPropertiesFile.getAbsolutePath() );
return loadProperties( projectBuildPropertiesFile );
}
@@ -671,7 +678,7 @@
File projectPropertiesFile =
new File( directory, "project.properties" );
- logger.debug( "Using projectPropertiesFile: " + projectPropertiesFile.getAbsolutePath() );
+ log.debug( "Using projectPropertiesFile: " + projectPropertiesFile.getAbsolutePath() );
return loadProperties( projectPropertiesFile );
}
@@ -709,7 +716,7 @@
File userBuildPropertiesFile =
new File( System.getProperty( "user.home" ), "build.properties" );
- logger.debug( "Using userBuildPropertiesFile: " + userBuildPropertiesFile.getAbsolutePath() );
+ log.debug( "Using userBuildPropertiesFile: " + userBuildPropertiesFile.getAbsolutePath() );
Properties userBuildProperties = loadProperties( userBuildPropertiesFile );
Properties projectProperties = loadProjectProperties( descriptorDirectory );
@@ -750,7 +757,7 @@
// Turn inheritance back on to make the parent's values visible.
context.setInherit( true );
- //add in the driver.properties with defaults, but in inheritance mode.
+ //add in the default.properties with defaults, but in inheritance mode.
MavenUtils.integrateMapInContext( defaultProperties, context );
}
else
@@ -818,7 +825,7 @@
catch ( Exception e )
{
// do nothing.
- logger.debug("Unexpected error evaluating expression", e);
+ log.debug("Unexpected error evaluating expression", e);
}
}
}
@@ -839,7 +846,7 @@
catch ( Exception e )
{
// ignore
- logger.debug("Unexpected error loading properties", e);
+ log.debug("Unexpected error loading properties", e);
}
return null;
@@ -862,7 +869,7 @@
catch ( IOException e )
{
// ignore
- logger.debug("Unexpected exception loading properties", e);
+ log.debug("Unexpected exception loading properties", e);
}
finally
{
@@ -876,7 +883,7 @@
catch ( IOException e )
{
// ignore
- logger.debug("Unexpected exception loading properties", e);
+ log.debug("Unexpected exception loading properties", e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org