Author: mcconnell Date: Thu Jun 3 18:26:43 2004 New Revision: 20799 Added: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Organization.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java Removed: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/project/ProjectTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeliverableTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/HomeTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/TestTask.java Modified: avalon/trunk/tools/project/core/build.xml avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/event/StandardListener.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/project/Info.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java avalon/trunk/tools/project/core/src/test/index.xml avalon/trunk/tools/project/core/src/test/projects/demo/build.xml avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml avalon/trunk/tools/project/core/src/test/projects/sample/build.xml avalon/trunk/tools/project/core/src/test/projects/widget/build.xml Log: Initial steps to support better integration of task/target/resource notions in ant with the project task set. Still a work-in-progress.
Modified: avalon/trunk/tools/project/core/build.xml ============================================================================== --- avalon/trunk/tools/project/core/build.xml (original) +++ avalon/trunk/tools/project/core/build.xml Thu Jun 3 18:26:43 2004 @@ -64,6 +64,8 @@ <ant dir="${target.test.dir}/projects/widget" /> <ant dir="${target.test.dir}/projects/demo" /> <ant dir="${target.test.dir}/projects/sample" /> + <!-- + --> </target> <target name="clean"> Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml Thu Jun 3 18:26:43 2004 @@ -1,14 +1,16 @@ <?xml version="1.0"?> <antlib xmlns:current="ant:current"> - <taskdef name="project" classname="org.apache.avalon.tools.project.ProjectTask"/> - <typedef name="home" classname="org.apache.avalon.tools.home.Home"/> - <taskdef name="prepare" classname="org.apache.avalon.tools.tasks.PrepareTask"/> + + <taskdef name="home" classname="org.apache.avalon.tools.home.Home"/> + <taskdef name="clean" classname="org.apache.avalon.tools.tasks.CleanTask"/> - <taskdef name="javac" classname="org.apache.avalon.tools.tasks.JavacTask"/> - <taskdef name="jar" classname="org.apache.avalon.tools.tasks.JarTask"/> - <taskdef name="test" classname="org.apache.avalon.tools.tasks.TestTask"/> + <taskdef name="prepare" classname="org.apache.avalon.tools.tasks.PrepareTask"/> + <taskdef name="javac" classname="org.apache.avalon.tools.tasks.JavacTask"/> + <taskdef name="jar" classname="org.apache.avalon.tools.tasks.JarTask"/> + <taskdef name="junit" classname="org.apache.avalon.tools.tasks.JUnitTestTask"/> <taskdef name="declare" classname="org.apache.avalon.tools.tasks.DeclareTask"/> - <taskdef name="plugin" classname="org.apache.avalon.tools.tasks.PluginTask"/> <taskdef name="install" classname="org.apache.avalon.tools.tasks.InstallTask"/> + <taskdef name="plugin" classname="org.apache.avalon.tools.tasks.PluginTask"/> <taskdef name="xdoc" classname="org.apache.avalon.tools.tasks.XdocTask"/> -</antlib> + +</antlib> Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/event/StandardListener.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/event/StandardListener.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/event/StandardListener.java Thu Jun 3 18:26:43 2004 @@ -48,11 +48,15 @@ private Definition m_definition; private Task m_task; + public StandardListener( Home home, Definition definition ) + { + this( null, home, definition ); + } + public StandardListener( Task task, Home home, Definition definition ) { m_home = home; m_definition = definition; - m_task = task; } /** @@ -67,8 +71,8 @@ Project project = event.getProject(); project.log( "" ); project.log( BANNER ); - getTask().log( "project: " + getDefinition() ); - getTask().log( "basedir: " + project.getBaseDir() ); + project.log( "project: " + getDefinition() ); + project.log( "basedir: " + project.getBaseDir() ); project.log( BANNER ); /* Added: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java ============================================================================== --- (empty file) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java Thu Jun 3 18:26:43 2004 @@ -0,0 +1,274 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.tools.home; + +import java.io.File; +import java.util.Hashtable; +import java.util.Map; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Property; + +/** + * Organization descriptor. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ + */ +public class Context +{ + public static final String KEY = "project.context"; + public static final String HOME_KEY = "project.home"; + + public static final String SRC_KEY = "project.src"; + public static final String SRC_VALUE = "src"; + + public static final String SRC_MAIN_KEY = "project.src.main"; + public static final String SRC_MAIN_VALUE = "main"; + + public static final String SRC_CONFIG_KEY = "project.src.config"; + public static final String SRC_CONFIG_VALUE = "config"; + + public static final String SRC_TEST_KEY = "project.src.test"; + public static final String SRC_TEST_VALUE = "test"; + + public static final String TARGET_KEY = "project.target"; + public static final String TARGET_VALUE = "target"; + + private static final String USER_PROPERTIES = "user.properties"; + private static final String BUILD_PROPERTIES = "build.properties"; + + public static final String DELIVERABLES_KEY = "project.target.deliverables"; + private static final String DELIVERABLES_VALUE = "deliverables"; + + public static final String TEMP_KEY = "project.target.temp"; + private static final String TEMP_VALUE = "temp"; + + public static final String DOCS_KEY = "project.target.docs"; + private static final String DOCS_VALUE = "docs"; + + public static Context getContext( Project project ) + { + return getContext( project, null ); + } + + public static Context getContext( Project project, File home ) + { + Context context = (Context) project.getReference( KEY ); + if( null == context ) + { + context = new Context( project, home ); + project.addReference( KEY, context ); + } + return context; + } + + private final File m_home; + + private final File m_src; + private final File m_target; + private final File m_deliverables; + private final File m_temp; + private final File m_docs; + + private final Map m_map = new Hashtable(); + private final Map m_resources = new Hashtable(); + + private Context( Project project, File home ) + { + setupProperties( project ); + + project.setNewProperty( SRC_KEY, SRC_VALUE ); + project.setNewProperty( SRC_MAIN_KEY, SRC_MAIN_VALUE ); + project.setNewProperty( SRC_CONFIG_KEY, SRC_CONFIG_VALUE ); + project.setNewProperty( SRC_TEST_KEY, SRC_TEST_VALUE ); + project.setNewProperty( DELIVERABLES_KEY, DELIVERABLES_VALUE ); + project.setNewProperty( TARGET_KEY, TARGET_VALUE ); + project.setNewProperty( DOCS_KEY, DOCS_VALUE ); + project.setNewProperty( TEMP_KEY, TEMP_VALUE ); + + File basedir = project.getBaseDir(); + String src = project.getProperty( SRC_KEY ); + String target = project.getProperty( TARGET_KEY ); + String temp = project.getProperty( TEMP_KEY ); + String docs = project.getProperty( DOCS_KEY ); + String deliverables = project.getProperty( DELIVERABLES_KEY ); + + m_src = setupSrc( basedir, src ); + m_target = setupTarget( basedir, target ); + if( null == home ) + { + String path = project.getProperty( HOME_KEY ); + if( null == path ) + { + //final String error = + // "Missing 'project.home' declaration."; + //project.log( error ); + m_home = null; + } + else + { + m_home = new File( basedir, path ); + } + } + else + { + m_home = home; + } + + m_deliverables = + setBuildPath( DELIVERABLES_KEY, deliverables ); + m_temp = + setBuildPath( TEMP_KEY, temp ); + m_docs = + setBuildPath( DOCS_KEY, docs ); + } + + //public File getHomeDirectory() + //{ + // return m_home; + //} + + public File getSrcDirectory() + { + return m_src; + } + + public File getTargetDirectory() + { + return m_target; + } + + public File getDeliverablesDirectory() + { + return m_deliverables; + } + + public File getTempDirectory() + { + return m_temp; + } + + public File getDocsDirectory() + { + return m_docs; + } + + + public File setBuildPath( String key, String path ) + { + if( null == key ) + { + throw new NullPointerException( "key" ); + } + if( null == path ) + { + throw new NullPointerException( "null path for key: " + key ); + } + if( m_map.containsKey( key ) ) + { + final String error = + "Duplicate path registration request for key '" + + key + "'."; + throw new BuildException( error ); + } + File build = getFile( m_target, path ); + m_map.put( key, build ); + return build; + } + + public File getBuildPath( String key ) + { + return getBuildPath( key, true ); + } + + public File getBuildPath( String key, boolean fail ) + { + if( m_map.containsKey( key ) ) + { + return (File) m_map.get( key ) ; + } + else if( fail ) + { + final String error = + "Unknown build key '" + + key + "'."; + throw new BuildException( error ); + } + else + { + return null; + } + } + + public File getTargetDirectory( String path ) + { + return new File( m_target, path ); + } + + private File setupSrc( File basedir, String path ) + { + if( null == path ) return new File( basedir, SRC_VALUE ); + return new File( basedir, path ); + } + + private File setupTarget( File basedir, String path ) + { + if( null == path ) return new File( basedir, TARGET_VALUE ); + return new File( basedir, path ); + } + + private void setupProperties( Project project ) + { + File basedir = project.getBaseDir(); + setupUserProperties( project, basedir ); + setupBuildProperties( project, basedir ); + } + + private void setupUserProperties( Project project, File basedir ) + { + File user = new File( basedir, USER_PROPERTIES ); + readProperties( project, user ); + } + + private void setupBuildProperties( Project project, File basedir ) + { + File build = new File( basedir, BUILD_PROPERTIES ); + readProperties( project, build ); + } + + private void readProperties( Project project, File file ) throws BuildException + { + Property props = (Property) project.createTask( "property" ); + props.setFile( file ); + props.init(); + props.execute(); + } + + private File getFile( File root, String path ) + { + File file = new File( path ); + if( file.isAbsolute() ) return file; + if( null == root ) + { + throw new NullPointerException( "root" ); + } + return new File( root, path ); + } +} Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java Thu Jun 3 18:26:43 2004 @@ -25,6 +25,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.ProjectComponent; @@ -33,6 +34,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.DataType; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.taskdefs.Sequential; import org.apache.tools.ant.taskdefs.Property; @@ -45,6 +47,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import org.apache.avalon.tools.event.StandardListener; import org.apache.avalon.tools.project.Definition; import org.apache.avalon.tools.project.ProjectRef; import org.apache.avalon.tools.project.ResourceRef; @@ -59,21 +62,27 @@ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class Home +public class Home extends Sequential { - private static Home HOME; + //------------------------------------------------------------- + // static immutable + //------------------------------------------------------------- - public static boolean isInitialized() - { - return null != HOME; - } + //private static Home HOME; - public static void initialize( Project project, File index ) + //------------------------------------------------------------- + // static operations + //------------------------------------------------------------- + + /* + public static Home initialize( Task task, File index ) { - if( !isInitialized() ) + Project project = task.getProject(); + if( null == HOME ) { try { + task.log( "index: " + index, Project.MSG_INFO ); HOME = new Home( project, index ); } catch( Throwable e ) @@ -81,103 +90,114 @@ throw new BuildException( e ); } } + setHomeReference( project ); + return HOME; } - public static Home getHome( Project project ) + public static Home getHome() { - if( !isInitialized() ) - { - final String error = - "Home has not been initialized."; - throw new BuildException( error ); - } - project.addReference( "urn:avalon.home", HOME ); return HOME; } + */ - private final Project m_project; - private final Repository m_repository; - private final File m_home; - private final File m_file; + //------------------------------------------------------------- + // immutable state + //------------------------------------------------------------- + + private String m_key; + + private Project m_project; + private Repository m_repository; + private File m_home; + private File m_file; private final Hashtable m_resources = new Hashtable(); + private Definition m_definition; + private BuildListener m_listener; + + //------------------------------------------------------------- + // constructor + //------------------------------------------------------------- - public Home( Project project, File file ) + public Home( Project project ) { - m_file = file; + super(); m_project = project; - m_home = file.getParentFile(); + } + + //private Home( Project project, File file ) + //{ + // init( project, file ); + //} + + //------------------------------------------------------------- + // setters + //------------------------------------------------------------- + + public void setIndex( File file ) throws BuildException + { + m_file = file; + } - HOME = this; + public void setKey( String key ) + { + m_key = key; + } + + //------------------------------------------------------------- + // internal + //------------------------------------------------------------- + + public void execute() + { + //m_file = file; + //m_project = project; + m_home = m_file.getParentFile(); + + //HOME = this; - Element root = ElementHelper.getRootElement( file ); - project.log( "home: " + m_home, Project.MSG_DEBUG ); + Element root = ElementHelper.getRootElement( m_file ); + m_project.log( "home: " + m_home, Project.MSG_DEBUG ); final Element repo = ElementHelper.getChild( root, "repository" ); final Element resources = ElementHelper.getChild( root, "resources" ); final Element projects = ElementHelper.getChild( root, "projects" ); // - // construct the repository + // construct the repository, build the definition of the available + // resources and projects used within the system and associate a build + // listener // m_repository = createRepository( repo ); - - // - // build the definition of the available resources - // used within the system - // - buildResourceList( resources ); + buildProjectList( projects ); - // - // build the definition of the available projects - // used within the system - // + final String key = getKey(); + m_definition = getDefinition( key, false ); - buildProjectList( projects ); + m_listener = new StandardListener( this, m_definition ); + + super.execute(); } - private void buildResourceList( Element resources ) + private String getKey() { - if( null == resources ) return; - - Element[] resourceArray = ElementHelper.getChildren( resources, "resource" ); - m_project.log( "resources: " + resourceArray.length, Project.MSG_DEBUG ); - for( int i=0; i<resourceArray.length; i++ ) + if( null != m_key ) { - Element child = resourceArray[i]; - Resource resource = XMLDefinitionBuilder.createResource( this, child ); - String key = resource.getKey(); - m_resources.put( key, resource ); - m_project.log( - "resource: " + resource + " key=" + key, - Project.MSG_DEBUG ); + return m_key; } - } - - private void buildProjectList( Element projects ) - { - if( null == projects ) return; - - Element[] entries = ElementHelper.getChildren( projects ); - m_project.log( - "projects: " + entries.length, - Project.MSG_DEBUG ); - for( int i=0; i<entries.length; i++ ) + else { - Element element = entries[i]; - Definition definition = - XMLDefinitionBuilder.createDefinition( this, element, m_home ); - String key = definition.getKey(); - m_resources.put( key, definition ); - m_project.log( - "project: " + definition + " key=" + key, - Project.MSG_DEBUG ); + return getProject().getName(); } } + //------------------------------------------------------------- + // implementation + //------------------------------------------------------------- + public File getHomeDirectory() { return m_home; @@ -204,6 +224,11 @@ return (Plugin) getDefinition( ref ); } + public Definition getDefinition() + { + return m_definition; + } + public Definition getDefinition( ProjectRef ref ) throws BuildException { @@ -227,20 +252,39 @@ public Definition getDefinition( String key ) throws BuildException { + return getDefinition( key, true ); + } + + public Definition getDefinition( String key, boolean fail ) + throws BuildException + { Resource def = (Resource) m_resources.get( key ); if( null == def ) { - final String error = - "Unknown definition [" + key + "]"; - throw new BuildException( error ); + if( fail ) + { + final String error = + "Unknown definition [" + key + "]"; + throw new BuildException( error ); + } } - if( !( def instanceof Definition ) ) + else { - final String error = - "Key [" + key + "] is not project."; - throw new BuildException( error ); + if( def instanceof Definition ) + { + return (Definition) def; + } + else + { + if( fail ) + { + final String error = + "Key [" + key + "] is not project."; + throw new BuildException( error ); + } + } } - return (Definition) def; + return null; } public void build( Definition definition ) @@ -268,6 +312,10 @@ return (Definition[]) targets.toArray( new Definition[0] ); } + //------------------------------------------------------------- + // internal + //------------------------------------------------------------- + private void getBuildSequence( List visited, List targets, Definition definition ) { if( visited.contains( definition ) ) return; @@ -294,6 +342,45 @@ } } + private void buildResourceList( Element resources ) + { + if( null == resources ) return; + + Element[] resourceArray = ElementHelper.getChildren( resources, "resource" ); + m_project.log( "resources: " + resourceArray.length, Project.MSG_DEBUG ); + for( int i=0; i<resourceArray.length; i++ ) + { + Element child = resourceArray[i]; + Resource resource = XMLDefinitionBuilder.createResource( this, child ); + String key = resource.getKey(); + m_resources.put( key, resource ); + m_project.log( + "resource: " + resource + " key=" + key, + Project.MSG_DEBUG ); + } + } + + private void buildProjectList( Element projects ) + { + if( null == projects ) return; + + Element[] entries = ElementHelper.getChildren( projects ); + m_project.log( + "projects: " + entries.length, + Project.MSG_DEBUG ); + for( int i=0; i<entries.length; i++ ) + { + Element element = entries[i]; + Definition definition = + XMLDefinitionBuilder.createDefinition( this, element, m_home ); + String key = definition.getKey(); + m_resources.put( key, definition ); + m_project.log( + "project: " + definition + " key=" + key, + Project.MSG_DEBUG ); + } + } + private Repository createRepository( Element repo ) { Repository repository = new Repository( this, repo ); @@ -307,4 +394,14 @@ return repository; } + /* + private static void setHomeReference( Project project ) + { + if( null == HOME ) throw new IllegalStateException( "home" ); + if( null == project.getReference( "urn:project.home" ) ) + { + project.addReference( "urn:project.home", HOME ); + } + } + */ } Added: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Organization.java ============================================================================== --- (empty file) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Organization.java Thu Jun 3 18:26:43 2004 @@ -0,0 +1,74 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.tools.home; + + +/** + * Organization descriptor. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ + */ +public class Organization +{ + private final String m_key; + + private final String m_name; + + private final int m_inception; + + public Organization( String key, String name, int year ) + { + m_inception = year; + m_key = getKey( key ); + m_name = getName( name ); + } + + public String getKey() + { + return m_key; + } + + public String getName() + { + return m_name; + } + + public int getInceptionYear() + { + return m_inception; + } + + private String getKey( String key ) + { + if( null == key ) + { + return "unknown"; + } + return key; + } + + private String getName( String name ) + { + if( null == name ) + { + return "unknown"; + } + return name; + } +} Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/project/Info.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/project/Info.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/project/Info.java Thu Jun 3 18:26:43 2004 @@ -27,7 +27,22 @@ */ public class Info { - public static Info create( String id, String type ) + public static Info create( String id ) + { + int i = id.indexOf( ":" ); + if( i<0 ) + { + final String error = + "Missing protocol in id [" + id + "]"; + throw new BuildException( error ); + } + String protocol = id.substring( 0, i ); + String spec = id.substring( i+1 ); + return Info.create( protocol, spec); + } + + + public static Info create( String type, String id ) { int n = getGroupIndex( id ); String group = getGroupFromId( id, n ); @@ -92,14 +107,7 @@ buffer.append( getVersion() ); } buffer.append( "." ); - if( getType().equals( "plugin" ) ) - { - buffer.append( "jar" ); - } - else - { - buffer.append( getType() ); - } + buffer.append( getType() ); return buffer.toString(); } Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java Thu Jun 3 18:26:43 2004 @@ -19,22 +19,38 @@ import java.io.File; +import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Delete; +import org.apache.avalon.tools.home.Context; + /** - * Cleanup the target directory. + * Load a goal. * * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class CleanTask extends PrepareTask +public class CleanTask extends Task { + private Context m_context; + private boolean m_init = false; + + public void init() throws BuildException + { + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + m_init = true; + } + } + public void execute() throws BuildException { + File target = m_context.getTargetDirectory(); Project project = getProject(); - File target = PrepareTask.getTargetDirectory( project ); Delete delete = (Delete) project.createTask( "delete" ); delete.setDir( target ); delete.init(); Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java Thu Jun 3 18:26:43 2004 @@ -27,8 +27,10 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.Mkdir; import org.apache.avalon.tools.home.Home; +import org.apache.avalon.tools.home.Context; import org.apache.avalon.tools.project.Definition; import org.apache.avalon.tools.project.Resource; import org.apache.avalon.tools.project.ResourceRef; @@ -38,24 +40,66 @@ import org.apache.avalon.tools.project.Plugin.TaskDef; /** - * Load a plugin. + * Load a plugin. * * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class DeclareTask extends DeliverableTask +public class DeclareTask extends Task { - private static final String FILENAME = "plugin.xml"; + private static final String TYPE = "plugin"; + + private boolean m_init = false; + private Context m_context; + private Home m_home; + + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) + { + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) + { + m_home = (Home) object; + } + else + { + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); + } + } public void init() throws BuildException { - super.init(); + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + m_init = true; + } } public void execute() throws BuildException { + if( null == m_home ) + { + final String error = + "Required system home 'refid' attribute not set in the task definition [" + + getTaskName() + "]."; + throw new BuildException( error ); + } + log( "creating plugin declaration" ); - final Definition def = getDefinition(); + final Definition def = m_home.getDefinition(); try { @@ -80,11 +124,11 @@ private File getPluginFile() { - Project project = getProject(); - File dir = DeliverableTask.getTargetDeliverablesDirectory( project ); - File ants = new File( dir, "ants" ); - createDirectory( ants ); - Definition def = getDefinition(); + File dir = m_context.getDeliverablesDirectory(); + File ants = new File( dir, TYPE + "s" ); + mkDir( ants ); + + Definition def = m_home.getDefinition(); Info info = def.getInfo(); String filename = getFilename( info ); return new File( ants, filename ); @@ -95,11 +139,11 @@ String version = info.getVersion(); if( null == version ) { - return info.getName() + ".ant"; + return info.getName() + "." + TYPE; } else { - return info.getName() + "-" + version + ".ant"; + return info.getName() + "-" + version + "." + TYPE; } } @@ -173,7 +217,7 @@ { writer.write( "\n <version>" + version + "</version>" ); } - writer.write( "\n <type>" + type + "</type>" ); + writer.write( "\n <type>" + TYPE + "</type>" ); writer.write( "\n </info>" ); } @@ -182,7 +226,7 @@ { writer.write( "\n <classpath>" ); final String pad = " "; - ResourceRef[] resources = getHome().getRepository().getResourceRefs( def ); + ResourceRef[] resources = m_home.getRepository().getResourceRefs( def ); writeResourceRefs( writer, pad, resources ); writeResource( writer, pad, def ); writer.write( "\n </classpath>" ); @@ -197,7 +241,7 @@ Policy policy = ref.getPolicy(); if( policy.isRuntimeEnabled() ) { - Resource resource = getHome().getResource( ref ); + Resource resource = m_home.getResource( ref ); writeResource( writer, pad, resource ); } } @@ -240,6 +284,14 @@ // ignore } } + } + + private void mkDir( File dir ) + { + Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" ); + mkdir.setDir( dir ); + mkdir.init(); + mkdir.execute(); } } Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java Thu Jun 3 18:26:43 2004 @@ -21,6 +21,7 @@ import java.io.IOException; import org.apache.tools.ant.Task; +import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.taskdefs.Jar; @@ -28,6 +29,7 @@ import org.apache.tools.ant.types.Path; import org.apache.avalon.tools.home.Home; +import org.apache.avalon.tools.home.Context; import org.apache.avalon.tools.project.Definition; /** @@ -36,11 +38,50 @@ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class InstallTask extends DeliverableTask +public class InstallTask extends Task { + private boolean m_init = false; + private Context m_context; + private Home m_home; + + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) + { + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) + { + m_home = (Home) object; + } + else + { + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); + } + } + + public void init() throws BuildException + { + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + m_init = true; + } + } + public void execute() throws BuildException { - File deliverables = getTargetDeliverablesDirectory(); + File deliverables = m_context.getDeliverablesDirectory(); if( deliverables.exists() ) { install( deliverables ); @@ -53,8 +94,8 @@ fileset.setDir( deliverables ); fileset.createInclude().setName( "**/*" ); - File cache = getHome().getRepository().getCacheDirectory(); - String group = getDefinition().getInfo().getGroup(); + File cache = m_home.getRepository().getCacheDirectory(); + String group = m_home.getDefinition().getInfo().getGroup(); File target = new File( cache, group ); Copy copy = (Copy) getProject().createTask( "copy" ); Added: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java ============================================================================== --- (empty file) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java Thu Jun 3 18:26:43 2004 @@ -0,0 +1,256 @@ +/* + * Copyright 2004 Apache Software Foundation + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.avalon.tools.tasks; + +import java.io.File; +import java.io.IOException; + +import org.apache.tools.ant.Task; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.Copy; +import org.apache.tools.ant.taskdefs.Javac; +import org.apache.tools.ant.taskdefs.Mkdir; +import org.apache.tools.ant.taskdefs.optional.junit.FormatterElement; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitTask; +import org.apache.tools.ant.taskdefs.optional.junit.BatchTest; +import org.apache.tools.ant.types.Environment; +import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.Path; + +import org.apache.avalon.tools.home.Home; +import org.apache.avalon.tools.project.Definition; +import org.apache.avalon.tools.home.Context; + +/** + * Load a goal. + * + * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> + * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ + */ +public class JUnitTestTask extends Task +{ + public static final String TEST_KEY = "project.test"; + public static final String TEST_VALUE = "test"; + + public static final String TEST_SRC_KEY = "project.test.src"; + public static final String TEST_SRC_VALUE = "test"; + + public static final String TEST_ENV_KEY = "project.test.env"; + public static final String TEST_ENV_VALUE = "env"; + + public static final String TEST_TMP_KEY = "project.test.temp"; + public static final String TEST_TMP_VALUE = "temp"; + + public static final String DEBUG_KEY = "test.compile.debug"; + public static final boolean DEBUG_VALUE = true; + + public static final String FORK_KEY = "test.compile.fork"; + public static final boolean FORK_VALUE = false; + + private boolean m_init = false; + private Context m_context; + private File m_test; + + private Home m_home; + + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) + { + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) + { + m_home = (Home) object; + } + else + { + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); + } + } + + public void init() throws BuildException + { + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + project.setNewProperty( DEBUG_KEY, "" + DEBUG_VALUE ); + project.setNewProperty( FORK_KEY, "" + FORK_VALUE ); + project.setNewProperty( TEST_SRC_KEY, "" + TEST_SRC_VALUE ); + project.setNewProperty( TEST_ENV_KEY, "" + TEST_ENV_VALUE ); + project.setNewProperty( TEST_TMP_KEY, "" + TEST_TMP_VALUE ); + m_context.setBuildPath( TEST_KEY, TEST_VALUE ); + m_test = m_context.getBuildPath( TEST_KEY ); + m_init = true; + } + } + + public void execute() throws BuildException + { + if( null == m_home ) + { + final String error = + "Required system home 'refid' attribute not set in the task definition [" + + getTaskName() + "]."; + throw new BuildException( error ); + } + + Project project = getProject(); + File build = m_context.getBuildPath( PrepareTask.BUILD_SRC_KEY ); + String testPath = project.getProperty( TEST_SRC_KEY ); + File src = new File( build, testPath ); + + if( src.exists() ) + { + File classes = new File( m_test, "classes" ); + mkDir( classes ); + Definition definition = m_home.getDefinition(); + Path classpath = + m_home.getRepository().createPath( project, definition ); + + // + // add the project jar to the classpath for the compilation + // of the test classes and compile the test classes into the + // target/test-classes directory + // + + File jar = m_context.getBuildPath( "jar" ); + classpath.createPathElement().setLocation( jar ); + compile( src, classes, classpath ); + classpath.createPathElement().setLocation( classes ); + test( src, classpath ); + } + } + + private void compile( File sources, File classes, Path classpath ) + { + File basedir = getProject().getBaseDir(); + Javac javac = (Javac) getProject().createTask( "javac" ); + Path src = javac.createSrc(); + Path.PathElement element = src.createPathElement(); + element.setLocation( sources ); + javac.setDestdir( classes ); + javac.setDebug( getDebugProperty() ); + javac.setFork( getForkProperty() ); + javac.setClasspath( classpath ); + javac.init(); + javac.execute(); + } + + private void test( File src, Path classpath ) + { + FileSet fileset = new FileSet(); + fileset.setDir( src ); + fileset.createInclude().setName( "**/*TestCase.java" ); + fileset.createExclude().setName( "**/Abstract*.java" ); + + File base = new File( m_test, "temp" ); + mkDir( base ); + + JUnitTask junit = (JUnitTask) getProject().createTask( "junit" ); + junit.setFork( getForkProperty() ); + + JUnitTask.SummaryAttribute summary = new JUnitTask.SummaryAttribute(); + summary.setValue( "on" ); + junit.setPrintsummary( summary ); + junit.setHaltonfailure( true ); + junit.setHaltonerror( true ); + junit.setErrorProperty( "test-errors" ); + junit.setFailureProperty( "test-failures" ); + if( FORK_VALUE ) + { + junit.setFork( true ); + junit.setDir( base ); + } + junit.setShowOutput( true ); + junit.setTempdir( base ); + junit.setReloading( true ); + junit.setFiltertrace( true ); + junit.createClasspath().add( classpath ); + + File reports = new File( m_test, "reports" ); + mkDir( reports ); + + BatchTest batch = (BatchTest) junit.createBatchTest(); + batch.addFileSet( fileset ); + batch.setTodir( reports ); + + FormatterElement plainFormatter = new FormatterElement(); + FormatterElement.TypeAttribute plain = new FormatterElement.TypeAttribute(); + plain.setValue( "plain" ); + plainFormatter.setType( plain ); + junit.addFormatter( plainFormatter ); + + FormatterElement xmlFormatter = new FormatterElement(); + FormatterElement.TypeAttribute xml = new FormatterElement.TypeAttribute(); + xml.setValue( "xml" ); + xmlFormatter.setType( xml ); + junit.addFormatter( xmlFormatter ); + + Environment.Variable basedir = new Environment.Variable(); + basedir.setKey( "basedir" ); + basedir.setValue( base.toString() ); + + junit.addSysproperty( basedir ); + + junit.init(); + junit.execute(); + } + + private void mkDir( File dir ) + { + Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" ); + mkdir.setDir( dir ); + mkdir.init(); + mkdir.execute(); + } + + private boolean getDebugProperty() + { + return getBooleanProperty( DEBUG_KEY, DEBUG_VALUE ); + } + + private boolean getForkProperty() + { + return getBooleanProperty( FORK_KEY, FORK_VALUE ); + } + + private boolean getBooleanProperty( String key, boolean fallback ) + { + String value = getProject().getProperty( key ); + if( null == value ) + { + return fallback; + } + else + { + return getProject().toBoolean( value ); + } + } +} Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java Thu Jun 3 18:26:43 2004 @@ -26,11 +26,13 @@ import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.taskdefs.Delete; import org.apache.tools.ant.taskdefs.Jar; +import org.apache.tools.ant.taskdefs.Mkdir; import org.apache.tools.ant.taskdefs.Checksum; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; +import org.apache.avalon.tools.home.Context; import org.apache.avalon.tools.home.Home; import org.apache.avalon.tools.project.Definition; @@ -40,37 +42,68 @@ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class JarTask extends DeliverableTask +public class JarTask extends Task { public static final String MD5_EXT = "md5"; public static final String JAR_EXT = "jar"; public static final String ASC_EXT = "asc"; - - public static String getJarFilename( Definition def ) - { - String name = def.getInfo().getName(); - if( null != def.getInfo().getVersion() ) + public static final String GPG_EXE_KEY = "project.gpg.exe"; + + private boolean m_init = false; + private Context m_context; + private Home m_home; + + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) + { + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) { - return name + "-" + def.getInfo().getVersion() + "." + JAR_EXT; + m_home = (Home) object; } else { - return name + "." + JAR_EXT; + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); } } - public static File getJarFile( Project project, Definition def ) + public void init() throws BuildException { - File type = getTargetDeliverablesTypeDirectory( project, def ); - String filename = getJarFilename( def ); - return new File( type, filename ); + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + m_init = true; + } } public void execute() throws BuildException { + if( null == m_home ) + { + final String error = + "Required system home 'refid' attribute not set in the task definition [" + + getTaskName() + "]."; + throw new BuildException( error ); + } + File classes = - JavacTask.getTargetClassesDirectory( getProject() ); - File jarFile = getJarFile(); + m_context.getBuildPath( JavacTask.BUILD_CLASSES_KEY ); + File deliverables = + m_context.getDeliverablesDirectory(); + + File jarFile = getJarFile( deliverables ); if( classes.exists() ) { try @@ -84,15 +117,41 @@ throw new BuildException( ioe ); } } + m_context.setBuildPath( "jar", jarFile.toString() ); } - private File getJarFile() + public File getJarFile( File deliverables ) { - return getJarFile( getProject(), getDefinition() ); + Project project = getProject(); + Definition def = m_home.getDefinition(); + String type = m_home.getDefinition().getInfo().getType(); + File types = new File( deliverables, type + "s" ); + String filename = getJarFilename( def ); + return new File( types, filename ); + } + + public String getJarFilename( Definition def ) + { + String name = def.getInfo().getName(); + if( null != def.getInfo().getVersion() ) + { + return name + "-" + def.getInfo().getVersion() + "." + JAR_EXT; + } + else + { + return name + "." + JAR_EXT; + } } private boolean jar( File classes, File jarFile ) { + File dir = jarFile.getParentFile(); + + Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" ); + mkdir.setDir( dir ); + mkdir.init(); + mkdir.execute(); + long modified = -1; if( jarFile.exists() ) { @@ -133,7 +192,7 @@ md5.delete(); } - String gpg = getProject().getProperty( "avalon.gpg.exe" ); + String gpg = getProject().getProperty( GPG_EXE_KEY ); if( null != gpg ) { log( "Creating asc signature" ); Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java Thu Jun 3 18:26:43 2004 @@ -25,72 +25,116 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.taskdefs.Javac; +import org.apache.tools.ant.taskdefs.Mkdir; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; +import org.apache.avalon.tools.home.Context; import org.apache.avalon.tools.home.Home; import org.apache.avalon.tools.project.Definition; /** - * Load a goal. + * Compile sources. * * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class JavacTask extends HomeTask +public class JavacTask extends Task { - public static final String CLASSES_KEY = "avalon.target.classes"; - public static final String CLASSES_VALUE = "classes"; + public static final String BUILD_CLASSES_KEY = "classes"; + public static final String BUILD_CLASSES_PATH = "classes"; public static final String DEBUG_KEY = "java.compile.debug"; - public static final boolean DEBUG_FLAG = false; + public static final boolean DEBUG_VALUE = false; public static final String FORK_KEY = "java.compile.fork"; - public static final boolean FORK_FLAG = false; + public static final boolean FORK_VALUE = false; - public static File getTargetClassesDirectory( Project project ) + private boolean m_init = false; + + private Context m_context; + + private Home m_home; + + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) { - File target = PrepareTask.getTargetDirectory( project ); - String classes = project.getProperty( CLASSES_KEY ); - return new File( target, classes ); + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) + { + m_home = (Home) object; + } + else + { + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); + } } public void init() throws BuildException { - super.init(); - setProjectProperty( CLASSES_KEY, CLASSES_VALUE ); - setProjectProperty( DEBUG_KEY, "" + DEBUG_FLAG ); - setProjectProperty( FORK_KEY, "" + FORK_FLAG ); + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + project.setNewProperty( DEBUG_KEY, "" + DEBUG_VALUE ); + project.setNewProperty( FORK_KEY, "" + FORK_VALUE ); + m_context.setBuildPath( + BUILD_CLASSES_KEY, + BUILD_CLASSES_PATH ); + m_init = true; + } } public void execute() throws BuildException { - File src = getTargetSrcMainDirectory(); - if( src.exists() ) + if( null == m_home ) { - File classes = getTargetClassesDirectory(); - if( !classes.exists() ) - { - log( "creating target classes directory" ); - createDirectory( classes ); - } - Path classpath = - getHome().getRepository().createPath( - getProject(), getDefinition() ); - compile( src, classes, classpath ); - copy( src, classes ); + final String error = + "Required system home 'refid' value is not declared"; + throw new BuildException( error ); } - } - private File getTargetSrcMainDirectory() - { - String src = getProject().getProperty( PrepareTask.TARGET_SRC_MAIN_KEY ); - return new File( getProject().getBaseDir(), src ); - } + Project project = getProject(); + File build = m_context.getBuildPath( PrepareTask.BUILD_SRC_KEY, false ); + String mainPath = project.getProperty( Context.SRC_MAIN_KEY ); + File main = new File( build, mainPath ); - private File getTargetClassesDirectory() - { - return getTargetClassesDirectory( getProject() ); + if( main.exists() ) + { + File classes = m_context.getBuildPath( BUILD_CLASSES_KEY ); + Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" ); + mkdir.setDir( classes ); + mkdir.init(); + mkdir.execute(); + + Path classpath = + m_home.getRepository().createPath( + getProject(), m_home.getDefinition() ); + compile( main, classes, classpath ); + + Copy copy = (Copy) getProject().createTask( "copy" ); + copy.setPreserveLastModified( true ); + copy.setTodir( classes ); + + FileSet fileset = new FileSet(); + fileset.setDir( main ); + fileset.setIncludes( "**/**" ); + fileset.setExcludes( "**/*.java,**/package.html" ); + copy.addFileset( fileset ); + copy.init(); + copy.execute(); + } } private void compile( File sources, File classes, Path classpath ) @@ -108,29 +152,14 @@ javac.execute(); } - private void copy( File sources, File classes ) - { - Copy copy = (Copy) getProject().createTask( "copy" ); - copy.setPreserveLastModified( true ); - copy.setTodir( classes ); - - FileSet fileset = new FileSet(); - fileset.setDir( sources ); - fileset.setIncludes( "**/**" ); - fileset.setExcludes( "**/*.java,**/package.html" ); - copy.addFileset( fileset ); - copy.init(); - copy.execute(); - } - private boolean getDebugProperty() { - return getBooleanProperty( DEBUG_KEY, DEBUG_FLAG ); + return getBooleanProperty( DEBUG_KEY, DEBUG_VALUE ); } private boolean getForkProperty() { - return getBooleanProperty( FORK_KEY, FORK_FLAG ); + return getBooleanProperty( FORK_KEY, FORK_VALUE ); } private boolean getBooleanProperty( String key, boolean fallback ) Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java Thu Jun 3 18:26:43 2004 @@ -31,6 +31,7 @@ import org.apache.tools.ant.UnknownElement; import org.apache.avalon.tools.home.Home; +import org.apache.avalon.tools.home.Context; import org.apache.avalon.tools.project.Definition; import org.apache.avalon.tools.project.Info; import org.apache.avalon.tools.project.Resource; @@ -47,18 +48,57 @@ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class PluginTask extends HomeTask +public class PluginTask extends Task { private String m_id; - private File m_definition; private String m_uri; - public void setId( String id ) + private boolean m_init = false; + private Context m_context; + private Home m_home; + + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) + { + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) + { + m_home = (Home) object; + } + else + { + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); + } + } + + + public void setArtifact( String id ) { m_id = id; } - private String getId() + public void init() throws BuildException + { + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + m_init = true; + } + } + + private String getArtifactSpec() { if( null != m_id ) { @@ -67,30 +107,40 @@ else { final String error = - "Missing plugin id attribute."; + "Missing plugin 'artifact' attribute."; throw new BuildException( error ); } } public void execute() throws BuildException { + if( null == m_home ) + { + final String error = + "Required system home 'refid' attribute not set in the task definition [" + + getTaskName() + "]."; + throw new BuildException( error ); + } + try { // // get the xml definition of the plugin // - String id = getId(); - Info info = Info.create( id, "ant" ); + String id = getArtifactSpec(); + + Info info = Info.create( id ); Project project = getProject(); Resource resource = new Resource( info ); - m_definition = getHome().getRepository().getResource( project, resource ); + File file = m_home.getRepository().getResource( project, resource ); // // create a utility data object from the defintion // - AntLibData data = new AntLibData( getProject(), m_definition ); + AntLibData data = new AntLibData( getProject(), file ); + ClassLoader classloader = project.createClassLoader( data.getPath() ); String uri = data.getInfo().getURI(); @@ -135,13 +185,12 @@ for( int i=0; i<children.length; i++ ) { Element child = children[i]; - String value = ElementHelper.getValue( child ); String type = child.getTagName(); - Info info = Info.create( value, type ); + String value = ElementHelper.getValue( child ); + Info info = Info.create( type, value ); Resource resource = new Resource( info ); File jar = - getHome().getRepository().getResource( - project, resource ); + m_home.getRepository().getResource( project, resource ); m_path.createPathElement().setLocation( jar ); } } Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java Thu Jun 3 18:26:43 2004 @@ -19,17 +19,18 @@ import java.io.File; import java.io.IOException; +import java.util.Hashtable; +import java.util.Map; import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.Copy; +import org.apache.tools.ant.taskdefs.Mkdir; import org.apache.tools.ant.taskdefs.Property; +import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.types.FileSet; -import org.apache.avalon.tools.home.Home; -import org.apache.avalon.tools.project.Definition; -import org.apache.avalon.tools.tasks.HomeTask; +import org.apache.avalon.tools.home.Context; /** * Load a goal. @@ -37,93 +38,75 @@ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a> * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $ */ -public class PrepareTask extends HomeTask +public class PrepareTask extends Task { - public static String SRC = "src"; - public static String TARGET = "target"; - public static String TARGET_SRC = TARGET + "/src"; - public static String TARGET_SRC_MAIN = TARGET_SRC + "/main"; - public static String TARGET_SRC_TEST = TARGET_SRC + "/test"; - public static String TARGET_SRC_RES = TARGET_SRC + "/resources"; - - public static final String SRC_KEY = "avalon.src"; - public static final String TARGET_KEY = "avalon.target"; - public static final String TARGET_SRC_KEY = "avalon.target.src"; - public static final String TARGET_SRC_MAIN_KEY = "avalon.target.src.main"; - public static final String TARGET_SRC_TEST_KEY = "avalon.target.src.test"; - public static final String TARGET_SRC_RES_KEY = "avalon.target.src.resources"; - public static File getTargetDirectory( Project project ) - { - String target = project.getProperty( TARGET_KEY ); - return new File( project.getBaseDir(), target ); - } + public static final String BUILD_SRC_KEY = "src"; + private static final String BUILD_SRC_PATH = "src"; - public static File getTargetSrcResourcesDirectory( Project project ) + private static final String SRC_FILTERED_INCLUDES_KEY = + "project.prepare.src.filtered.includes"; + private static final String SRC_FILTERED_INCLUDES_VALUE = + "**/*.java,**/*.x*,**/*.properties"; + + private Context m_context; + private boolean m_init = false; + private File m_home; + + /** + * Optional setting of the project home. + */ + public void setHome( File home ) { - String res = project.getProperty( TARGET_SRC_RES_KEY ); - return new File( project.getBaseDir(), res ); + m_home = home; } public void init() throws BuildException { - setProjectProperty( SRC_KEY, SRC ); - setProjectProperty( TARGET_KEY, TARGET ); - setProjectProperty( TARGET_SRC_KEY, TARGET_SRC ); - setProjectProperty( TARGET_SRC_MAIN_KEY, TARGET_SRC_MAIN ); - setProjectProperty( TARGET_SRC_TEST_KEY, TARGET_SRC_TEST ); - setProjectProperty( TARGET_SRC_RES_KEY, TARGET_SRC_RES ); + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project, m_home ); + project.setNewProperty( + SRC_FILTERED_INCLUDES_KEY, SRC_FILTERED_INCLUDES_VALUE ); + m_context.setBuildPath( BUILD_SRC_KEY, BUILD_SRC_PATH ); + m_init = true; + } } public void execute() throws BuildException { - File target = getTargetDirectory(); + Project project = getProject(); + File target = m_context.getTargetDirectory(); if( !target.exists() ) { log( "creating target directory" ); - createDirectory( target ); + Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" ); + mkdir.setDir( target ); + mkdir.init(); + mkdir.execute(); } - File src = getSrcDirectory(); + File src = m_context.getSrcDirectory(); if( src.exists() ) { - copySrcToBuildWithFiltering( target ); - copySrcToBuildWithoutFiltering( target ); + String filters = project.getProperty( SRC_FILTERED_INCLUDES_KEY ); + File build = m_context.getBuildPath( "src" ); + copy( src, build, true, filters, "" ); + copy( src, build, false, "**/*.*", filters ); } } - private File getSrcDirectory() + private void copy( + File src, File destination, boolean filtering, String includes, String excludes ) { - String src = getProject().getProperty( "avalon.src" ); - return new File( getProject().getBaseDir(), src ); - } - - private File getTargetDirectory() - { - return getTargetDirectory( getProject() ); - } - - private void copySrcToBuildWithFiltering( File target ) - { - copySrcToBuild( target, true, "**/*.java,**/*.x*,**/*.properties", "" ); - } - - private void copySrcToBuildWithoutFiltering( File target ) - { - copySrcToBuild( target, false, "**/*.*", "**/*.java,**/*.x*,**/*.properties" ); - } - - private void copySrcToBuild( - File target, boolean filtering, String includes, String excludes ) - { - File targetSrc = new File( target, SRC ); Copy copy = (Copy) getProject().createTask( "copy" ); - copy.setTodir( targetSrc ); + copy.setTodir( destination ); copy.setFiltering( filtering ); copy.setOverwrite( false ); copy.setPreserveLastModified( true ); FileSet fileset = new FileSet(); - fileset.setDir( getSrcDirectory() ); + fileset.setDir( src ); fileset.setIncludes( includes ); fileset.setExcludes( excludes ); copy.addFileset( fileset ); @@ -131,4 +114,5 @@ copy.init(); copy.execute(); } + } Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java ============================================================================== --- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java (original) +++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java Thu Jun 3 18:26:43 2004 @@ -23,107 +23,227 @@ import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.taskdefs.Copy; import org.apache.tools.ant.taskdefs.XSLTProcess; +import org.apache.tools.ant.taskdefs.Mkdir; + +import org.apache.avalon.tools.home.Context; +import org.apache.avalon.tools.home.Home; -public class XdocTask extends HomeTask +public class XdocTask extends Task { - public static final String XDOC_TARGET_SRC_KEY = "avalon.target.src.xdoc"; - public static final String XDOC_TARGET_SRC_VALUE = - PrepareTask.TARGET_SRC + "/xdocs"; - - public static final String XDOC_TARGET_DOCS_KEY = "avalon.target.docs"; - public static final String XDOC_TARGET_DOCS_VALUE = - PrepareTask.TARGET + "/docs"; + //public static final String BUILD_DOCS_KEY = "project.target.docs.name"; + //public static final String BUILD_DOCS_VALUE = "docs"; + + public static final String XDOC_TEMP_KEY = "project.target.temp.xdocs"; + public static final String XDOC_TEMP_VALUE = "xdocs"; + + public static final String XDOC_SRC_KEY = "project.xdocs.src"; + public static final String XDOC_SRC_VALUE = "xdocs"; + + public static final String XDOC_RESOURCES_KEY = "project.xdocs.resources"; + public static final String XDOC_RESOURCES_VALUE = "resources"; - public static final String XDOC_THEME_KEY = "xdoc.theme.name"; + public static final String XDOC_THEME_KEY = "project.xdoc.theme"; public static final String XDOC_THEME_VALUE = "avalon2"; - public static final String XDOC_OUTPUT_FORMAT_KEY = "xdoc.output.format"; - public static final String XDOC_OUTPUT_FORMAT_VALUE = "html"; + public static final String XDOC_FORMAT_KEY = "project.xdoc.output.format"; + public static final String XDOC_FORMAT_VALUE = "html"; + + public static final String ORG_NAME_KEY = "project.organization.name"; + public static final String ORG_NAME_VALUE = "The Apache Software Foundation"; + + public static final String XDOC_LOGO_RIGHT_FILE_KEY = "project.xdoc.logo.right.file"; + public static final String XDOC_LOGO_RIGHT_FILE_VALUE = ""; + + public static final String XDOC_LOGO_RIGHT_URL_KEY = "project.xdoc.logo.right.url"; + public static final String XDOC_LOGO_RIGHT_URL_VALUE = ""; + + public static final String XDOC_LOGO_LEFT_FILE_KEY = "project.xdoc.logo.left.file"; + public static final String XDOC_LOGO_LEFT_FILE_VALUE = ""; + + public static final String XDOC_LOGO_LEFT_URL_KEY = "project.xdoc.logo.left.url"; + public static final String XDOC_LOGO_LEFT_URL_VALUE = ""; + + public static final String XDOC_LOGO_MIDDLE_FILE_KEY = "project.xdoc.logo.middle.file"; + public static final String XDOC_LOGO_MIDDLE_FILE_VALUE = ""; + + public static final String XDOC_LOGO_MIDDLE_URL_KEY = "project.xdoc.logo.middle.url"; + public static final String XDOC_LOGO_MIDDLE_URL_VALUE = ""; + + public static final String XDOC_BRAND_NAME_KEY = "project.xdoc.brand.name"; + public static final String XDOC_BRAND_NAME_VALUE = "Avalon"; + + public static final String XDOC_ANCHOR_URL_KEY = "project.xdoc.anchor.url"; + + + private boolean m_init = false; + private Context m_context; + private Home m_home; + private String m_theme; private File m_BaseToDir; private File m_BaseSrcDir; - private String m_theme; public void setTheme( String theme ) { m_theme = theme; } - public void init() + /** + * Set the home ref id. + * @param id a home id + */ + public void setRefid( String id ) { - super.init(); - setProjectProperty( XDOC_TARGET_SRC_KEY, XDOC_TARGET_SRC_VALUE ); - setProjectProperty( XDOC_TARGET_DOCS_KEY, XDOC_TARGET_DOCS_VALUE ); - setProjectProperty( XDOC_THEME_KEY, XDOC_THEME_VALUE ); - setProjectProperty( XDOC_OUTPUT_FORMAT_KEY, XDOC_OUTPUT_FORMAT_VALUE ); - setProjectProperty( "xdoc.organization", "" ); - setProjectProperty( "xdoc.logo.right.file", "" ); - setProjectProperty( "xdoc.logo.right.url", "" ); - setProjectProperty( "xdoc.logo.left.file", "" ); - setProjectProperty( "xdoc.logo.left.url", "" ); - setProjectProperty( "xdoc.logo.middle.file", "" ); - setProjectProperty( "xdoc.logo.middle.url", "" ); - setProjectProperty( "xdoc.brand.name", "" ); + Object object = getProject().getReference( id ); + if( null == object ) + { + final String error = + "Unknown ref id '" + id + "'."; + throw new BuildException( error ); + } + if( object instanceof Home ) + { + m_home = (Home) object; + } + else + { + final String error = + "Supplied id '" + id + "' does not refer to a Home."; + throw new BuildException( error ); + } } - private File getThemesDirectory() + public void init() throws BuildException { - return new File( getHome().getHomeDirectory(), "themes" ); - } + if( !m_init ) + { + Project project = getProject(); + m_context = Context.getContext( project ); + project.setNewProperty( ORG_NAME_KEY, ORG_NAME_VALUE ); + project.setNewProperty( XDOC_SRC_KEY, XDOC_SRC_VALUE ); + project.setNewProperty( XDOC_RESOURCES_KEY, XDOC_RESOURCES_VALUE ); + project.setNewProperty( XDOC_THEME_KEY, XDOC_THEME_VALUE ); + project.setNewProperty( XDOC_FORMAT_KEY, XDOC_FORMAT_VALUE ); + project.setNewProperty( XDOC_TEMP_KEY, XDOC_TEMP_VALUE ); + project.setNewProperty( XDOC_LOGO_RIGHT_FILE_KEY, XDOC_LOGO_RIGHT_FILE_VALUE ); + project.setNewProperty( XDOC_LOGO_RIGHT_URL_KEY, XDOC_LOGO_RIGHT_URL_VALUE ); + project.setNewProperty( XDOC_LOGO_LEFT_FILE_KEY, XDOC_LOGO_LEFT_FILE_VALUE ); + project.setNewProperty( XDOC_LOGO_LEFT_URL_KEY, XDOC_LOGO_LEFT_URL_VALUE ); + project.setNewProperty( XDOC_LOGO_MIDDLE_FILE_KEY, XDOC_LOGO_MIDDLE_FILE_VALUE ); + project.setNewProperty( XDOC_LOGO_MIDDLE_URL_KEY, XDOC_LOGO_MIDDLE_URL_VALUE ); + project.setNewProperty( XDOC_BRAND_NAME_KEY, XDOC_BRAND_NAME_VALUE ); - private File getTargetSrcXdocDirectory() - { - File basedir = getProject().getBaseDir(); - return new File( basedir, getProject().getProperty( XDOC_TARGET_SRC_KEY ) ); + m_init = true; + } } - private File getTargetDocsDirectory() + private File getThemesDirectory() { - File basedir = getProject().getBaseDir(); - return new File( basedir, getProject().getProperty( XDOC_TARGET_DOCS_KEY ) ); + File home = m_home.getHomeDirectory(); + return new File( home, "themes" ); } - - private File getTargetBuildXdocDirectory() + + private String getOutputFormat() { - File target = PrepareTask.getTargetDirectory( getProject() ); - return new File( target, "temp/xdoc-build" ); + return getProject().getProperty( XDOC_FORMAT_KEY ); } - + private String getTheme() { if( m_theme != null ) return m_theme; return getProject().getProperty( XDOC_THEME_KEY ); } - private String getOutputFormat() - { - return getProject().getProperty( XDOC_OUTPUT_FORMAT_KEY ); - } - public void execute() { + log( "Executing" ); + + if( null == m_home ) + { + final String error = + "Required system home 'refid' attribute not set in the task definition [" + + getTaskName() + "]."; + throw new BuildException( error ); + } + + Project project = getProject(); + File docs = m_context.getDocsDirectory(); + log( "Docs:" + docs ); + + // + // get the directory containing the filtered xdocs source files + // (normally target/src/xdocs) + // + + File build = m_context.getBuildPath( PrepareTask.BUILD_SRC_KEY, false ); - File srcDir = getTargetSrcXdocDirectory(); + if( null == build ) + { + final String message = + "Src directory does not exist: " + + build; + log( message ); + return; + } + + String xdocsPath = project.getProperty( XDOC_SRC_KEY ); + if( null == xdocsPath ) + { + final String message = + "Cannot processed as xdoc src directory not defined."; + log( message ); + return; + } + + File srcDir = new File( build, xdocsPath ); if( !srcDir.exists() ) return; + log( "Filtered source: " + srcDir.getAbsolutePath() ); - File destDir = getTargetBuildXdocDirectory(); - createDirectory( destDir ); + // + // create the temporary directory into which we generate the + // navigation structure (normally target/temp/xdocs) + // + + File temp = m_context.getTempDirectory(); + String tempPath = project.getProperty( XDOC_TEMP_KEY ); + File destDir = new File( temp, tempPath ); + mkDir( destDir ); + + // + // get the theme, output formats, etc. + // + + log( "Destination: " + docs.getAbsolutePath() ); + mkDir( docs ); String theme = getTheme(); String output = getOutputFormat(); File themeRoot = getThemesDirectory(); File themeDir = new File( themeRoot, theme + "/" + output ); - + + String resourcesPath = project.getProperty( XDOC_RESOURCES_KEY ); + File resources = new File( build, resourcesPath ); + log( "Year: " + getProject().getProperty( "magic.year" ) ); - log( "Source: " + srcDir.getAbsolutePath() ); log( "Theme: " + themeDir ); + // + // initiate the transformation starting with the generation of + // the navigation structure based on the src directory content + // into the temporary destingation directory, copy the content + // sources to to the temp directory, transform the content and + // generated navigation in the temp dir using the selected them + // into the final docs directory, and copy over resources to + // the final docs directory + // + try { transformNavigation( themeDir, srcDir, destDir ); copySources( srcDir, destDir ); - transformXdocs( themeDir, destDir ); - copyResources( themeDir ); + transformXdocs( themeDir, destDir, docs ); + copyThemeResources( themeDir, docs ); + copySrcResources( resources, docs ); } catch( Throwable e ) { @@ -146,35 +266,25 @@ copy( source, dest, "**/*", "**/navigation.xml" ); } - private void transformXdocs( File themeDir, File build ) + private void transformXdocs( File themeDir, File build, File docs ) { File xslFile = new File( themeDir, "transform.xsl" ); String output = getOutputFormat(); - File docs = getTargetDocsDirectory(); log( "Transforming content." ); transformTrax( build, docs, xslFile, "^.*\\.xml$", "^.*/navigation.xml$", "." + output, "html" ); } - private void copyResources( File themeDir ) - { - copyThemeResources( themeDir ); - copySrcResources(); - } - - private void copySrcResources() + private void copySrcResources( File resources, File docs ) { - File destDir = getTargetDocsDirectory(); - File resources = PrepareTask.getTargetSrcResourcesDirectory( getProject() ); - copy( resources, destDir, "**/*", "" ); + copy( resources, docs, "**/*", "" ); } - private void copyThemeResources( File themeDir ) + private void copyThemeResources( File themeDir, File docs ) { - File destDir = getTargetDocsDirectory(); File fromDir = new File( themeDir, "resources" ); - copy( fromDir, destDir, "**/*", "" ); + copy( fromDir, docs, "**/*", "" ); } private void copy( File fromDir, File toDir, String includes, String excludes ) @@ -182,8 +292,9 @@ FileSet from = new FileSet(); from.setDir( fromDir ); from.setIncludes( includes ); - from.setExcludes( excludes ); - toDir.mkdirs(); /* ensure that the directory exists. */ + from.setExcludes( excludes ); + + mkDir( toDir ); Copy copy = (Copy) getProject().createTask( "copy" ); copy.setTodir( toDir ); @@ -221,7 +332,7 @@ throws BuildException { String year = getProject().getProperty( "magic.year" ); - String org = getProject().getProperty( "xdoc.organization" ); + String org = getProject().getProperty( ORG_NAME_KEY ); String copyright = "Copyright " + year + ", " + org + " All rights reserved."; @@ -238,7 +349,7 @@ } if( content[i].isFile() ) { - String svnRoot = getProject().getProperty( "xdoc.svn.root.xdocs" ); + String svnRoot = getProject().getProperty( XDOC_ANCHOR_URL_KEY ); String svnSource = svnRoot + getRelSrcPath( srcDir ) + "/" + base; int pos = base.lastIndexOf( '.' ); @@ -259,25 +370,25 @@ transformer.setParameter( "copyright", copyright ); transformer.setParameter( "logoright_file", - getProject().getProperty( "xdoc.logo.right.file" ).trim() ); + getProject().getProperty( XDOC_LOGO_RIGHT_FILE_KEY ).trim() ); transformer.setParameter( "logoright_url", - getProject().getProperty( "xdoc.logo.right.url" ).trim() ); + getProject().getProperty( XDOC_LOGO_RIGHT_URL_KEY).trim() ); transformer.setParameter( "logoleft_file", - getProject().getProperty( "xdoc.logo.left.file" ).trim() ); + getProject().getProperty( XDOC_LOGO_LEFT_FILE_KEY ).trim() ); transformer.setParameter( "logoleft_url", - getProject().getProperty( "xdoc.logo.left.url" ).trim() ); + getProject().getProperty( XDOC_LOGO_LEFT_URL_KEY ).trim() ); transformer.setParameter( "logomiddle_file", - getProject().getProperty( "xdoc.logo.middle.file" ).trim() ); + getProject().getProperty( XDOC_LOGO_MIDDLE_FILE_KEY ).trim() ); transformer.setParameter( "logomiddle_url", - getProject().getProperty( "xdoc.logo.middle.url" ).trim() ); + getProject().getProperty( XDOC_LOGO_MIDDLE_URL_KEY ).trim() ); transformer.setParameter( "brand_name", - getProject().getProperty( "xdoc.brand.name" ).trim() ); + getProject().getProperty( XDOC_BRAND_NAME_KEY ).trim() ); try { @@ -333,7 +444,6 @@ if( file.isDirectory() ) return true; - String fullpath = file.getAbsolutePath().replace( '\\', '/' ); Matcher m = m_Includes.matcher( fullpath ); @@ -344,4 +454,12 @@ return ! m.matches() ; } } + + private void mkDir( File dir ) + { + Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" ); + mkdir.setDir( dir ); + mkdir.init(); + mkdir.execute(); + } } Modified: avalon/trunk/tools/project/core/src/test/index.xml ============================================================================== --- avalon/trunk/tools/project/core/src/test/index.xml (original) +++ avalon/trunk/tools/project/core/src/test/index.xml Thu Jun 3 18:26:43 2004 @@ -11,7 +11,7 @@ <cache dir=".cache"/> <proxy/> <hosts> - <host>http://www.dpml.net</host> + <host>http://www.apache.org/dist/avalon/</host> </hosts> </repository> Modified: avalon/trunk/tools/project/core/src/test/projects/demo/build.xml ============================================================================== --- avalon/trunk/tools/project/core/src/test/projects/demo/build.xml (original) +++ avalon/trunk/tools/project/core/src/test/projects/demo/build.xml Thu Jun 3 18:26:43 2004 @@ -1,14 +1,32 @@ -<project name="my-demo" default="" basedir="." - xmlns:x="antlib:org.apache.avalon.tools"> +<project name="my-demo" default="install" basedir="." + xmlns:x="antlib:org.apache.avalon.tools"> - <x:project index="../../index.xml" key="demo"/> + <x:home id="system" index="../../index.xml" key="demo"/> - <x:prepare/> - <x:javac/> - <x:declare/> - <x:jar/> - <x:test/> - <x:install/> + <target name="clean"> + <x:clean/> + </target> + + <target name="prepare" depends=""> + <x:prepare/> + </target> + + <target name="build" depends="prepare"> + <x:declare refid="system"/> + <x:javac refid="system"/> + </target> + + <target name="package" depends="build"> + <x:jar refid="system"/> + </target> + + <target name="test" depends="package"> + <x:junit refid="system"/> + </target> + + <target name="install" depends="test"> + <x:install refid="system"/> + </target> </project> Modified: avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties ============================================================================== --- avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties (original) +++ avalon/trunk/tools/project/core/src/test/projects/gizmo/build.properties Thu Jun 3 18:26:43 2004 @@ -1 +1,5 @@ #avalon.target = targetx + +project.index = ../../index.xml +project.home = ../.. +project.gpg.exe = gpg \ No newline at end of file Modified: avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml ============================================================================== --- avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml (original) +++ avalon/trunk/tools/project/core/src/test/projects/gizmo/build.xml Thu Jun 3 18:26:43 2004 @@ -1,13 +1,31 @@ -<project name="gizmo" default="" basedir="." - xmlns:x="antlib:org.apache.avalon.tools"> +<project name="gizmo" default="install" basedir="." + xmlns:x="antlib:org.apache.avalon.tools"> - <x:project index="../../index.xml"/> + <x:home id="system" index="../../index.xml"/> - <x:prepare/> - <x:javac/> - <x:jar/> - <x:test/> - <x:install/> + <target name="clean"> + <x:clean/> + </target> + + <target name="prepare" depends=""> + <x:prepare/> + </target> + + <target name="build" depends="prepare"> + <x:javac refid="system"/> + </target> + + <target name="package" depends="build"> + <x:jar refid="system"/> + </target> + + <target name="test" depends="package"> + <x:junit refid="system"/> + </target> + + <target name="install" depends="test"> + <x:install refid="system"/> + </target> </project> Modified: avalon/trunk/tools/project/core/src/test/projects/sample/build.xml ============================================================================== --- avalon/trunk/tools/project/core/src/test/projects/sample/build.xml (original) +++ avalon/trunk/tools/project/core/src/test/projects/sample/build.xml Thu Jun 3 18:26:43 2004 @@ -1,9 +1,35 @@ -<project name="sample" default="" basedir="." - xmlns:x="antlib:org.apache.avalon.tools" xmlns:d="jar:demo/demo#1.0" > +<project name="sample" default="install" basedir="." + xmlns:x="antlib:org.apache.avalon.tools" xmlns:d="plugin:demo/demo#1.0" > - <x:project index="../../index.xml"/> - <x:plugin id="demo/demo#1.0"/> - <d:hello/> + <x:home id="system" index="../../index.xml"> + <x:plugin refid="system" artifact="plugin:demo/demo#1.0"/> + </x:home> + + <target name="clean"> + <x:clean/> + </target> + + <target name="prepare" depends=""> + <x:prepare/> + </target> + + <target name="build" depends="prepare"> + <x:javac refid="system"/> + <d:hello/> + </target> + + <target name="package" depends="build"> + <x:jar refid="system"/> + </target> + + <target name="test" depends="package"> + <x:junit refid="system"/> + </target> + + <target name="install" depends="test"> + <x:install refid="system"/> + </target> </project> + Modified: avalon/trunk/tools/project/core/src/test/projects/widget/build.xml ============================================================================== --- avalon/trunk/tools/project/core/src/test/projects/widget/build.xml (original) +++ avalon/trunk/tools/project/core/src/test/projects/widget/build.xml Thu Jun 3 18:26:43 2004 @@ -1,13 +1,32 @@ -<project name="widget" default="" basedir="." - xmlns:x="antlib:org.apache.avalon.tools"> +<project name="widget" default="install" basedir="." + xmlns:x="antlib:org.apache.avalon.tools"> - <x:project index="../../index.xml"/> + <x:home id="system" index="../../index.xml"/> - <x:prepare/> - <x:javac/> - <x:jar/> - <x:test/> - <x:install/> + <target name="clean"> + <x:clean/> + </target> + + <target name="prepare" depends=""> + <x:prepare/> + </target> + + <target name="build" depends="prepare"> + <x:javac refid="system"/> + </target> + + <target name="package" depends="build"> + <x:jar refid="system"/> + </target> + + <target name="test" depends="package"> + <x:junit refid="system"/> + </target> + + <target name="install" depends="test"> + <x:install refid="system"/> + </target> </project> + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]