You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/04/16 14:39:29 UTC
cvs commit: maven-new/src/java/org/apache/maven/verifier DefaultLocalSettingsVerifier.java LocalSettingsVerifier.java
jvanzyl 2003/04/16 05:39:29
Modified: src/java/org/apache/maven DefaultMaven.java Maven.java
src/java/org/apache/maven/project Project.java
src/java/org/apache/maven/project/builder
DefaultProjectBuilder.java ProjectBuilder.java
src/java/org/apache/maven/verifier
DefaultLocalSettingsVerifier.java
LocalSettingsVerifier.java
Log:
o Turn the local settings verifier in a component.
o Another cleanup of the Maven contract.
Revision Changes Path
1.2 +102 -133 maven-new/src/java/org/apache/maven/DefaultMaven.java
Index: DefaultMaven.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/DefaultMaven.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultMaven.java 15 Apr 2003 01:16:31 -0000 1.1
+++ DefaultMaven.java 16 Apr 2003 12:39:28 -0000 1.2
@@ -66,7 +66,6 @@
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.project.Project;
import org.apache.maven.project.builder.ProjectBuilder;
-import org.apache.maven.util.I18NUtils;
import org.apache.maven.verifier.ChecksumVerificationException;
import org.apache.maven.verifier.DependencyVerifier;
import org.apache.maven.verifier.LocalSettingsVerifier;
@@ -75,9 +74,6 @@
import org.apache.plexus.logging.AbstractLogEnabled;
import java.io.File;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -109,18 +105,6 @@
// Constants
// ------------------------------------------------------------
- /** Tag for build start goal. */
- public static final String BUILD_START_GOAL = "build:start";
-
- /** Tag for build end goal. */
- public static final String BUILD_END_GOAL = "build:end";
-
- /** The current MavenSession version id */
- public static final String APP_VERSION = "1.0-beta-9-SNAPSHOT";
-
- // These need to be coupled with messages so users have some
- // idea what's going on.
-
/** return code from command prompt when a goal isn't found */
private static final int RC_NO_GOAL = 30;
@@ -136,15 +120,9 @@
/** return code for a failure due to anything else */
private static final int RC_OTHER_FAILURE = 90;
- // With the remove of ant from the core we should only need
- // a root realm.
-
/** */
private static final String ROOT_REALM = "root";
- /** */
- private static final String MAVEN_ROOT_REALM = "root.maven";
-
// ----------------------------------------------------------------------
// Options
// ----------------------------------------------------------------------
@@ -171,46 +149,41 @@
private PluginManager pluginManager;
/** Root project. */
- private Project rootProject;
-
+ private Project project;
/** Root classworlds class realm. */
private ClassRealm rootClassRealm;
- /** Maven root classworlds class realm. */
- private static ClassRealm mavenRootClassRealm;
-
- private static ClassRealm currentClassRealm;
+ /** */
+ private File projectFile;
/** List of string goal names on the command-line. */
private List goalNames;
+ /** */
private Map options;
- private File project;
+ /** Execution time. */
private Date startTime;
private Date endTime;
private long executionDuration;
+
// ----------------------------------------------------------------------
// Errors
// ----------------------------------------------------------------------
+
private Throwable rootCause;
private Throwable cause;
private String errorMessage;
- private File mavenHome;
-
- public File getMavenHome()
- {
- return mavenHome;
- }
+ // ----------------------------------------------------------------------
+ // Environment
+ // ----------------------------------------------------------------------
- public void setMavenHome( File mavenHome )
- {
- this.mavenHome = mavenHome;
- }
+ private File mavenHome;
+ private File mavenRepoLocal;
// ----------------------------------------------------------------------
// Constructors
@@ -228,7 +201,6 @@
try
{
rootClassRealm = classWorld.getRealm( ROOT_REALM );
- mavenRootClassRealm = classWorld.getRealm( MAVEN_ROOT_REALM );
}
catch ( Exception e )
{
@@ -257,38 +229,22 @@
public void initialize()
throws Exception
{
- dependencyVerifier.setIgnoreErrors( false );
-
- initializeRootProject();
+ // Verfify the local settings.
+ localSettingsVerifier.verify();
}
// ----------------------------------------------------------------------
- // Accessors
+ // Setting of the project resource
// ----------------------------------------------------------------------
- public void addGoal( String goal )
- {
- }
-
- public void addGoals( List goals )
- {
- }
-
- public void setProject( String project )
- {
- }
-
- public void setProject( InputStream project )
+ public void setProjectFile( File projectFile )
{
+ this.projectFile = projectFile;
}
- public void setProject( URL project )
- {
- }
-
- public void setProject( Reader project )
- {
- }
+ // ----------------------------------------------------------------------
+ // Error Handling.
+ // ----------------------------------------------------------------------
public String getErrorMessage()
{
@@ -310,6 +266,20 @@
this.cause = cause;
}
+ public Throwable getRootCause()
+ {
+ return rootCause;
+ }
+
+ public void setRootCause( Throwable rootCause )
+ {
+ this.rootCause = rootCause;
+ }
+
+ // ----------------------------------------------------------------------
+ // Execution time.
+ // ----------------------------------------------------------------------
+
public Date getStartTime()
{
return startTime;
@@ -340,38 +310,6 @@
this.executionDuration = executionDuration;
}
- public Throwable getRootCause()
- {
- return rootCause;
- }
-
- public void setRootCause( Throwable rootCause )
- {
- this.rootCause = rootCause;
- }
-
- // Setting the POM, the client can use an URL, a file, Project, InputStream.
-
- public void setProject( File project )
- {
- this.project = project;
- }
-
- public File getProjectFile()
- {
- return project;
- }
-
- public Map getOptions()
- {
- return options;
- }
-
- public void setOptions( Map options )
- {
- this.options = options;
- }
-
/**
*
* @return
@@ -381,23 +319,26 @@
return rootClassRealm;
}
- /**
- *
- * @return
- */
- public ClassRealm getMavenRootClassRealm()
+ public void setProject( Project project )
+ {
+ this.project = project;
+ }
+
+ public Project getProject()
{
- return mavenRootClassRealm;
+ return project;
}
- public void setRootProject( Project rootProject )
+ // ----------------------------------------------------------------------
+ // Goal Processing
+ // ----------------------------------------------------------------------
+
+ public void addGoal( String goal )
{
- this.rootProject = rootProject;
}
- public Project getRootProject()
+ public void addGoals( List goals )
{
- return rootProject;
}
/** Retrieve the list of goal names.
@@ -440,16 +381,6 @@
}
}
- public static void setCurrentClassRealm( ClassRealm classRealm )
- {
- currentClassRealm = classRealm;
- }
-
- public static ClassRealm getCurrentClassRealm()
- {
- return currentClassRealm;
- }
-
/**
* Get a given goal's description.
*
@@ -567,23 +498,12 @@
* @throws Exception If there is an error while
* reading the project descriptor.
*/
- private void initializeRootProject()
+ private void initializeProject()
throws Exception
{
- File descriptorFile = getProjectFile();
-
- // THIS NEEDS TO BE SET
- //getRootContext().setMavenSession( this );
-
- if ( descriptorFile.exists() )
+ if ( projectFile != null )
{
- if ( descriptorFile.length() == 0 )
- {
- throw new Exception( I18NUtils.getMessage( "empty.descriptor.error",
- descriptorFile.getName() ) );
- }
-
- setRootProject( projectBuilder.getProject( descriptorFile ) );
+ setProject( projectBuilder.build( projectFile ) );
}
else
{
@@ -592,10 +512,10 @@
// in the rest of the code.
Project globalProject = new Project();
globalProject.setId( "Global Project" );
- setRootProject( globalProject );
+ setProject( globalProject );
}
- getRootProject().setGoalNames( getGoalNames() );
+ getProject().setGoalNames( getGoalNames() );
}
// Once a set of goals have been attained should they be removed from
@@ -643,4 +563,53 @@
}
}
+ // ----------------------------------------------------------------------
+ // Environment
+ // ----------------------------------------------------------------------
+
+ public Map getOptions()
+ {
+ return options;
+ }
+
+ public void setOptions( Map options )
+ {
+ this.options = options;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public File getMavenHome()
+ {
+ return mavenHome;
+ }
+
+ /**
+ *
+ * @param mavenHome
+ */
+ public void setMavenHome( File mavenHome )
+ {
+ this.mavenHome = mavenHome;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public File getMavenRepoLocal()
+ {
+ return mavenRepoLocal;
+ }
+
+ /**
+ *
+ * @param mavenRepoLocal
+ */
+ public void setMavenRepoLocal( File mavenRepoLocal )
+ {
+ this.mavenRepoLocal = mavenRepoLocal;
+ }
}
1.2 +42 -45 maven-new/src/java/org/apache/maven/Maven.java
Index: Maven.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/Maven.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Maven.java 15 Apr 2003 01:16:33 -0000 1.1
+++ Maven.java 16 Apr 2003 12:39:28 -0000 1.2
@@ -1,12 +1,8 @@
package org.apache.maven;
-import com.werken.classworlds.ClassRealm;
import org.apache.maven.project.Project;
import java.io.File;
-import java.io.InputStream;
-import java.io.Reader;
-import java.net.URL;
import java.util.List;
import java.util.Map;
@@ -77,41 +73,6 @@
static String ROLE = Maven.class.getName();
/**
- * Set the Maven POM source as a <code>String</code>.
- *
- * @param project Maven POM source.
- */
- void setProject( String project );
-
- /**
- * Set the Maven POM source as a <code>File</code>.
- *
- * @param project Maven POM source.
- */
- void setProject( File project );
-
- /**
- * Set the Maven POM source as a <code>Reader</code>.
- *
- * @param project Maven POM source.
- */
- void setProject( Reader project );
-
- /**
- * Set the Maven POM source as an <code>InputStream</code>.
- *
- * @param project Maven POM source.
- */
- void setProject( InputStream project );
-
- /**
- * Set the Maven POM source as an <code>URL</code>.
- *
- * @param project Maven POM source.
- */
- void setProject( URL project );
-
- /**
* Set the options for the model.
*
* @param options Options for the model.
@@ -119,7 +80,7 @@
void setOptions( Map options );
// ----------------------------------------------------------------------
- // Goal related methods.
+ // Goal Processing
// ----------------------------------------------------------------------
/**
@@ -153,12 +114,48 @@
void attainGoals()
throws UnknownGoalException, Exception;
- // Initial environment
- File getMavenHome();
- // Classworlds
+ // ----------------------------------------------------------------------
+ // Project Handling
+ // ----------------------------------------------------------------------
- ClassRealm getMavenRootClassRealm();
+ /**
+ * Set the Maven POM source as a <code>Reader</code>.
+ *
+ * @param project Maven POM source.
+ */
+ void setProjectFile( File project );
+
+ /**
+ *
+ * @return
+ */
+ Project getProject();
+
+ // ----------------------------------------------------------------------
+ // Environment
+ // ----------------------------------------------------------------------
+
+ /**
+ *
+ */
+ void setMavenHome( File mavenHome );
+
+ /**
+ *
+ * @return
+ */
+ File getMavenHome();
- Project getRootProject();
+ /**
+ *
+ * @param mavenRepoLocal
+ */
+ void setMavenRepoLocal( File mavenRepoLocal );
+
+ /**
+ *
+ * @return
+ */
+ File getMavenRepoLocal();
}
1.2 +1 -11 maven-new/src/java/org/apache/maven/project/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/project/Project.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Project.java 15 Apr 2003 01:16:37 -0000 1.1
+++ Project.java 16 Apr 2003 12:39:28 -0000 1.2
@@ -1558,16 +1558,6 @@
return (String) getVariable( MavenConstants.JAR_OVERRIDE_PROPERTY + id );
}
- /**
- * Get MavenSession home.
- *
- * @return MavenSession home.
- */
- public String getMavenHome()
- {
- return (String) getVariable( MavenConstants.MAVEN_HOME );
- }
-
private void setVariable( String key, Object value )
{
getProperties().put( key, value );
1.3 +5 -11 maven-new/src/java/org/apache/maven/project/builder/DefaultProjectBuilder.java
Index: DefaultProjectBuilder.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/project/builder/DefaultProjectBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultProjectBuilder.java 16 Apr 2003 00:31:51 -0000 1.2
+++ DefaultProjectBuilder.java 16 Apr 2003 12:39:28 -0000 1.3
@@ -8,6 +8,7 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -32,23 +33,16 @@
/** Map of loaded POMs. */
private HashMap parentPoms = new HashMap();
- /**
- * Create a Project object given a name a file descriptor.
- *
- * @param projectDescriptor a maven project.xml
- * @return the MavenSession project object for the given project descriptor
- * @throws java.lang.Exception when any errors occur
- */
public Project build( File projectDescriptor )
throws Exception
{
return build( projectDescriptor, null );
}
- public Project build( File projectDescriptor, Project rootProject )
+ public Project build( File projectDescriptor, Project parent )
throws Exception
{
- return build( projectDescriptor, rootProject, true );
+ return build( projectDescriptor, parent, true );
}
/**
@@ -87,7 +81,7 @@
// parent project.
// 1)
- Project project = pomUnmarshaller.parse( projectDescriptor );
+ Project project = pomUnmarshaller.parse( new FileReader( projectDescriptor ) );
// 2)
Map propertiesMap = createPropertiesMap( projectDescriptor.getParentFile(),
@@ -110,7 +104,7 @@
if ( parent == null )
{
- parent = pomUnmarshaller.parse( parentPom );
+ parent = pomUnmarshaller.parse( new FileReader( parentPom ) );
if ( parent != null )
{
1.3 +13 -11 maven-new/src/java/org/apache/maven/project/builder/ProjectBuilder.java
Index: ProjectBuilder.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/project/builder/ProjectBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProjectBuilder.java 16 Apr 2003 00:31:51 -0000 1.2
+++ ProjectBuilder.java 16 Apr 2003 12:39:28 -0000 1.3
@@ -14,6 +14,7 @@
*
* @param projectDescriptor
* @return
+ * @throws Exception
*/
Project build( File projectDescriptor )
throws Exception;
@@ -21,22 +22,23 @@
/**
*
* @param projectDescriptor
- * @param rootProject
+ * @param parent
* @return
* @throws Exception
*/
- Project build( File projectDescriptor, Project rootProject )
+ Project build( File projectDescriptor, Project parent )
throws Exception;
/**
*
* @param projectDescriptor
- * @param rootProject
+ * @param parent
* @param useParentPom
* @return
+ * @throws Exception
*/
Project build( File projectDescriptor,
- Project rootProject,
+ Project parent,
boolean useParentPom )
throws Exception;
@@ -44,13 +46,13 @@
*
* @param directory
* @param includes
- * @param rootProject
+ * @param parent
* @return
* @throws Exception
*/
public List build( File directory,
- String includes,
- Project rootProject )
+ String includes,
+ Project parent )
throws Exception;
/**
@@ -58,13 +60,13 @@
* @param directory
* @param includes
* @param excludes
- * @param rootProject
+ * @param parent
* @return
* @throws Exception
*/
public List build( File directory,
- String includes,
- String excludes,
- Project rootProject )
+ String includes,
+ String excludes,
+ Project parent )
throws Exception;
}
1.2 +20 -13 maven-new/src/java/org/apache/maven/verifier/DefaultLocalSettingsVerifier.java
Index: DefaultLocalSettingsVerifier.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/verifier/DefaultLocalSettingsVerifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLocalSettingsVerifier.java 15 Apr 2003 01:16:45 -0000 1.1
+++ DefaultLocalSettingsVerifier.java 16 Apr 2003 12:39:28 -0000 1.2
@@ -56,7 +56,10 @@
* ====================================================================
*/
-import org.apache.maven.project.Project;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.maven.Maven;
import org.apache.maven.util.I18NUtils;
import org.apache.plexus.logging.AbstractLogEnabled;
@@ -71,19 +74,25 @@
*/
public class DefaultLocalSettingsVerifier
extends AbstractLogEnabled
- implements LocalSettingsVerifier
+ implements Serviceable, LocalSettingsVerifier
{
- private Project project;
+ /** Maven. */
+ private Maven maven;
/** Default constructor. */
- public DefaultLocalSettingsVerifier( Project project )
+ public DefaultLocalSettingsVerifier()
{
- this.project = project;
}
- Project getProject()
+ // ----------------------------------------------------------------------
+ // Lifecylce Management
+ // ----------------------------------------------------------------------
+
+ /** @see Serviceable#service(ServiceManager) */
+ public void service( ServiceManager serviceManager )
+ throws ServiceException
{
- return project;
+ maven = (Maven) serviceManager.lookup( Maven.ROLE );
}
/**
@@ -92,20 +101,18 @@
* @throws RepoConfigException If an error occurs while trying to verify some basic
* maven settings.
*/
- public void verifyLocalRepository()
+ public void verify()
throws RepoConfigException
{
// Get local repo property.
- String localRepoProp = getProject().getMavenRepoLocal();
+ File localRepo = maven.getMavenRepoLocal();
- if ( localRepoProp == null )
+ if ( localRepo == null )
{
// This is not likely to happen any more as it defaults
// to ${maven.home}/repository which is set in the driver.properties
throw new RepoConfigException( I18NUtils.getMessage( "maven.repo.local.unset" ) );
}
-
- File localRepo = new File( localRepoProp );
if ( localRepo.exists() == false )
{
1.2 +5 -0 maven-new/src/java/org/apache/maven/verifier/LocalSettingsVerifier.java
Index: LocalSettingsVerifier.java
===================================================================
RCS file: /home/cvs/maven-new/src/java/org/apache/maven/verifier/LocalSettingsVerifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LocalSettingsVerifier.java 15 Apr 2003 01:16:44 -0000 1.1
+++ LocalSettingsVerifier.java 16 Apr 2003 12:39:28 -0000 1.2
@@ -2,5 +2,10 @@
public interface LocalSettingsVerifier
{
+ /** */
static String ROLE = LocalSettingsVerifier.class.getName();
+
+ void verify()
+ throws RepoConfigException;
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org