org.acmsl.antmake
Class AntMake

java.lang.Object
  |
  +--org.acmsl.antmake.AntMake

public abstract class AntMake
extends java.lang.Object

Manages the creation of required GNU Autotools files from a sets of Java source files.

Version:
$Revision: 1.14 $
Author:
Jose San Leandro Armend?riz

Field Summary
static java.lang.String[] EMPTY_STRING_ARRAY
          Cached empty String array.
 
Constructor Summary
protected AntMake()
          Protected constructor to avoid accidental instantiation.
 
Method Summary
protected  void addFolder(java.util.Map map, java.lang.String folder)
          Adds given folder to given map.
protected  void addFolder(java.util.Map map, java.lang.String parent, java.lang.String folder)
          Adds given folder to given map.
protected  void addPackage(AntMakeUtils antMakeUtils, java.util.Map map, java.lang.String[] folders)
          Adds given package (and its parents) to given map.
protected  void addPackage(java.util.Map map, java.lang.String[] folders)
          Adds given package (and its parents) to given map.
protected  void addSource(java.util.Map map, java.io.File source)
          Adds a source file to given map.
protected  java.lang.Object buildFolderKey(java.lang.String folder)
          Builds a key for given folder.
protected  java.lang.Object buildFolderListKey()
          Builds a key for the folder list.
 void buildProject(java.lang.String projectName, java.lang.String projectVersion, java.io.File baseFolder, org.apache.tools.ant.types.FileSet[] fileSets, org.apache.tools.ant.types.Path classpath, AntMakeTask task)
          Creates the basic folder structure starting from given folder.
protected  java.lang.Object buildSourceKey(java.lang.String source)
          Builds a key for given source file.
protected  java.lang.String[] copyDependencies(java.io.File baseFolder, org.apache.tools.ant.types.Path classpath, org.apache.tools.ant.Task task)
          Copies the required dependencies from the classpath.
protected  java.lang.String[] copyDependencies(java.io.File baseFolder, java.lang.String[] dependencies, java.lang.String relativeFolder, org.apache.tools.ant.Task task)
          Copies the required dependencies from the classpath.
 void copyFile(org.acmsl.commons.utils.io.FileUtils fileUtils, java.io.File file, java.io.File folder, org.apache.tools.ant.Task task)
          Copies given file to the specified folder.
protected  void copyFile(java.lang.String fileName, FolderStructureHelper folderStructureHelper, java.io.File baseFolder, AntMakeTask task, java.lang.ClassLoader classLoader)
          Copies a concrete file.
protected  void copyFiles(FolderStructureHelper folderStructureHelper, java.io.File baseFolder, AntMakeTask task, java.lang.ClassLoader classLoader)
          Copies the fixed files.
 void copyFixedFiles(java.io.File baseFolder, AntMakeTask task)
          Copies the fixed files: README, AUTHORS and COPYING.
protected  void createConfigureInFile(ConfigureInTemplateGenerator generator, AntMakeUtils antMakeUtils, java.lang.String projectName, java.lang.String projectVersion, java.io.File baseFolder, java.io.File[] sourceFiles, org.apache.tools.ant.Task task)
          Creates the configure.in file.
protected  void createConfigureInFile(java.lang.String projectName, java.lang.String projectVersion, java.io.File baseFolder, java.io.File[] sourceFiles, org.apache.tools.ant.Task task)
          Creates the configure.in file.
protected  void createMakefileAmFiles(MakefileAmTemplateGenerator generator, AntMakeUtils antMakeUtils, java.lang.String projectName, java.io.File baseFolder, java.io.File[] sourceFiles, org.apache.tools.ant.Task task)
          Creates the child Makefile.am files.
protected  void createMakefileAmFiles(java.lang.String projectName, java.io.File baseFolder, java.io.File[] sourceFiles, org.apache.tools.ant.Task task)
          Creates the child Makefile.am files.
protected  void createMakeRulesFile(MakeRulesTemplateGenerator generator, java.lang.String projectName, java.io.File baseFolder, java.lang.String[] dependencies, org.apache.tools.ant.Task task)
          Creates the Make-rules file.
protected  void createMakeRulesFile(java.lang.String projectName, java.io.File baseFolder, java.lang.String[] dependencies, org.apache.tools.ant.Task task)
          Creates the Make-rules file.
