I have made another fix to the project-creator.jar found here.
This fix allows you to specify
-templateDir X
where
X = path relative to the directory from which the script is invoked
or
X = Absolute path
example:
Let's say I want to create a new template for my data Object so that it always has a defined String property.
I create a file called "dataObject.javasrc" (because that is currently the only name available for the dataObject template file)
The file could look like this:
***
package @packageName.common;
public class @dataObjectName {
private String dummyValue;
public void setDummyValue(String val){dummyValue=val;}
public String getDummyValue(){return dummyValue};
}
***
I save that file in:
c:\tmp\openspaces\mytemplates
in c:\tmp\openspaces I have a script that looks like this: (changes from previous examples are in different font)
****
rem Personal Settings (these change according to each machine environment)
set JAR_FILE_LOCATION=./project-creator.jar
set OUTPUT_DIRECTORY=c:/tmp/openspaces/output
set JAVA_HOME=c:\java\jdk1.5.0_07
if "%JSHOMEDIR%." == "." set JSHOMEDIR=c:\GigaSpacesXAP6.0
rem Script-specific Configuration Settings:
set PROJECT_NAME=Worker
if "%IDE%." == "." set IDE=-eclipse
set SERVICE_TEMPLATE_NAME=service.javasrc_myversion
set PU_TEMPLATE_NAME=pu.xmlsrc
set TEMPLATE_DIR=-templateDir ./mytemplates
rem General Options
rem elect to overwrite existing projects with same name:
set OVERWRITE_OPTION=-overwrite
call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR% %TEMPLATE_DIR%
****
If I call that script from the c:\tmp\openspaces directory all will be well and it will find my new version of the dataObject.javasrc file.
If I do not want to call it from that dir everytime, I can instead provide the arg:
set TEMPLATE_DIR=-templateDir c:/tmp/openspaces/mytemplates
and call the script from anywhere.
If the template needed for an operation is not provided in your specified TEMPLATE_DIR, projectcreator will look for it in the jar file as usual.
The template directory structure is as follows:
/%templateDir%
/%templateDir%/eclipse
/%templateDir%/intellij
All the templates are stored in the root of the templateDir except the files used for eclipse and intellij.
Some of the templates you can create must have certain names such as:
build.xml
any of the eclipse or intellij files
dataObject.javasrc
The template files used for the Service.java and pu.xml files can be given any name you like.
Within the templates you create you can currently use any of the following as replacement tokens: (consult the source code found here for more details)
@projectName (Name of the project you want to build)
@spaceName (Name of the space you want to connect to ex: MySpace)
@propertySpaceName (Name of the space with a lowercased first letter ā derived from @spaceName ex: mySpace)
@varGSHome (Path to [and including] Root Directory of your XAP installation)
@spaceUrl (This is derived from the @spaceName and your choice of remote or embedded)
@packageName (You specify this as the package for your first service in this Project)
@packageDir (This is derived from the @packageName)
@serviceName (You specify this as the name of your service class)
@dataObjectName (You specify this as the name of your data class (note the package name will set to @packageName.common to ensure this class is packaged in a separate jar file for classloading purposes)
I hope this addition makes this utility even more fun to use.
Cheers,
Owen.