Thursday, February 21, 2008

Build for Eclipse

This is in response to a comment on Mark Drew's blog by Tero. At Kroger we have an automated builder for our ColdFusion Projects. I'm making it available for everyone here I offer no official support but feel free to leave a comment if you have questions. Its fairly simple and works for us, installation Instructions:

Unzip the contents into your project in eclipse. You should have some thing like /[project]/_builder and /[project/.externalToolBuilders/. You'll also want to add the following XML block to your .project file



<buildSpec>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>

<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/project_build.launch</value>

</dictionary>
</arguments>
</buildCommand>
</buildSpec>



Now let's get to educating you about what's actually going on. In eclipse you can attach 1 or more builders to a project. They can execute at different times in Eclipse. You can set these builders up by right clicking the project and selecting the properties. The above xml block is what eclipse would put in your .project file so it knows there is a builder attached to the project. Okay now how the ANT file works. Below is a bulleted list of exceptions you may want to know about/change.
  • This is setup specifically for JBoss but it is very easy to change.
  • Properties are not variables once they are defined they will not be over written. So the order of the property declarations is important
  • The ANT script does try to take advantage of an environment variable of JBOSS_HOME. If it is not defined it will use the definition of env.JBOSS_HOME in the .properties file.
  • Some additional pathing for JBoss may need to be modified
  • The default build task is Project and all projects in Kroger deploy to cfusion.war/projects/ you may want to change that behavior
Please feel free to modify and use to your hearts content I am always happy to try to answer questions as well.

Wednesday, February 06, 2008

Eclipse Monkey

Anyone that has installed Aptana has probably noticed the console that starts up with the message "Eclipse Monkey JavaScript Console Started." I know for the longest time I wondered what the heck that was. You may have used Eclipse Monkey and not known that you were if you ever accessed anything in the scripts menu option, like Compact Javascript. While it is packaged with Aptana it's actually a separate plugin for Eclipse which you could use outside of Aptana.

I took the opportunity this morning to play around with it some and I have to say I was very impressed with what one could do quite quickly with Eclipse Monkey. I showed my co-worker, Bob, Eclipse Monkey and within 10 minutes he said, "This is sweet" and sent me a new script, which I've included at the bottom of this post, to help take care of the annoying MyEclipse issue on Macs. Aptana has a really nice one for code reviews or presenters that allows you to easily increase and decrease font sizes, lots easier than going through preferences. Another benefit I have found is the ability to do Key Bindings, essentially I can now bind my snippets to keys like I could with Homesite. Basically I have the Eclipse Monkey script with the appropriate key binding type out the text for the snippet to engage. I know its a bit of a hack but at least I can do it. I could just put the correct code into the Eclipse Monkey script itself but then I could not leverage SnipEx server...yet.

/* * Menu: Editors > Personalize Editor Font
* Kudos: Robert Burns (The Kroger Co.)
* License: EPL 1.0
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
* */
function main()
{
var store = Packages.org.eclipse.ui.internal.WorkbenchPlugin.getDefault().getPreferenceStore();
font = Packages.org.eclipse.jface.resource.JFaceResources.getTextFont();
if (font != null)
{
var data = font.getFontData();
if (data != null && data.length > 0)
{
var fontName = getFontName(data[0].getName());
var fontHeight = getFontHeight(data[0].getHeight());
if (fontName != null && fontHeight != null)
{
data[0].setName(fontName);
data[0].setHeight(fontHeight);
}
store.setValue(Packages.org.eclipse.jface.resource.JFaceResources.TEXT_FONT, Packages.org.eclipse.jface.preference.PreferenceConverter.getStoredRepresentation(data));
}
}
}

function getFontName(name)
{
dialog = new Packages.org.eclipse.jface.dialogs.InputDialog(window.getShell(), "Font Name", "Font name?", name, null);



result = dialog.open();
if (result == Packages.org.eclipse.jface.window.Window.OK)
{
return dialog.getValue();
}
}

function getFontHeight(height)
{
dialog = new Packages.org.eclipse.jface.dialogs.InputDialog(window.getShell(), "Font Height", "Font height?", height, null);
result = dialog.open();
if (result == Packages.org.eclipse.jface.window.Window.OK)
{
return dialog.getValue();
}
};