donaldp 01/06/12 06:41:41
Modified: proposal/myrmidon/src/java/org/apache/myrmidon/components/model
Project.java DefaultProject.java
Log:
Changed Project so that it contains a list of Imports (of type libraries) and
project references.
Revision Changes Path
1.3 +24 -2
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/Project.java
Index: Project.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/Project.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Project.java 2001/05/31 17:20:23 1.2
+++ Project.java 2001/06/12 13:41:39 1.3
@@ -28,10 +28,32 @@
String PROJECT = "ant.project.name";
// the name of currently executing project
- String PROJECT_FILE = "ant.project.file";
+ //String PROJECT_FILE = "ant.project.file";
// the name of currently executing target
- String TARGET = "ant.target.name";
+ //String TARGET = "ant.target.name";
+
+ /**
+ * Get the imports for project.
+ *
+ * @return the imports
+ */
+ Import[] getImports();
+
+ /**
+ * Get names of projects referred to by this project.
+ *
+ * @return the names
+ */
+ String[] getProjectNames();
+
+ /**
+ * Retrieve project reffered to by this project.
+ *
+ * @param name the project name
+ * @return the Project or null if none by that name
+ */
+ Project getProject( String name );
/**
* Get name of default target.
1.4 +65 -4
jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/DefaultProject.java
Index: DefaultProject.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/model/DefaultProject.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultProject.java 2001/05/29 12:06:25 1.3
+++ DefaultProject.java 2001/06/12 13:41:39 1.4
@@ -9,6 +9,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
/**
@@ -19,6 +20,12 @@
public class DefaultProject
implements Project
{
+ ///The imports
+ private final ArrayList m_imports = new ArrayList();
+
+ ///The projects refferred to by this project
+ private final HashMap m_projects = new HashMap();
+
///The targets contained by this project
private final HashMap m_targets = new HashMap();
@@ -32,6 +39,37 @@
private File m_baseDirectory;
/**
+ * Get the imports for project.
+ *
+ * @return the imports
+ */
+ public Import[] getImports()
+ {
+ return (Import[])m_imports.toArray( new Import[ 0 ] );
+ }
+
+ /**
+ * Get names of projects referred to by this project.
+ *
+ * @return the names
+ */
+ public String[] getProjectNames()
+ {
+ return (String[])m_projects.keySet().toArray( new String[ 0 ] );
+ }
+
+ /**
+ * Retrieve project reffered to by this project.
+ *
+ * @param name the project name
+ * @return the Project or null if none by that name
+ */
+ public Project getProject( final String name )
+ {
+ return (Project)m_projects.get( name );
+ }
+
+ /**
* Retrieve base directory of project.
*
* @return the projects base directory
@@ -113,8 +151,13 @@
m_baseDirectory = baseDirectory;
}
+ public final void addImport( final Import importEntry )
+ {
+ m_imports.add( importEntry );
+ }
+
/**
- * Add a target to project.
+ * Add a target.
*
* @param name the name of target
* @param target the Target
@@ -124,7 +167,7 @@
{
if( null != m_targets.get( name ) )
{
- throw new IllegalArgumentException( "Can not have two targets in
a " +
+ throw new IllegalArgumentException( "Can not have two targets in
a " +
"file with the name " + name
);
}
else
@@ -132,6 +175,24 @@
m_targets.put( name, target );
}
}
-}
-
+ /**
+ * Add a project reference.
+ *
+ * @param name the name of target
+ * @param project the Project
+ * @exception IllegalArgumentException if project already exists with
same name
+ */
+ public final void addProject( final String name, final Project project )
+ {
+ if( null != m_projects.get( name ) )
+ {
+ throw new IllegalArgumentException( "Can not have two projects
referenced in a " +
+ "file with the name " + name
);
+ }
+ else
+ {
+ m_projects.put( name, project );
+ }
+ }
+}