PDA

View Full Version : Running JSBUILDER2 from Cold Fusion



brookd
18 Nov 2009, 11:29 AM
Hello,

I am trying to automate my build process with the awesome JSBUILDER2. In cold fusion I am using a the javaLoader cfc (http://javaloader.riaforge.org/) to load the JSBuilder JAR.




<!--- use the javaloader to load external jars --->
<cflock scope="server" type="exclusive" timeout="1">
<cfif not structKeyExists(server,'jsBuilder')>
<cfset loadPaths = arrayNew(1)>
<cfset loadPaths[1] = application.gs['jsBuilderFilePath'] & 'JSBuilder2.jar'>
<cfset server.javaLoader = createObject('component', 'com.utilities.JavaLoader').init(loadPaths)>
</cfif>
</cflock>

<!--- create an instance we can use --->
<cfset jsBuilderInstance = server.javaLoader.create('com.extjs.JSBuilder2')>


So far so code, if I look at the object I can see




object of com.extjs.JSBuilder2
Class Name:com.extjs.JSBuilder2
Methods
----------------------------------------
Method Return Type
compressOutputFiles() void
copyResources() void
main(java.lang.String[]) void
writeHeadersToTargets() void


So, which method do I call to simulate calling it from the command line?

brookd
18 Nov 2009, 11:49 AM
Well, its easier I guess to just to:



<cfexecute name = "java.exe"
arguments = "#commandargs#"
variable="result"
timeout = "60" />


Thats working nicely. and I have a nice script that automatically generates the JSBuilder Project file json too! sweet....

brookd
18 Nov 2009, 11:52 AM
I guess I may aswell post the function:





<cffunction name="buildfromsource" access="public" returntype="string" hint="Use the CFEXECUTE command to call JSBUILDER2 to build from source and output to the build">
<cfargument name="projectfilesrc" type="string" required="true" default="" hint="The full path to the project file to build">
<cfargument name="jsbuilderpath" type="string" required="false" default="c:\inetpub\wwwroot\somedir\tools\jsbuilder2\" hint="The full path to the project file to build">
<cfargument name="homedir" type="string" required="false" default="c:\inetpub\wwwroot\somedir\" hint="The absolute path to the output directory">

<cfset var header = ''>
<cfset var result = ''>
<cfset var commandargs = ''>

<cfset commandargs = "-jar #arguments.jsbuilderpath#JSBuilder2.jar">
<cfset commandargs = commandargs & " --projectFile #arguments.projectfilesrc#">
<cfset commandargs = commandargs & " --homeDir #arguments.homedir#">

<cfexecute name = "java.exe"
arguments = "#commandargs#"
variable="result"
timeout = "60" />

<cfset header = 'Project SRC: ' & arguments.projectfilesrc & chr(10)>
<cfset header = header & 'Output Home Dir: ' & arguments.homedir & chr(10) & chr(10)>

<cfreturn header & result>
</cffunction>

Gjslick
25 May 2010, 1:53 PM
Hey, just implemented this functionality on my system as well. Didn't even think of doing it until I came across your thread, so thank you! And thanks for that implementation function, def got me going on it.

-Greg

brookd
25 May 2010, 3:49 PM
Glad it was helpful for you!