001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.sdlctools.applications.anttasks.builder;
016:
017: import java.io.File;
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.apache.tools.ant.BuildException;
022: import org.apache.tools.ant.types.FileSet;
023:
024: /** This abstract class represents the definition of the single module
025: * a separately buildable unit. */
026: public abstract class ModuleDefinition extends
027: MetaBossBuilderTaskElement {
028: private String mModuleName = null; // Public attribute - the name of the file to package
029: private File mModuleDir = null; // The name of the destination directrory. If not given the libdir from the owner task is assumed
030: private List mAdditionalFileSets = new ArrayList();
031: // List of submodules modules to build
032: protected List mSubModules = new ArrayList();
033:
034: /** The task module constructor */
035: public ModuleDefinition(MetaBossBuilderTask pOwnerTask,
036: ElementMetadata pElementMetadata) {
037: super (pOwnerTask, pElementMetadata);
038: pOwnerTask.mModules.add(this );
039: }
040:
041: /** The submodule constructor */
042: public ModuleDefinition(ModuleDefinition pOwnerModuleDefinition,
043: ElementMetadata pElementMetadata) {
044: super (pOwnerModuleDefinition.getOwnerTask(), pElementMetadata);
045: pOwnerModuleDefinition.mSubModules.add(this );
046: }
047:
048: /** The special creator asking to include some files in the resulting module */
049: public FileSet createAdditionalFiles() {
050: FileSet lFileSet = new FileSet();
051: lFileSet.setProject(getOwnerTask().getProject());
052: mAdditionalFileSets.add(lFileSet);
053: return lFileSet;
054: }
055:
056: /** Retireve the additional files to be added to the module */
057: public FileSet[] getAdditionalFiles() {
058: return (FileSet[]) mAdditionalFileSets
059: .toArray(new FileSet[mAdditionalFileSets.size()]);
060: }
061:
062: /** The setter for the optional "modulename" attribute */
063: public void setModuleName(String pModuleName) {
064: mModuleName = pModuleName;
065: }
066:
067: /** The getter for the optional "modulename" attribute */
068: public String getModuleName() throws BuildException {
069: return mModuleName;
070: }
071:
072: /** The getter for the destination directory for the module.
073: * Will use the libdir of the ModuleBuilder if 'moduledir' attribute was not specified */
074: public File getModuleDir() throws BuildException {
075: if (mModuleDir != null)
076: return mModuleDir;
077: File lLibDir = getOwnerTask().getLibDir();
078: if (lLibDir == null)
079: throw new BuildException(
080: "Either 'moduledir' attribute on the module element or 'libdir' attribute on the metaboss builder element must be specified.");
081: return lLibDir;
082: }
083:
084: /** The setter for the optional "moduledir" attribute */
085: public void setModuleDir(File pModuleDir) {
086: mModuleDir = pModuleDir;
087: }
088:
089: /** Called when initialisation of parameters has been completed and generation is about to commence */
090: public abstract void completeInitialisation() throws BuildException;
091:
092: /** Returns plan to invoke any number of code generators necessary to build the module */
093: public abstract ToolInvocationDefinition[] getGenerationPlan()
094: throws BuildException;
095:
096: /** Returns tasks to invoke any number of compilers necessary to build the module */
097: public abstract ToolInvocationDefinition[] getCompilationPlan()
098: throws BuildException;
099:
100: /** Returns tasks to invoke any number of packagers necessary to build the module */
101: public abstract ToolInvocationDefinition[] getPackagingPlan()
102: throws BuildException;
103: }
|