how to use ant-contrib tasks in eclipse auto content assist - eclipse

I have Eclipse Ganymede and would like to use the auto content assist feature for ant. I have the ant-contrib-1.0b3.jar with me.
What configuration is required in eclipse to use auto content assist which can include tasks for ant-contrib as well?
When I use the following the ant can recognize tasks for ant-contrib but content assist doesn't work?
<!-- Define classpath for ant-contrib tasks -->
<path id="ant.contrib.classpath">
<fileset dir="/path/to/lib/">
<include name="ant-contrib-1.0b3.jar" />
</fileset>
</path>
<!-- Task definition -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath refid="ant.contrib.classpath" />
</taskdef>

Please try the following.
I understand that for Ant 1.6 and later you need to reference the antcontrib XML file instead of the properties file like so :
<!-- Task definition -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath refid="ant.contrib.classpath" />
</taskdef>
This is also detailed here.
Besides that, in Preferences -> Ant -> Editor -> Content Assist check that Provide proposals for user defined tasks is checked like so (this is also the default) :
If both of the above are in place you should get the content assist as shown here (This is the code from your post, the only difference being, that have replaced the reference to antcontrib.properties with antlib.xml) :
Replacing the reference to the properties file with the xml one made all the difference for me on Eclipse Indigo SR2 (64 Bit).
I checked to make sure that this feature ( Content assist for user-defined ant tasks) is available at least since Eclipse 3.3. There were performance problems in the Ant Editor related specifically to this feature in Eclipse 3.3 but the same have since been resolved.

Related

Domino Designer Plugin Ant class path

I've build an osgi plug-in to wrap a jar files. I've been following this guide.
In the last step, I can´t “Build all” to generate the update site because an error said that couldn't find the ant classpath
Any idea?
Thanks
The version that i'm using is Release 9.0.1FP9
Revision 20170815.0729-FP9 (Release 9.0.1FP9)
Try running Ant on the command line to see the full output. Here is a GitHub project showing specifically how to run Ant tasks for Domino.
Here also are some details about setting the Ant classpath for a given build in build.xml:
<!-- create our ant classpath using the fileset task -->
<path id="class.path">
<!-- include all jars in the lib directory and all sub-directories -->
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
I find that Eclipse plugins often just assemble and execute terminal commands, but when they fail they tend not to be great at making clear the cause. Often, running the equivalent commands in the terminal (be they ant, maven, etc.) is clearer when failures occur because you'll see the full error output. And it gives you the added benefit--sometimes--of having a clearer understanding of what's happening under the hood.

How to speed up Alfresco Share development