protected  void createTopMakefileAmFile(java.lang.String projectName, java.io.File baseFolder, java.io.File[] sourceFiles, org.apache.tools.ant.Task task)
          Creates the top-level Makefile.am file.
protected  void createTopMakefileAmFile(TopMakefileAmTemplateGenerator generator, AntMakeUtils antMakeUtils, java.lang.String projectName, java.io.File baseFolder, java.io.File[] sourceFiles, org.apache.tools.ant.Task task)
          Creates the top-level Makefile.am file.
protected  void generateChangeLog(CvsUtils cvsUtils, java.io.File rootFolder, java.lang.String output, org.apache.tools.ant.Task task)
          Generates the changelog file.
protected  void generateChangeLog(java.io.File rootFolder, java.lang.String output, org.apache.tools.ant.Task task)
          Generates the changelog file.
 java.util.Collection getFolderList(java.util.Map map)
          Retrieves the folder list contained in given map.
static AntMake getInstance()
          Retrieves an AntMake instance.
protected static java.lang.ref.WeakReference getReference()
          Retrieves the weak reference.
 java.util.Collection getSources(java.util.Map map, java.lang.String folder)
          Retrieves the sources of given folder.
 java.util.Collection getSubfolders(java.util.Map map, java.lang.String folder)
          Retrieves the sources of given folder.
protected static void setReference(AntMake instance)
          Specifies a new weak reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY
Cached empty String array.

Constructor Detail

AntMake

protected AntMake()
Protected constructor to avoid accidental instantiation.

Method Detail

setReference

protected static void setReference(AntMake instance)
Specifies a new weak reference.

Parameters:
instance - the instance to use.

getReference

protected static java.lang.ref.WeakReference getReference()
Retrieves the weak reference.

Returns:
such reference.

getInstance

public static AntMake getInstance()
Retrieves an AntMake instance.

Returns:
such instance.

buildProject

public void buildProject(java.lang.String projectName,
                         java.lang.String projectVersion,
                         java.io.File baseFolder,
                         org.apache.tools.ant.types.FileSet[] fileSets,
                         org.apache.tools.ant.types.Path classpath,
                         AntMakeTask task)
                  throws AntMakeException
Creates the basic folder structure starting from given folder.

Parameters:
projectName - the project name.
projectVersion - the project version.
baseFolder - the base folder.
classpath - the class path.
task - the AntMake task (only for logging purposes).
Throws:
AntMakeException - if the project cannot be built for some reason.

copyFiles

protected void copyFiles(FolderStructureHelper folderStructureHelper,
                         java.io.File baseFolder,
                         AntMakeTask task,
                         java.lang.ClassLoader classLoader)
                  throws AntMakeException
Copies the fixed files.

Parameters:
folderStructureHelper - the helper.
baseFolder - the base folder.
task - the AntMake tas.
classLoader - the class loader used to get the macro files from the class path.
Throws:
AntMakeException - if some files are not found.

copyFile

protected void copyFile(java.lang.String fileName,
                        FolderStructureHelper folderStructureHelper,
                        java.io.File baseFolder,
                        AntMakeTask task,
                        java.lang.ClassLoader classLoader)
                 throws java.io.IOException
Copies a concrete file.

Parameters:
fileName - the name of the file.
folderStructureHelper - the helper.
baseFolder - the base folder.
task - the AntMake tas.
classLoader - the class loader used to get the macro files from the class path.
Throws:
java.io.IOException - if some files are not found.

copyDependencies

protected java.lang.String[] copyDependencies(java.io.File baseFolder,
                                              org.apache.tools.ant.types.Path classpath,
                                              org.apache.tools.ant.Task task)
                                       throws AntMakeException
Copies the required dependencies from the classpath.

Parameters:
baseFolder - the base folder.
classpath - the classpath.
task - the task, for logging purposes.
Returns:
the references to the new location of the dependencies.
Throws:
AntMakeException - if the dependencies could not be copied.

copyDependencies

protected java.lang.String[] copyDependencies(java.io.File baseFolder,
                                              java.lang.String[] dependencies,
                                              java.lang.String relativeFolder,
                                              org.apache.tools.ant.Task task)
                                       throws AntMakeException
Copies the required dependencies from the classpath.

