From 8b39211862c5a0b88ce5764bbc1682a89fd02895 Mon Sep 17 00:00:00 2001 From: adammurdoch Date: Wed, 13 Feb 2002 02:47:37 +0000 Subject: [PATCH] A project may now have a name attribute. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271304 13f79535-47bb-0310-9956-ffa450edef68 --- proposal/myrmidon/docs/index.html | 20 ++++++++++++++ .../components/builder/DefaultProject.java | 26 ++++++++++++++++--- .../builder/DefaultProjectBuilder.java | 3 +++ .../myrmidon/interfaces/model/Project.java | 15 +++++++---- proposal/myrmidon/src/xdocs/index.xml | 5 ++++ 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/proposal/myrmidon/docs/index.html b/proposal/myrmidon/docs/index.html index da813f1bb..550f5e9be 100644 --- a/proposal/myrmidon/docs/index.html +++ b/proposal/myrmidon/docs/index.html @@ -298,6 +298,26 @@ take the following attributes: Default Value + + + + + + name + + + + + The project name. + + + + + The name of the project file, with the extension removed. + diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProject.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProject.java index 2ddf4b04d..9d883548a 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProject.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProject.java @@ -46,6 +46,25 @@ public class DefaultProject ///The base directory of project private File m_baseDirectory; + ///The project name + private String m_name; + + /** + * Returns the project name. + */ + public String getProjectName() + { + return m_name; + } + + /** + * Sets the project name. + */ + public void setProjectName( String name ) + { + m_name = name; + } + /** * Get the imports for project. * @@ -111,7 +130,7 @@ public class DefaultProject /** * Retrieve a target by name. * - * @param name the name of target + * @param targetName the name of target * @return the Target or null if no target exists with name */ public final Target getTarget( final String targetName ) @@ -151,14 +170,15 @@ public class DefaultProject /** * Retrieve base directory of project. - * - * @return the projects base directory */ public final void setBaseDirectory( final File baseDirectory ) { m_baseDirectory = baseDirectory; } + /** + * Adds a type library import to the project. + */ public final void addTypeLib( final TypeLib typeLib ) { m_imports.add( typeLib ); diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java index d8290b89f..894fb0e1a 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java @@ -128,6 +128,8 @@ public class DefaultProjectBuilder } //get project-level attributes + final String projectName = configuration.getAttribute( "name", + FileUtil.removeExtension(file.getName()) ); final String baseDirectoryName = configuration.getAttribute( "basedir", null ); final String defaultTarget = configuration.getAttribute( "default", "main" ); final Version version = getVersion( configuration ); @@ -156,6 +158,7 @@ public class DefaultProjectBuilder //create project and ... final DefaultProject project = new DefaultProject(); + project.setProjectName( projectName ); project.setDefaultTargetName( defaultTarget ); project.setBaseDirectory( baseDirectory ); diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/model/Project.java b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/model/Project.java index 86c985658..46c51f8d6 100644 --- a/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/model/Project.java +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/interfaces/model/Project.java @@ -14,9 +14,6 @@ import org.apache.avalon.framework.component.Component; * Abstraction used to interact with projects. * Implementations may choose to structure it anyway they choose. * - * TODO: Determine if projects should carry their own name. Breaks IOC but - * Can be useful as project files embed own name (or should that be description). - * * @author Peter Donald * @version $Revision$ $Date$ */ @@ -34,6 +31,14 @@ public interface Project // the name of currently executing target //String TARGET = "myrmidon.target.name"; + /** + * Returns the project name. + * + * TODO: Determine if projects should carry their own name. Breaks IOC but + * Can be useful as project files embed own name (or should that be description). + */ + String getProjectName(); + /** * Get the imports for project. * @@ -42,14 +47,14 @@ public interface Project TypeLib[] getTypeLibs(); /** - * Get names of projects referred to by this project. + * Get names of projects referenced by this project. * * @return the names */ String[] getProjectNames(); /** - * Retrieve project reffered to by this project. + * Retrieve project referenced by this project. * * @param name the project name * @return the Project or null if none by that name diff --git a/proposal/myrmidon/src/xdocs/index.xml b/proposal/myrmidon/src/xdocs/index.xml index 41377f897..1e49bb175 100644 --- a/proposal/myrmidon/src/xdocs/index.xml +++ b/proposal/myrmidon/src/xdocs/index.xml @@ -174,6 +174,11 @@ take the following attributes: + + + + +
AttributeDescriptionDefault Value
nameThe project name.The name of the project file, with the extension removed.
basedir The base directory for the project.