I'm developing and performing some customization on Share. My IDE is Eclipse Juno and workspace is made up of the next elements:
alfresco web project
extensions Java project
share web project
Both alfresco and share web projects are deployed in separate Tomcat instances, this way I can slightly speed up my development tasks by restarting only the Tomcat instance where Share is deployed.
My extensions Java project has the same structure as the Eclipse project proposed by Alfresco. Y the provided Ant tasks for compiling, compressing JavaScript files, packaging and deploying the resultant JAR file in Tomcat.
I'm developing some new JavaScript client-side widgets, which means every time I make a change I have to stop Tomcat, launch Ant build script and start again so as I have to do it very often, you can guess what a pain it is becoming. I was just wondering if there exist any way to speed up development tasks on Share. How do Alfresco developers team do it? What kind of environment do they set up?
I was thinking about creating a new Ant target which hot deploys extension project's content into deployed Share web project, taking into account paths of course; that mechanism must allow the reverse operation by the way. Would that be viable? The idea would be to have a similar deploy mechanism as when you develop regular web projects: when you make any change you just push the "Publish" button and the changes are populated into the server.
I would like to know some tips and ideas, specifically from Alfresco developers team if possible.
PS: I have already read https://forums.alfresco.com/en/viewtopic.php?f=47&t=44850 and https://forums.alfresco.com/en/viewtopic.php?f=48&t=18749.
Two things that speeds up things a lot:
Invest in a jrebel license for class reloading without server restart http://zeroturnaround.com/software/jrebel/
Construct ant tasks that copy webscripts to the target folder and reloads webscripts with curl if necessary.
Example of a task that reloads an Alfresco Share webscript:
<target name="deploy-share-webscripts" depends="Share: Copy files" description="Refreshes the list of webscripts">
<exec executable="curl">
<arg value="-d"/>
<arg value="reset=on"/>
<arg value="http://admin:admin#${share.web.url}/page/console?reset=webscripts"/>
</exec>
</target>
Appending the copying part of the ant task (the src-dirs are declared as properties in the beginning of the buildfile):
<echo message="- Copying java classes" />
<copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
<fileset dir="${warTargetJavaDir}" />
</copy>
<echo message="- Copying resource files" />
<copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
<fileset dir="${warSrcResourcesDir}" >
<include name="**/model/*"/>
<include name="**/templates/**/*"/>
<include name="**/custom-model-context.xml"/>
<include name="**/web-client-config-custom.xml"/>
<include name="**/webclient.properties"/>
<include name="**/aka-model-resourcebundle*"/>
<include name="log4j.properties"/>
</fileset>
</copy>
<echo message="- Copying resource files from amp into war for quick deployment." />
<copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
<fileset dir="${projectAmpResourcesSrcDir}" />
<fileset dir="${projectAmpClassesDir}" />
<fileset dir="${listmanagerAmpResourcesSrcDir}" />
</copy>
<echo message="- Copying config files from amp into war for quick deployment." />
<copy todir="${warWebappTargetClasses}\alfresco\module\Project-amp\" overwrite="false" verbose="true">
<fileset dir="${projectAmpConfigSrcDir}" />
</copy>
</target>
I use the maven alfresco lifecycle http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven for my setup, which also speeds up things. I sure a lot can be added to this topic.
You can avoid copying the webscripts to the tomcat by configuring additional paths for tomcats shared classloader. This is a setting in tomcat/conf/catalina.properties. I set this directly to the projects source directory so there is no need for the compile step.
shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/lib/*.jar,\
/path/to/my/dashlet/src/main/resources,\
I also have the following settings in shared/classes/alfresco/web-extension/share-config-custom.xml to enable automatic refresh of templates and webscripts.
<alfresco-config>
<!-- Global config section -->
<config replace="true">
<flags>
<!-- Developer debugging setting - DEBUG mode for client scripts in the browser -->
<client-debug>true</client-debug>
<!-- LOGGING can be toggled at runtime when in DEBUG mode (Ctrl, Ctrl, Shift, Shift).
This flag automatically activates logging on page load. -->
<client-debug-autologging>false</client-debug-autologging>
</flags>
</config>
<config evaluator="string-compare" condition="WebFramework">
<web-framework>
<!-- Autowire Runtime Settings -->
<autowire>
<!--
Developers can set mode to 'production' or 'development' (to disable; SpringSurf caches,
FreeMarker template caching and Rhino JavaScript compilation.)
-->
<mode>development</mode>
</autowire>
</web-framework>
</config>
</alfresco-config>
Well this is the solution that is working 100% as I expected. I came up with this after the answers of #erik-b and #jorn-horstmann and taking into account some posts I have read.
So basically I have the next Ant target which hot deploys the content of my Share extensions Java project:
<!--
Hot copy individual files into appropriate deployment folder (e.g. $TOMCAT_HOME/webapps/share)
-->
<target name="hotdeploy-tomcat-share" depends="clean, prepare, build-jar" description="Hot copy individual files into appropriate deployment folder (e.g. $TOMCAT_HOME/webapps/share)">
<echo message="Generating and deploying JAR file with custom configuration files" />
<jar destfile="${dist.dir}/${jar.name}">
<!-- Only including configuration XML files such as share-config-custom.xml -->
<fileset dir="${build.jar.dir}" includes="**/META-INF/*.xml" />
</jar>
<copy todir="${tomcat.share.deployment.path}/WEB-INF/lib">
<fileset file="${dist.dir}/${jar.name}" />
</copy>
<echo message="Hot deploying Share files" />
<copy todir="${tomcat.share.deployment.path}/WEB-INF/classes" includeEmptyDirs="false">
<fileset dir="${build.jar.dir}">
<patternset refid="hotdeploy-tomcat-patternset" />
</fileset>
</copy>
</target>
Auto-reloading modules feature must be disabled, otherwise every time you execute the above Ant target Tomcat will reload Share and other web apps deployed. Additionally, I believe it is also possible to hot deploy in the $TOMCAT_HOME/shared/ directory but I haven't tried it out yet.
The Java project I'm using for developing my extensions is this model project: http://code.google.com/p/share-extras/wiki/SampleProject. There is the full build script with the other targets required.
I'm also using this in my share-config-custom.xml:
<!-- Global config section -->
<config replace="true">
<flags>
<!--
Developer debugging setting to turn on DEBUG mode for client scripts in the browser
-->
<client-debug>true</client-debug>
<!--
LOGGING can always be toggled at runtime when in DEBUG mode (Ctrl, Ctrl, Shift, Shift).
This flag automatically activates logging on page load.
-->
<client-debug-autologging>false</client-debug-autologging>
</flags>
</config>
<config evaluator="string-compare" condition="WebFramework">
<web-framework>
<!-- SpringSurf Autowire Runtime Settings -->
<!--
Developers can set mode to 'development' to disable; SpringSurf caches,
FreeMarker template caching and Rhino JavaScript compilation.
-->
<autowire>
<!-- Pick the mode: "production" or "development" -->
<mode>development</mode>
</autowire>
<!-- Allows extension modules with <auto-deploy> set to true to be automatically deployed -->
<module-deployment>
<mode>manual</mode>
<enable-auto-deploy-modules>true</enable-auto-deploy-modules>
</module-deployment>
</web-framework>
</config>
The last XML snippet avoids to refresh webscripts after any change performed on an FTL page, for example.
I have also performed some tests with JRebel but after my experience I would say it doesn't helps a lot in Share development.
There is also interesting stuff in the next articles:
http://blogs.alfresco.com/wp/kevinr/2010/04/07/developer-tips-for-alfresco-share-33/
http://techblog.zabuchy.net/2012/debugging-javascript-in-alfresco/
Hope it helps others.
I'm usually working on private instances so I can afford myself to run exploded apps, so any changes are visible immediately for me. I only need to restart tomcat when I change the datamodel, deploy some new java-backed modules or webscripts or similar. Even though some of those can get reloaded live too.

Cleaning Deployment Assembly with Eclipse Plugin

When faced with the unenviable task of cleaning all generated project artefacts/resources in a stock-standard Java EE/Tomcat configuration, I generally do one (or all) of 3 things:
Project/Clean
Right-click my server, and delete any artefacts (can't remember the exact command)
Source/Clean
I'm now playing around with the Google Eclipse Plugin for Appengine, which uses an inbuilt Jetty server.
Firstly, the plugin doesn't have any options to clean out generated class files before redeploying (well, not that I can see anyway). And secondly, the sever is not available as a configuration option.
Are there any quick fixes available to clean all artefacts/resources in my war/WEB-INF directory?
You can easily make it about one click and not unenviable. Just use ant and pattern matching. Open the ant view in Eclipse and add your file and it's just a click away.
Before 1.7 when app size was more limited, I used to copy almost everything out so I could upload it and serve from the blobstore (GWT permutations galore!). I was doing this alot!!!
see these for details http://ant.apache.org/manual/Types/fileset.html and http://ant.apache.org/manual/Tasks/delete.html
Here's my simple code example:
<target name="moveXprojectGae">
<delete includeemptydirs="true">
<fileset dir="XprojectGae" includes="**/*"/>
</delete>
<move todir="XprojectGae">
<fileset dir="war/XprojectGae">
<exclude name="**.rpc"/>
<exclude name="**nocache.js"/>
</fileset>
</move>
</target>

