ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/make primitive-tests.ant sample.ant
Date Tue, 15 Jan 2002 09:13:13 GMT
donaldp     02/01/15 01:13:13

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java Resources.properties
               proposal/myrmidon/src/make primitive-tests.ant sample.ant
  Log:
  Made the version attribute a required attribute of build file
  
  Revision  Changes    Path
  1.24      +52 -0     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- DefaultProjectBuilder.java	15 Jan 2002 08:50:59 -0000	1.23
  +++ DefaultProjectBuilder.java	15 Jan 2002 09:13:13 -0000	1.24
  @@ -15,8 +15,11 @@
   import javax.xml.parsers.SAXParserFactory;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.framework.CascadingException;
   import org.apache.avalon.framework.ExceptionUtil;
  +import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.myrmidon.components.model.DefaultProject;
  @@ -39,6 +42,8 @@
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultProjectBuilder.class );
   
  +    private final static Version VERSION = new Version( 2, 0, 0 );
  +
       private final static int PROJECT_REFERENCES = 0;
       private final static int LIBRARY_IMPORTS = 1;
       private final static int IMPLICIT_TASKS = 2;
  @@ -124,6 +129,14 @@
           //get project-level attributes
           final String baseDirectoryName = configuration.getAttribute( "basedir", null );
           final String defaultTarget = configuration.getAttribute( "default", "main" );
  +        final Version version = getVersion( configuration );
  +
  +        if( !VERSION.complies( version ) )
  +        {
  +            final String message =
  +                REZ.getString( "ant.bad-version.error", VERSION, version );
  +            throw new Exception( message );
  +        }
   
           //determine base directory for project.  Use the directory containing
           //the build file as the default.
  @@ -146,6 +159,45 @@
           project.setBaseDirectory( baseDirectory );
   
           return project;
  +    }
  +
  +    /**
  +     * Retrieve the version attribute from the specified configuration element.
  +     * Throw exceptions with meaningful errors if malformed or missing.
  +     */
  +    private Version getVersion( final Configuration configuration )
  +        throws CascadingException
  +    {
  +        try
  +        {
  +            final String versionString = configuration.getAttribute( "version" );
  +            return parseVersion( versionString );
  +        }
  +        catch( final ConfigurationException ce )
  +        {
  +            final String message = REZ.getString( "ant.version-missing.error" );
  +            throw new CascadingException( message, ce );
  +        }
  +    }
  +
  +    /**
  +     * Utility function to extract version
  +     */
  +    private Version parseVersion( final String versionString )
  +        throws CascadingException
  +    {
  +
  +        try
  +        {
  +            return Version.getVersion( versionString );
  +        }
  +        catch( final Exception e )
  +        {
  +            final String message =
  +                REZ.getString( "ant.malformed.version", versionString );
  +            getLogger().warn( message );
  +            throw new CascadingException( message, e );
  +        }
       }
   
       /**
  
  
  
  1.3       +3 -0      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/Resources.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.properties	19 Nov 2001 12:37:25 -0000	1.2
  +++ Resources.properties	15 Jan 2002 09:13:13 -0000	1.3
  @@ -23,3 +23,6 @@
   ant.target-bad-name.error=Target with an invalid name at {0}.
   ant.target-bad-logic.error=Discovered invalid target that has both a if and unless condition
at {0}.
   ant.target-bad-dependency.error=Discovered empty dependency in target {0} at {1}.
  +ant.malformed.version=Malformed version string "{0}" specified in version attribute of
project.
  +ant.version-missing.error=Missing version attribute from project.
  +ant.bad-version.error=Incompatible build file version detected. Expected {0} but found
{1}.
  
  
  
  1.7       +2 -3      jakarta-ant/proposal/myrmidon/src/make/primitive-tests.ant
  
  Index: primitive-tests.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/make/primitive-tests.ant,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- primitive-tests.ant	17 Dec 2001 09:16:31 -0000	1.6
  +++ primitive-tests.ant	15 Jan 2002 09:13:13 -0000	1.7
  @@ -14,7 +14,7 @@
   ==============================================================================
   -->
   
  -<project name="MySample" default="main" basedir=".">
  +<project version="2.0.0">
   
     <import library="selftest" />
   
  @@ -58,8 +58,7 @@
           float="1.0"
           float2="2.0"
           double="3.0"
  -        double2="4.0"
  -     />
  +        double2="4.0" />
   
       <sub-elements-test>
         <create-beep message="A string" />
  
  
  
  1.22      +1 -1      jakarta-ant/proposal/myrmidon/src/make/sample.ant
  
  Index: sample.ant
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/make/sample.ant,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- sample.ant	14 Jan 2002 09:30:17 -0000	1.21
  +++ sample.ant	15 Jan 2002 09:13:13 -0000	1.22
  @@ -14,7 +14,7 @@
   ==============================================================================
   -->
   
  -<project name="MySample" default="main" basedir=".">
  +<project version="2.0.0">
   
     <projectref name="prim" location="primitive-tests.ant" />
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message