Parameters:
baseFolder - the base folder.
dependencies - the dependencies.
relativeFolder - the relative folder for storing the dependencies starting from basefolder.
task - the task, for logging purposes.
Returns:
the references to the new location of the dependencies.
Throws:
AntMakeException - if the dependencies could not be copied.

createMakeRulesFile

protected void createMakeRulesFile(java.lang.String projectName,
                                   java.io.File baseFolder,
                                   java.lang.String[] dependencies,
                                   org.apache.tools.ant.Task task)
                            throws AntMakeException
Creates the Make-rules file.

Parameters:
projectName - the project name.
baseFolder - the base folder.
dependencies - the dependencies.
task - the task (for logging purposes). throws AntMakeException if the Make-rules file cannot be created.
AntMakeException

createMakeRulesFile

protected void createMakeRulesFile(MakeRulesTemplateGenerator generator,
                                   java.lang.String projectName,
                                   java.io.File baseFolder,
                                   java.lang.String[] dependencies,
                                   org.apache.tools.ant.Task task)
                            throws AntMakeException
Creates the Make-rules file.

Parameters:
generator - the template generator.
projectName - the project name.
baseFolder - the base folder.
dependencies - the dependencies.
task - the task (for logging purposes). throws AntMakeException if the Make-rules file cannot be created.
AntMakeException

createConfigureInFile

protected void createConfigureInFile(java.lang.String projectName,
                                     java.lang.String projectVersion,
                                     java.io.File baseFolder,
                                     java.io.File[] sourceFiles,
                                     org.apache.tools.ant.Task task)
                              throws AntMakeException
Creates the configure.in file.

Parameters:
projectName - the project name.
projectVersion - the project version.
baseFolder - the base folder.
sourceFiles - the source files.
task - the task (for logging purposes). throws AntMakeException if the configure.in file cannot be created.
AntMakeException

createConfigureInFile

protected void createConfigureInFile(ConfigureInTemplateGenerator generator,
                                     AntMakeUtils antMakeUtils,
                                     java.lang.String projectName,
                                     java.lang.String projectVersion,
                                     java.io.File baseFolder,
                                     java.io.File[] sourceFiles,
                                     org.apache.tools.ant.Task task)
                              throws AntMakeException
Creates the configure.in file.

Parameters:
generator - the template generator.
antMakeUtils - the helper instance.
projectName - the project name.
projectVersion - the project version.
baseFolder - the base folder.
sourceFiles - the source files.
task - the task (for logging purposes). throws AntMakeException if the configure.in file cannot be created.
AntMakeException

createTopMakefileAmFile

protected void createTopMakefileAmFile(java.lang.String projectName,
                                       java.io.File baseFolder,
                                       java.io.File[] sourceFiles,
                                       org.apache.tools.ant.Task task)
                                throws AntMakeException
Creates the top-level Makefile.am file.

Parameters:
projectName - the project name.
baseFolder - the base folder.
sourceFiles - the source files.
task - the task (for logging purposes). throws AntMakeException if such Makefile.am file cannot be created.
AntMakeException

createTopMakefileAmFile

protected void createTopMakefileAmFile(TopMakefileAmTemplateGenerator generator,
                                       AntMakeUtils antMakeUtils,
                                       java.lang.String projectName,
                                       java.io.File baseFolder,
                                       java.io.File[] sourceFiles,
                                       org.apache.tools.ant.Task task)
                                throws AntMakeException
Creates the top-level Makefile.am file.

Parameters:
generator - the template generator.
antMakeUtils - the helper instance.
projectName - the project name.
baseFolder - the base folder.
sourceFiles - the source files.
task - the task (for logging purposes). throws AntMakeException if such Makefile.am file cannot be created.
AntMakeException

createMakefileAmFiles

protected void createMakefileAmFiles(java.lang.String projectName,
                                     java.io.File baseFolder,
                                     java.io.File[] sourceFiles,
                                     org.apache.tools.ant.Task task)
                              throws AntMakeException
Creates the child Makefile.am files.

Parameters:
projectName - the project name.
baseFolder - the base folder.
sourceFiles - the source files.
task - the task (for logging purposes). throws AntMakeException if any of the Makefile.am files cannot be created.
AntMakeException

createMakefileAmFiles

