ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Darrell DeBoer <darr...@apache.org>
Subject Re: cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/workspace DefaultWorkspace.java
Date Tue, 11 Jun 2002 05:41:22 GMT
Note: Ant1CompatTargetTask has an undeclared dependency on the "project" 
antlib, and won't work outside of the test suite until the common stuff is 
refactored into framework. But, since Myrmidon won't run at all at the moment 
(for me, anyhow), I don't feel too guilty! ;)

On Tue, 11 Jun 2002 15:30, darrell@apache.org wrote:
> darrell     2002/06/10 22:30:47
>
>   Modified:    ant1compat project.xml
>                ant1compat/src/conf ant-descriptor.xml
>                ant1compat/src/test/org/apache/tools/ant/test
>                         Ant1CompatTestCase.java if-unless-test.xml
>                antlib/src/java/org/apache/antlib/project TargetTask.java
>                container/src/java/org/apache/myrmidon/components/builder
>                         ConvertingProjectBuilder.java
>                         DefaultProjectBuilder.java
>                container/src/java/org/apache/myrmidon/components/workspace
>                         DefaultWorkspace.java
>   Log:
>   * Added Ant1CompatTargetTask, which provides Ant1 style handling of
> <target> elements, by processing "if" and "unless" attributes as per Ant1.
>
>   * Implicit target is now of type "simple-target", and is executed
> directly by DefaultWorkspace, rather than by TargetTask. TargetTask now has
> no knowledge of the "<init>" target name.
>
>   * ConvertingProjectBuilder no longer has add "magic" <if> tasks to
> replicate Ant1 target behaviour.
>
>   Revision  Changes    Path
>   1.11      +1 -0      jakarta-ant-myrmidon/ant1compat/project.xml
>
>   Index: project.xml
>   ===================================================================
>   RCS file: /home/cvs/jakarta-ant-myrmidon/ant1compat/project.xml,v
>   retrieving revision 1.10
>   retrieving revision 1.11
>   diff -u -r1.10 -r1.11
>   --- project.xml	4 Jun 2002 12:47:51 -0000	1.10
>   +++ project.xml	11 Jun 2002 05:30:47 -0000	1.11
>   @@ -9,6 +9,7 @@
>        <classpath>
>            <fileset dir="../api/build/lib" includes="*.jar"/>
>            <fileset dir="../aut/build/lib" includes="*.jar"/>
>   +        <fileset dir="../antlib/build/lib" includes="*.jar"/>
>            <fileset dir="../framework/build/lib" includes="*.jar"/>
>            <fileset dir="../lib" includes="*.jar"/>
>        </classpath>
>
>
>
>   1.3       +4 -0     
> jakarta-ant-myrmidon/ant1compat/src/conf/ant-descriptor.xml
>
>   Index: ant-descriptor.xml
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/ant1compat/src/conf/ant-descriptor.xml,v
> retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- ant-descriptor.xml	8 May 2002 13:40:21 -0000	1.2
>   +++ ant-descriptor.xml	11 Jun 2002 05:30:47 -0000	1.3
>   @@ -1,6 +1,10 @@
>    <ant-lib version="1.0">
>
>        <types>
>   +        <!-- Target task -->
>   +        <task name="target"
>   +            classname="org.apache.tools.ant.Ant1CompatTargetTask"/>
>   +
>            <!-- Type instance tasks -->
>            <task name="path"
>                classname="org.apache.tools.ant.Ant1CompatTypeInstanceTask"
> />
>
>
>
>   1.5       +20 -6    
> jakarta-ant-myrmidon/ant1compat/src/test/org/apache/tools/ant/test/Ant1Comp
>atTestCase.java
>
>   Index: Ant1CompatTestCase.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/ant1compat/src/test/org/apache/tools/ant/tes
>t/Ant1CompatTestCase.java,v retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- Ant1CompatTestCase.java	29 May 2002 06:13:21 -0000	1.4
>   +++ Ant1CompatTestCase.java	11 Jun 2002 05:30:47 -0000	1.5
>   @@ -52,19 +52,33 @@
>            LogMessageTracker tracker = new LogMessageTracker( LogLevel.WARN
> );
>
>            // Should pass if for "set", "true" and "false"
>   -        tracker.addExpectedMessage(
> "/if-unless-test/if-set-test/if/echo", "Ran target: if-set-test" ); -      
>  tracker.addExpectedMessage( "/if-unless-test/if-true-test/if/echo", "Ran
> target: if-true-test" ); -        tracker.addExpectedMessage(
> "/if-unless-test/if-false-test/if/echo", "Ran target: if-false-test" ); +  
>      tracker.addExpectedMessage( "/if-unless-test/if-set-test/echo", "Ran
> target: if-set-test" ); +        tracker.addExpectedMessage(
> "/if-unless-test/if-true-test/echo", "Ran target: if-true-test" ); +       
> tracker.addExpectedMessage( "/if-unless-test/if-false-test/echo", "Ran
> target: if-false-test" );
>
>            // Should only pass unless, when not defined.
>   -        tracker.addExpectedMessage(
> "/if-unless-test/unless-unset-test/if/echo", +       
> tracker.addExpectedMessage( "/if-unless-test/unless-unset-test/echo", "Ran
> target: unless-unset-test" );
>
>            // If combined with unless on a single target.
>   -        tracker.addExpectedMessage(
> "/if-unless-test/if-with-unless-test-1/if/echo", +       
> tracker.addExpectedMessage( "/if-unless-test/if-with-unless-test-1/echo",
> "Ran target: if-with-unless-test-1" );
>
>            executeTarget( projectFile, "if-unless-tests", tracker );
>   +    }
>   +
>   +    public void testIfUnlessCalledTarget() throws Exception
>   +    {
>   +        // Process a single target with if and unless, to make
>   +        // sure that this works for the directly called target.
>   +        final File projectFile = getTestResource( "if-unless-test.xml"
> ); +
>   +        // if/unless tests.
>   +        LogMessageTracker tracker = new LogMessageTracker( LogLevel.WARN
> ); +        tracker.addExpectedMessage(
> "/if-unless-test/if-unless-test-single-target/echo", +                     
>               "Ran target: if-unless-test-single-target" ); +
>   +        executeTarget( projectFile, "if-unless-test-single-target" );
>        }
>
>        public void testAntTask() throws Exception
>
>
>
>   1.2       +5 -0     
> jakarta-ant-myrmidon/ant1compat/src/test/org/apache/tools/ant/test/if-unles
>s-test.xml
>
>   Index: if-unless-test.xml
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/ant1compat/src/test/org/apache/tools/ant/tes
>t/if-unless-test.xml,v retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- if-unless-test.xml	14 Apr 2002 12:38:41 -0000	1.1
>   +++ if-unless-test.xml	11 Jun 2002 05:30:47 -0000	1.2
>   @@ -59,4 +59,9 @@
>        <target name="if-with-unless-test-3" if="prop-set"
> unless="prop-set"> <echo message="Ran target: if-with-unless-test-3"/>
>        </target>
>   +
>   +    <target name="if-unless-test-single-target" depends="setup-props"
>   +            if="prop-set" unless="prop-unset">
>   +        <echo message="Ran target: if-unless-test-single-target"/>
>   +    </target>
>    </project>
>
>
>
>   1.13      +2 -16    
> jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/TargetTask.j
>ava
>
>   Index: TargetTask.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/antlib/src/java/org/apache/antlib/project/Ta
>rgetTask.java,v retrieving revision 1.12
>   retrieving revision 1.13
>   diff -u -r1.12 -r1.13
>   --- TargetTask.java	11 Jun 2002 03:59:48 -0000	1.12
>   +++ TargetTask.java	11 Jun 2002 05:30:47 -0000	1.13
>   @@ -29,8 +29,6 @@
>        private static final Resources REZ =
>            ResourceManager.getPackageResources( TargetTask.class );
>
>   -    private static final String IMPLICIT_TARGET_NAME = "<init>";
>   -
>        /**
>         * The array of ordered tasks which are contained
>         * withing Target.
>   @@ -118,12 +116,6 @@
>                throw new TaskException( message );
>            }
>
>   -        //Add in special case for "init" target.
>   -        if( IMPLICIT_TARGET_NAME.equals( m_name ) )
>   -        {
>   -            return;
>   -        }
>   -
>            final NameValidatorManager validatorManager =
>                (NameValidatorManager)getService( NameValidatorManager.class
> ); try
>   @@ -147,12 +139,6 @@
>        private void executeDependencies()
>            throws TaskException
>        {
>   -        // Execute implicit target first
>   -        if( ! m_name.equals( IMPLICIT_TARGET_NAME ) )
>   -        {
>   -            executeDependency( new Dependency( null,
> IMPLICIT_TARGET_NAME ) ); -        }
>   -
>            if( null != m_dependencies )
>            {
>                for( int i = 0; i < m_dependencies.length; i++ )
>   @@ -167,7 +153,7 @@
>         *
>         * @throws TaskException if theres an eror executing contained
> tasks. */
>   -    private void executeContainedTasks()
>   +    protected void executeContainedTasks()
>            throws TaskException
>        {
>            final ModelElement[] tasks =
>
>
>
>   1.13      +6 -54    
> jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/buil
>der/ConvertingProjectBuilder.java
>
>   Index: ConvertingProjectBuilder.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/compo
>nents/builder/ConvertingProjectBuilder.java,v retrieving revision 1.12
>   retrieving revision 1.13
>   diff -u -r1.12 -r1.13
>   --- ConvertingProjectBuilder.java	8 Jun 2002 23:56:04 -0000	1.12
>   +++ ConvertingProjectBuilder.java	11 Jun 2002 05:30:47 -0000	1.13
>   @@ -39,19 +39,15 @@
>            // Put a new version attribute.
>            model.setAttribute( VERSION_ATTRIBUTE, "2.0" );
>
>   -        // Convert the child <target> elements, and move all the non
> <target> -        // elements
>   +        // Move all the non <target> elements (implicit target) to
> before +        // any <target> elements.
>            final ModelElement[] children = model.getChildren();
>            int insertPos = 0;
>            for( int i = 0; i < children.length; i++ )
>            {
>                final ModelElement child = children[ i ];
>
>   -            if( child.getName().equals( "target" ) )
>   -            {
>   -                convertTarget( child );
>   -            }
>   -            else
>   +            if( ! child.getName().equals( "target" ) )
>                {
>                    if( i > insertPos )
>                    {
>   @@ -62,55 +58,11 @@
>                }
>            }
>
>   -        // Add an "import" task for the ant1 tasks
>   +        // Add an "import" task for the ant1 tasks - this is the first
>   +        // Task in the implicit target.
>            final ModelElement typelibDeclaration =
>                new ModelElement( "import", model.getLocation() );
>            typelibDeclaration.setAttribute( "library", "ant1" );
>            model.addChild( 0, typelibDeclaration );
>   -    }
>   -
>   -    /**
>   -     * Converts an Ant1 target into a Myrmidon version.
>   -     * @param target The target to convert
>   -     */
>   -    private void convertTarget( final ModelElement target )
>   -    {
>   -        final String ifAttrib = target.getAttribute( "if" );
>   -        final String unlessAttrib = target.getAttribute( "unless" );
>   -
>   -        if( ifAttrib == null && unlessAttrib == null )
>   -        {
>   -            // Don't need to do anything
>   -            return;
>   -        }
>   -
>   -        target.setAttribute( "if", null );
>   -        target.setAttribute( "unless", null );
>   -
>   -        // Wrap the children of the target in an <if> task
>   -        final ModelElement ifTask = new ModelElement( "if",
> target.getLocation() ); -        final ModelElement condition = new
> ModelElement( "condition", target.getLocation() ); -       
> ifTask.addChild( condition );
>   -        ifTask.addChildren( target.getChildren() );
>   -        ifTask.setContent( target.getContent() );
>   -        target.removeChildren();
>   -        target.addChild( ifTask );
>   -
>   -        if( ifAttrib != null )
>   -        {
>   -            // Add an <is-set> test
>   -            final ModelElement test = new ModelElement( "is-set",
> target.getLocation() ); -            test.setAttribute( "property",
> ifAttrib );
>   -            condition.addChild( test );
>   -        }
>   -        if( unlessAttrib != null )
>   -        {
>   -            // Add a ! <is-set> test
>   -            final ModelElement test = new ModelElement( "is-set",
> target.getLocation() ); -            test.setAttribute( "property",
> unlessAttrib );
>   -            final ModelElement not = new ModelElement( "not",
> target.getLocation() ); -            not.addChild( test );
>   -            condition.addChild( not );
>   -        }
>        }
>    }
>
>
>
>   1.75      +2 -2     
> jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/buil
>der/DefaultProjectBuilder.java
>
>   Index: DefaultProjectBuilder.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/compo
>nents/builder/DefaultProjectBuilder.java,v retrieving revision 1.74
>   retrieving revision 1.75
>   diff -u -r1.74 -r1.75
>   --- DefaultProjectBuilder.java	11 Jun 2002 04:47:09 -0000	1.74
>   +++ DefaultProjectBuilder.java	11 Jun 2002 05:30:47 -0000	1.75
>   @@ -341,7 +341,7 @@
>                                           final List targets )
>            throws Exception
>        {
>   -        final ModelElement implicit = new ModelElement( "target",
> model.getLocation() ); +        final ModelElement implicit = new
> ModelElement( "simple-target", model.getLocation() );
> implicit.setAttribute( "name", Project.IMPLICIT_TARGET_NAME );
>
>            final ModelElement[] children = model.getChildren();
>
>
>
>   1.81      +9 -2     
> jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/work
>space/DefaultWorkspace.java
>
>   Index: DefaultWorkspace.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/compo
>nents/workspace/DefaultWorkspace.java,v retrieving revision 1.80
>   retrieving revision 1.81
>   diff -u -r1.80 -r1.81
>   --- DefaultWorkspace.java	11 Jun 2002 04:47:09 -0000	1.80
>   +++ DefaultWorkspace.java	11 Jun 2002 05:30:47 -0000	1.81
>   @@ -78,6 +78,13 @@
>        {
>            final ProjectEntry entry = getProjectEntry( descriptor );
>            final Project project = entry.getProject();
>   +
>   +        // First execute the implicit target.
>   +        Target implicitTarget =
>   +            project.getTarget( Project.IMPLICIT_TARGET_NAME );
>   +        executeTarget( entry, implicitTarget );
>   +
>   +        // Now execute the called target.
>            Target target = project.getTarget( targetName );
>            if( null == target )
>            {
>   @@ -242,7 +249,7 @@
>
>        /**
>         * Executes a target.  Does not execute the target if it has already
> been -     * executed.  Executes the dependencies of the target, before
> executing +     * executed.  Executes the implicit target, before executing
> * the target itself.
>         *
>         * @param target the target

-- 
ciao,
Daz

--
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