protoj.lang
Class ConfigureFeature

java.lang.Object
  extended by protoj.lang.ConfigureFeature

public final class ConfigureFeature
extends java.lang.Object

Configures the project by overlaying the contents of a profile directory onto the project directory. A profile directory can have any content whatsoever, but usually it will contain a similar directory structure to the project itself and contain xml and property files that should replace those already existing in the project.

Also uniquely for properties files, any properties will automatically get merged with those where a a destination properties file already exists, with the profile properties taking precedence over the project properties. Here is an example of a profile called jonny for a hypothetical developer of the same name:

 ˜/dev/myproj/
          |
          |____bin/                            copy will happen here
          |
          |____conf/ip-addresses.properties    merge will happen here
          |      |
          |      |____profile/                 create profiles under here
          |            |
          |            |____jonny/             an example profile directory
          |                  |
          |                  |____bin/useful-dev-script.sh
          |                  |
          |                  |____conf/ip-addresses.properties
          |
          |...
 
So jonny has a special script that he likes to use and therefore has placed it in the bin directory under his profile. Also it seems also that the project needs to know various ip addresses in order to work correctly. Therefore he has placed his inside his conf directory, with the knowledge that after configuration, his properties will get merged into the properties file in the project directory and also take precedence.

Interpolated properties are also supported, which basically means all ${var} property placeholders get resolved during configuration in any text files specified in a profile. This can be especially useful for the many tools that are unable to interpolate properties at runtime for themselves. It's a good idea to set interpolation permanently on or off since the two modes aren't compatible. So the decision must be made at the API level at compile time by specifying true or false in the call to StandardProject.initConfig(). The following options are supported:

  1. -name: the name of the directory directly underneath the project name directory containing all of the project configuration files.
  2. -undo: when specified all files in the project hierarchy that match the files in the profile hierarchy are deleted. Really this is only a partial undo since no state is saved for the original configure command, so properties files for example also get deleted rather than unmerged.
Example: "configure -name defaults" Example: "configure -name jonny" Example: "configure -name clusternode1" Hint: try configuring profiles one after another to build up from the most common settings to the most specific settings.

Author:
Ashley Williams

Constructor Summary
ConfigureFeature(StandardProject project, boolean interpolated)
          Creates an instance with the owning parent project and also the plug-in runnable responsible for further configuration.
 
Method Summary
 void configure(java.lang.String name)
          Configures the project config directory by overlaying the content of the specified profile directory, merging any properties files en route.
 java.io.File getWorkingDir()
          Temporary storage for configuration calculations.
 void undo(java.lang.String name)
          Removes all files in the project directory that match the paths in the specified profile name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigureFeature

public ConfigureFeature(StandardProject project,
                        boolean interpolated)
Creates an instance with the owning parent project and also the plug-in runnable responsible for further configuration.

Parameters:
project -
interpolated -
Method Detail

getWorkingDir

public java.io.File getWorkingDir()
Temporary storage for configuration calculations.

Returns:

configure

public void configure(java.lang.String name)
Configures the project config directory by overlaying the content of the specified profile directory, merging any properties files en route.

When interpolate is specified to be true, all property references in all files (including the properties files themselves in the profile conf directory) are interpolated. This means every reference to ${var} is replaced with the value calculated from the properties files. Additionally the properties files are reduced to a single master properties file - see ProjectLayout.getPropertiesFile().

Parameters:
name -

undo

public void undo(java.lang.String name)
Removes all files in the project directory that match the paths in the specified profile name. No state is saved for the original configure, so this is probably the best that can be done.

Parameters:
name -