protected void createMakefileAmFiles(MakefileAmTemplateGenerator generator,
                                     AntMakeUtils antMakeUtils,
                                     java.lang.String projectName,
                                     java.io.File baseFolder,
                                     java.io.File[] sourceFiles,
                                     org.apache.tools.ant.Task task)
                              throws AntMakeException
Creates the child Makefile.am files.

Parameters:
generator - the template generator.
antMakeUtils - the helper instance.
projectName - the project name.
baseFolder - the base folder.
sourceFiles - the source files.
task - the task (for logging purposes). throws AntMakeException if such Makefile.am file cannot be created.
AntMakeException

addSource

protected void addSource(java.util.Map map,
                         java.io.File source)
Adds a source file to given map.

Parameters:
map - the container.
source - the source file.

getSources

public java.util.Collection getSources(java.util.Map map,
                                       java.lang.String folder)
Retrieves the sources of given folder.

Parameters:
map - the container.
folder - the folder.
Returns:
the collection of all sources under such folder.

addPackage

protected void addPackage(java.util.Map map,
                          java.lang.String[] folders)
Adds given package (and its parents) to given map.

Parameters:
map - the container.
folders - the folders of the package.

addPackage

protected void addPackage(AntMakeUtils antMakeUtils,
                          java.util.Map map,
                          java.lang.String[] folders)
Adds given package (and its parents) to given map.

Parameters:
antMakeUtils - the helper instance.
map - the container.
folders - the folders of the package.

addFolder

protected void addFolder(java.util.Map map,
                         java.lang.String parent,
                         java.lang.String folder)
Adds given folder to given map.

Parameters:
map - the container.
parent - the parent.
folder - the folder of the package.

addFolder

protected void addFolder(java.util.Map map,
                         java.lang.String folder)
Adds given folder to given map.

Parameters:
map - the container.
folder - the folder of the package.

getSubfolders

public java.util.Collection getSubfolders(java.util.Map map,
                                          java.lang.String folder)
Retrieves the sources of given folder.

Parameters:
map - the container.
folder - the folder.
Returns:
the collection of all sources under such folder.

getFolderList

public java.util.Collection getFolderList(java.util.Map map)
Retrieves the folder list contained in given map.

Parameters:
map - the container.
Returns:
the collection of all folders.

buildSourceKey

protected java.lang.Object buildSourceKey(java.lang.String source)
Builds a key for given source file.

Parameters:
source - the source file.
Returns:
the key.

buildFolderKey

protected java.lang.Object buildFolderKey(java.lang.String folder)
Builds a key for given folder.

Parameters:
folder - the folder.
Returns:
the key.

buildFolderListKey

protected java.lang.Object buildFolderListKey()
Builds a key for the folder list.

Returns:
the key.

copyFixedFiles

public void copyFixedFiles(java.io.File baseFolder,
                           AntMakeTask task)
                    throws AntMakeException
Copies the fixed files: README, AUTHORS and COPYING.

Parameters:
baseFolder - the base folder.
task - the AntMake task instance.
Throws:
AntMakeException - if the files could not be copied.

copyFile

public void copyFile(org.acmsl.commons.utils.io.FileUtils fileUtils,
                     java.io.File file,
                     java.io.File folder,
                     org.apache.tools.ant.Task task)
              throws AntMakeException
Copies given file to the specified folder.

Parameters:
file - the input file.
folder - the destination.
task - the task (for logging purposes).
Throws:
AntMakeException - if the file could not be copied.

generateChangeLog

protected void generateChangeLog(java.io.File rootFolder,
                                 java.lang.String output,
                                 org.apache.tools.ant.Task task)
                          throws AntMakeException
Generates the changelog file.

Parameters:
rootFolder - the root folder.
output - the name of the output file.
task - the task.
Throws:
AntMakeException - if the file cannot be generated.

generateChangeLog

protected void generateChangeLog(CvsUtils cvsUtils,
                                 java.io.File rootFolder,
                                 java.lang.String output,
                                 org.apache.tools.ant.Task task)
                          throws AntMakeException
Generates the changelog file.

Parameters:
cvsUtils - the CvsUtils instance.
rootFolder - the root folder.
output - the name of the output file.
task - the task.
Throws:
AntMakeException - if the file cannot be generated.


Copyright © 2004 ACM S.L.. All Rights Reserved.