Error! The first argument to the non-static Java function 'replace' is not a valid object reference

I am trying to get ANT to create an HTML report of a JUNIT test in Eclipse but after I created the ANT build I get the following errors when I run it:
[junitreport] Processing C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\null785926900
[junitreport] Loading stylesheet jar:file:/C:/ANT/apache-ant-1.8.3/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml
What do I need to do to fix this?
Here are the sections of my Build.xml I am trying to run:
<target name="Home">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="Home" todir="${junit.output.dir}"/>
<classpath refid="Home.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
When I got this error I had to right click on my build.xml file in Eclipse, choose the "Run as Ant build..." option (3rd one in the menu) then click the JRE tab and select the "Run in the same JRE as the workspace" option and then proceeded to run the script. For some reason this fixed the problem. I honestly don't know why.
The Eclipse Bug is clearly documented Bug 384757. The analysis suggests that Oracle introduced the bug. I need Java version 7 but JunitReport needs Java version 5 and early versions of Java version 6. The obvious way is to add the "bootclasspath" argument to the Ant junitreport task while the Java problem is fixed by Oracle in a future release. Unfortunately Ant task junitreport does not support the bootclasspath option. Is this something the people supporting Ant could do?
I met this situation while running my java program on Ubuntu 12.04 with *java 1.7.0_51* on Eclipse SDK Juno. I take Bhagyaraj's suggestion which is using apache-ant-1.9.2 instead.
(p.s. The default ant version of Eclipse Juno is *org.apache.ant_1.8.3*, and I use apache-ant-1.9.3)
You may following my steps to setup.
Download apache-ant-1.9.3-bin.zip and extract to a place where you want.
Open your eclipse and choose Window --> Preferences
You can see the Preferences window. On the left hand side please choose ant --> runtime
Now focus on right hand-site of the window. Make sure you are now on Classpath tab and choose Ant Home Entries(Default).The buttons on the right which is Ant Home... is now click-able.
No doubt, click on Ant Home... button and choose the folder where your ant-1.9.3 is. In this step, if you choose wrong folder, Eclipse may show the error message something like Specified Ant home does not contain a "lib" directory. If you choose the right directory, Ant Home Entries(Default) will become **Ant Home Entries()
Don't forget to click apply.
After change those, while you right click on build.xml file and choose Run --> 1 Ant Build, the error message won't show because your ant is now 1.9.3.
I also download apache-ant-1.8.4 to run my build file, but the error can't be solved.
I used the jdk1.6.45 and latest apache-ant-1.9.2-bin\
Problem solved.
As per note on MikeBach
This is bug#,
please read:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757
Fixed in Ant.
Regards,
Bhagyaraj
If you are using Eclipse/JUnit report with JDK 1.7, please use JDK 1.6. There is a bug in JDK 1.7 with Eclipse/JUnit report similar to what you describe. This may be a similar report: https://netbeans.org/bugzilla/show_bug.cgi?id=201022
I've tried using a few different JRE/JDK settings (all 1.6 and 1.7) with various problems (this or lack of access to XSL file in jar) for each.
It's not a perfect solution obviously but I don't seem to run into these issues if the JUnit report is "raw" in the buildfile -- not wrapped in a target.
Poor workaround obviously in that targets are an important aspect of Ant but sometimes for reporting build targets/dependencies aren't so mission critical. It's not so much of an issue for me yet because I'm running these reports in kindof a one-off fashion rather than as part of a build.
The Bug was introduced in Java 7u5 according to this comment.
Another comment explains how to workaround it, changing the bootclasspath. (DISCLAIMER: I didn't try and test this.)
This solution, however, worked fine for me:
Download ant-1.9.4
Eclipse>>Preferences>>Ant>>Runtime>>AntHomeEntries
Remove all 1.8.x classpath entries
Add all libs from 1.9.4 instead
According to Ant Changes, this has been fixed since 1.9.1

Changing dafault Netbeans Platform

Im developing application on top of Netbeans Platform.
In NetBeans IDE it is possible to choose different Netbeans Platform (it can be added under
NetBeans Platform Manager), but i cant find option/property to change default selection.
Is this even supported on Netbeans IDE?
I can't see a way to do this using the default ant based system. However if you use the maven based approach then it is a simple as editing the pom.xml
Solution for ANT based Nb Platform application is to modify ant build file to create custom properties before building application (separate modules). In this solution I create new properties file and fix the pointer in platform properties file to point to it. This file is later imported before building each module.
1) Create/Modify platform-private.properties to set user.properties.file to your custom one (i.e nbproject/private/build.properties). This file is later used to configure properties when building separate modules.
2) Create new user.properties.file (build.properties) and set nbplatform.default.harness.dir and nbplatform.default.netbeans.dest.dir to correct values (those parameters points to folder where nb platform is located - in my case it is located in project basedir under ./nbrc folder)
<project name="..." basedir=".">
<!-- Basedir property must be converted to use forward slashes (for windows machines) -->
<path id="basedir.path">
<pathelement path="${basedir}" />
</path>
<pathconvert targetos="unix" property="basedir.unix" refid="basedir.path"/>
<!-- Initialize path to netbeans platform [located in nbrc folder in project root directory -->
<mkdir dir="nbproject/private"/>
<echo file="nbproject/private/platform-private.properties">user.properties.file=${basedir.unix}/nbproject/private/build.properties${line.separator}</echo>
<echo file="nbproject/private/build.properties">nbplatform.default.harness.dir=${nbplatform.default.netbeans.dest.dir}/harness${line.separator}</echo>
<echo file="nbproject/private/build.properties" append="true">nbplatform.default.netbeans.dest.dir=${basedir.unix}/nbrc${line.separator} </echo>
<!-- .. -->
</project> `