git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269153 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,91 +0,0 @@ | |||
| /* | |||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||
| * | |||
| * This software is published under the terms of the Apache Software License | |||
| * version 1.1, a copy of which has been included with this distribution in | |||
| * the LICENSE file. | |||
| */ | |||
| package org.apache.myrmidon.components.model; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| /** | |||
| * Default implementation of target. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public class DefaultTarget | |||
| implements Target | |||
| { | |||
| private final ArrayList m_dependencies = new ArrayList(); | |||
| private final ArrayList m_tasks = new ArrayList(); | |||
| private final Condition m_condition; | |||
| /** | |||
| * Constructor taking condition for target. | |||
| * | |||
| * @param condition the condition | |||
| */ | |||
| public DefaultTarget( final Condition condition ) | |||
| { | |||
| m_condition = condition; | |||
| } | |||
| /** | |||
| * Constructor for target with no condition. | |||
| */ | |||
| public DefaultTarget() | |||
| { | |||
| this( null ); | |||
| } | |||
| /** | |||
| * Get condition under which target is executed. | |||
| * | |||
| * @return the condition for target or null | |||
| */ | |||
| public Condition getCondition() | |||
| { | |||
| return m_condition; | |||
| } | |||
| /** | |||
| * Get dependencies of target | |||
| * | |||
| * @return the dependency list | |||
| */ | |||
| public String[] getDependencies() | |||
| { | |||
| return (String[])m_dependencies.toArray( new String[ 0 ] ); | |||
| } | |||
| /** | |||
| * Get tasks in target | |||
| * | |||
| * @return the target list | |||
| */ | |||
| public Configuration[] getTasks() | |||
| { | |||
| return (Configuration[])m_tasks.toArray( new Configuration[ 0 ] ); | |||
| } | |||
| /** | |||
| * Add a dependency to target. | |||
| * | |||
| * @param dependency the dependency | |||
| */ | |||
| public void addDependency( final String dependency ) | |||
| { | |||
| m_dependencies.add( dependency ); | |||
| } | |||
| /** | |||
| * Add task to target. | |||
| * | |||
| * @param taskConfiguration the task representation | |||
| */ | |||
| public void addTask( final Configuration taskData ) | |||
| { | |||
| m_tasks.add( taskData ); | |||
| } | |||
| } | |||
| @@ -7,39 +7,71 @@ | |||
| */ | |||
| package org.apache.myrmidon.components.model; | |||
| import org.apache.avalon.framework.component.Component; | |||
| import java.util.ArrayList; | |||
| import org.apache.avalon.framework.configuration.Configuration; | |||
| /** | |||
| * Interface to represent targets in build file. | |||
| * Targets in build file. | |||
| * | |||
| * @author <a href="mailto:donaldp@apache.org">Peter Donald</a> | |||
| */ | |||
| public interface Target | |||
| extends Component | |||
| public class Target | |||
| { | |||
| String ROLE = "org.apache.myrmidon.components.model.Target"; | |||
| private final ArrayList m_dependencies = new ArrayList(); | |||
| private final ArrayList m_tasks = new ArrayList(); | |||
| private final Condition m_condition; | |||
| /** | |||
| * Get dependencies of target | |||
| * Constructor taking condition for target. | |||
| * | |||
| * @return the dependency list | |||
| * @param condition the condition | |||
| */ | |||
| String[] getDependencies(); | |||
| public Target( final Condition condition, | |||
| final Configuration[] tasks, | |||
| final String[] dependencies ) | |||
| { | |||
| m_condition = condition; | |||
| for( int i = 0; i < tasks.length; i++ ) | |||
| { | |||
| m_tasks.add( tasks[ i ] ); | |||
| } | |||
| if( null != dependencies ) | |||
| { | |||
| for( int i = 0; i < dependencies.length; i++ ) | |||
| { | |||
| m_dependencies.add( dependencies[ i ] ); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Get tasks in target | |||
| * Get condition under which target is executed. | |||
| * | |||
| * @return the target list | |||
| * @return the condition for target or null | |||
| */ | |||
| Configuration[] getTasks(); | |||
| public final Condition getCondition() | |||
| { | |||
| return m_condition; | |||
| } | |||
| /** | |||
| * Get dependencies of target | |||
| * | |||
| * @return the dependency list | |||
| */ | |||
| public final String[] getDependencies() | |||
| { | |||
| return (String[])m_dependencies.toArray( new String[ 0 ] ); | |||
| } | |||
| /** | |||
| * Get condition under which target is executed. | |||
| * Get tasks in target | |||
| * | |||
| * @return the condition for target or null | |||
| * @return the target list | |||
| */ | |||
| Condition getCondition(); | |||
| public final Configuration[] getTasks() | |||
| { | |||
| return (Configuration[])m_tasks.toArray( new Configuration[ 0 ] ); | |||
| } | |||
| } | |||