Ant can't seem to link to groovy properly in NetBeans 8.2 - netbeans

In netBeans 8.2, I'm having an issue reading groovy inside a build.xml file.
I have a project in which I run my script via a build.xml using the build-in Ant 1.9.7.
In it, for my groovy task, I set the following:
<property environment="env" />
<path id="groovy.classpath">
<fileset dir="${env.GROOVY_HOME}/embeddable" />
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath" />
For environment variable {env.GROOVY_HOME}, I have set the following in windows environment variable:
GROOVY_HOME with the value C:\Program Files (x86)\Groovy\Groovy-2.4.10
Yet I'm still having an error ""Script failed" when reaching the step with Groovy at the following stage in the build.xml file:
<groovy>
def corePlatformList = []
[Groovy code here...]
</groovy>
I know the script is working fine as it does run perfectly in Eclipse and IntelliJ.
It would seem ant can't link with Groovy 2.4.10 for some reason.

I believe that you have some trivial error.
You need to include the library file.
Change from:
<path id="groovy.classpath">
<fileset dir="${env.GROOVY_HOME}/embeddable" />
</path>
To:
<path id="groovy.classpath">
<fileset dir="${env.GROOVY_HOME}/embeddable">
<include name="**/groovy-all-*.jar"/>
</fileset>
</path>
EDIT: based on OP comments
Here is the complete build.xml and I can see it working.
<project name="MyProject" default="runscript" basedir=".">
<path id="groovy.classpath">
<fileset dir="d:/softwares/groovy-2.4.5/embeddable">
<include name="**/groovy-all-*.jar"/>
</fileset>
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath" />
<target name="runscript"
description="compile the source">
<groovy>
def corePlatformList = [1,2,3,4]
println corePlatformList
</groovy>
</target>
</project>

Related

eclipse.buildScript Complete Example Script for headless build

I am trying to generate a build script for a plugin outside the IDE
Below is mybuild.xml
<project name="com.foo.poo" xmlns='antlib:org.apache.tools.ant'>
<target name="build.plugin">
<antcall target="generateBuildScript" />
<ant dir="${workspace.dir}/${project.name}"
antfile="build.xml"
target="build.update.jar" />
<copy todir="${eclipse.dir}/plugins">
<fileset dir="${workspace.dir}/${project.name}">
<include name="*.jar"/>
</fileset>
</copy>
</target>
<target name="generateBuildScript">
<eclipse.buildScript elements="plugin#${project.name}"
buildDirectory="${workspace.dir}"
baseLocation="${eclipse.dir}"
configInfo="linux,gtk,win32,win32,x86"/>
</target>
</project>
Expecting build.xml to be generated Please Guide me
When I run above script
$java -jar {$Eclipse.Dir}/plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar -application org.eclipse.ant.core.antRunner -buildfile <Project_path>\mybuild.xml
I nothing is happening on build success.
Here i have found the answer may help some new bees like me..
<project name="com.foo.poo" xmlns='antlib:org.apache.tools.ant'>
...
</project>
As there is no default set, it is not generating the required jar file so
modified only the first line as
<project name="com.foo.poo" default="build.plugin" xmlns='antlib:org.apache.tools.ant'>
...
</project>
now the required jar is generated under plugin folder and even copied to plugin folder of eclipse.
baseLocation : Target Plugins Directory absolute path.
buildDirectory: Absolute path to the plugin folder in which the Plugin Project is present.

Sencha CMD Ant integration for custom web application

We are trying to integrate the Sencha CMD to our custom application ant script( build.xml) inorder to do minification of js files. Could you please let us know the steps needs to be followed for minifcation of js files . It could be useful if you could provide sample file to achieve this. We tried the following steps as per the manual to just include the sencha.jar which resulted in error "init-sencha-cmd:
[taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml."
I have added the target "init-sencha-cmd" as dependency to target "build" and a property build.dir (basedir="." configured in the start of xml)
<target name="build" depends="init, dependencies, pre-compile, compile, post-compile,init-sencha-cmd" description="Builds the project." />
<property name="build.dir" location="${basedir}"/>
<target name="init-antcontrib">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${Bundles.WebCharts.lib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
</target>
<target name="init-sencha-cmd" depends="init-antcontrib">
<taskdef resource="com/sencha/ant/antlib.xml" classpath="/Users/hatamm/bin/Sencha/Cmd/5.0.3.324/sencha.jar"/>
</target>

Add Xom to managed URI In res

I am Working on ILOG.Currently I am using an Ant script for deploying ruleapp to res.My Problem is when I am deploying it is working fine but I want to add xom automatically to " ADD Managed URI" tab present in res. xom is getting attached to ruleapp but i want to get it attached to managed uri section.
Thanks in advance.
Have you tried this way - Got it from IBM Help.I have not tried it, but looks like, it should work. ( IBM ODM.8.0.1)
<target name="deployruleappwithxom">
<res-deploy hostname="${hostname}" portnumber="${portnumber}" webapp="${webapp}" userid="${userid}" password="${password}" file="my-ruleapp.jar">
<xompath rulesetpath="/MyRuleApp/MyRuleset">
<fileset dir="${lib}">
<include name="**/myxom.jar" />
</fileset>
</xompath>
<xompath rulesetpath="/AnotherRuleApp/AnotherRuleset">
<fileset dir="${otherlib}">
<include name="**/otherxom.jar" />
</fileset>
</xompath>
</res-deploy>
</target>
if you just looking for managing xomuri property, you can try this.
<target name="runloanvalidation">
<res-deploy-xom
hostname="localhost"
portnumber="9080"
webapp="res"
userid="resAdmin"
password="resAdmin"
jarMajorVersion="false"
libName="person"
outputRulesetProperty="ruleset.managedxom.uris">
<xompath>
<fileset dir="hello">
<include name="*.jar"/>
</fileset>
</xompath>
</res-deploy-xom>
<echo message="Resulting property: ${ruleset.managedxom.uris}"/>
</target>
And for more information, you can visit this.
http://www-01.ibm.com/support/knowledgecenter/#!/SSQP76_8.6.0/com.ibm.odm.dserver.rules.ref.res/ant_tasks/con_ant_res_deploy_xom.html

script to execute the eclipse PDE Tools > Build site

i want to write a script to do the Build site of plugin Update site site.xml?
i could not find a way to do this?
i found very easy to build a plugin feature. I can automatically creat the ant file build.xml via eclipse but i could not find the same for the update site.xml
thank you all
stefania
Are you trying to build an Eclipse plugin from Ant? You want to use the Ant4Eclipse external add-on for Ant. It lets you build the run-configurations you've made in Eclipse (right click>run as>...) from your .project file. You can download it here and there is a tutorial here.
I attempted to do what you're asking at a previous job without using Ant4Eclipse, I don't remember how I got it working, but I do remember it being extremely difficult.
Edit: you can build an Eclipse update site from the command line, which can be run from Ant. There is some [possibly out of date] documentation here, but I found you a sample from an Apache projects build.xml:
<target name="build-site" depends="init">
<copy todir="target/eclipse-update-site/web" preservelastmodified="true">
<fileset dir="web"/>
</copy>
<copy todir="target/eclipse-update-site" file="index.html" preservelastmodified="true"/>
<copy todir="target/eclipse-update-site" file="site.xml" preservelastmodified="true"/>
<!-- copy all the features to the target -->
<copy todir="target/eclipse-update-site/features" preservelastmodified="true" >
<fileset dir="features"/>
</copy>
<!-- see http://wiki.eclipse.org/Update_Site_Optimization -->
<java jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher.jar" fork="true" failonerror="true"
maxmemory="256m">
<arg line="-application org.eclipse.update.core.siteOptimizer"/>
<arg line="-digestBuilder -digestOutputDir=target/eclipse-update-site"/>
<arg line="-siteXML=target/eclipse-update-site/site.xml"/>
</java>
</target>

Running P2 Ant tasks outside Eclipse

I got ant script running fine inside Eclipse
Here is a piece of it :
<p2.composite.repository failOnExists="true">
<repository location="file:/${basedir}/compRepo" name="Repository description goes here" />
<add>
<repository location="http://url/Eclipse/repo/Galileo-3.5.1/" />
<repository location="http://another-url/Java/repo/4.0/" />
<repository location="${diag.location}" />
</add>
</p2.composite.repository>
But I would like Hudson CI server to be able to run it, but, no matter all the jars I put in ANT_HOME/lib I can't get this task to run in a simple command line ant...
I got stuck with this error :
C:\workspaces\workspace\project\junit.script\createCompRepo.xml:10: Problem: failed to create task or type p2.composite.repository
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Where are defined the p2 ant tasks ? Is there a way to run them outside Eclipse ?
Thank you very much for you help !
Anthony
By reading this thread and the P2 Publisher documentation, it should be in org.eclipse.equinox.launcher_*.jar
Example of a P2 task (not an ant task here) just for the -jar argument:
java -jar <targetProductFolder>/plugins/org.eclipse.equinox.launcher_*.jar
-application org.eclipse.equinox.p2.publisher.UpdateSitePublisher
-metadataRepository file:/<some location>/repository
-artifactRepository file:/<some location>/repository
-source /<location with a site.xml>
-configs gtk.linux.x86
-compress
-publishArtifacts
The P2 Ant tasks are described here, and in the Eclipse help.
The OP Anthony43 adds in the comments:
I just want to run an an ant target with p2 taskdefs, outside of eclipse.
I found out that I should use antRunner, using such a command line :
./eclipse -vm /opt/sun-java2-6.0/bin/java -nosplash \
-data ${java.io.tmpdir}/workspace -consolelog \
-application org.eclipse.ant.core.antRunner \
-f /path/to/scripts/partialMirrorFromRepo.xml
But Andrew Niefer (Eclipse committer on PDE/Build, p2, & Equinox Framework) adds:
The p2 tasks need to be run inside an osgi environment and won't work in a normal ant run.
That is why you need to use the org.eclipse.ant.core.antRunner application.
Starting with "java -jar launcher.jar" is just an alternate method to invoking the eclipse executable.
martin jakubik mentions:
I would have liked to see a command that I could cut&paste and that put everything together.
What I used was:
java -jar <eclipse-install-directory>\eclipse\plugins\org.eclipse.equinox.launcher_*.jar -application org.eclipse.ant.core.antRunner.
Note that I could not figure out what <targetProductFolder> was, so I used <eclipse-install...> instead.
I created a small Ant macro for that exact purpose
<path id="equinox.launcher.path">
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar" />
</fileset>
</path>
<macrodef name="antRunner">
<!-- Ant script location -->
<attribute name="antFile" />
<!-- the arguments for the script that is executed -->
<attribute name="args" default=""/>
<sequential>
<java
classname="org.eclipse.equinox.launcher.Main"
fork="true"
failonerror="true">
<arg line="-application org.eclipse.ant.core.antRunner" />
<arg line="-f #{antFile}" />
<arg line="#{args}"/>
<classpath refid="equinox.launcher.path" />
</java>
</sequential>
</macrodef>
All the p2 tasks NEED the eclipse runtime (as explicitly stated in the eclipse help mentioned above), so you definitely need to use eclipse.
The only way to get round of it would be to analyze the eclipse code, extract what is needed and create your own build system with it.
Just to complete the example of Jarek Przygódzki here is my solution, using his ant-file. I'm not well versed in using ant, so there might be potential for optimisation.
This aproach is used headless on a server without GUI, nevertheless I had to install eclipse. Installation with apt-get wasn't working, so it's better to install manual (download and untar).
First antfile assembles names, versions, etc...
Second antfile is called from first antfile and creates composite repositories.
First antfile:
<project name="project">
<!-- ....do some other stuff...-->
<target name="p2.composite.add">
<!--Call macro for child repo-->
<antRunner
name="${site.composite.name}"
location="${composite.repository.directory}"
child="${child.repository}"
/>
<!--Call macro for main repo-->
<antRunner
name="${main.site.composite.name}"
location="${main.composite.repository.directory}"
child="${majorMinorVersion}"
/>
</target>
<!--Eclipse installation path-->
<path id="equinox.launcher.path">
<fileset dir="/usr/share/eclipse/plugins">
<include name="org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar" />
</fileset>
</path>
<macrodef name="antRunner">
<attribute name="name"/>
<attribute name="location"/>
<attribute name="child"/>
<sequential>
<java
classname="org.eclipse.equinox.launcher.Main"
fork="true"
failonerror="true">
<arg line="-application org.eclipse.ant.core.antRunner" />
<arg line="-f addCompositeInternal.ant run" />
<arg line="-Dcomposite.name=#{name}"/>
<arg line="-Dcomposite.location=#{location}"/>
<arg line="-Dcomposite.child=#{child}"/>
<classpath refid="equinox.launcher.path" />
</java>
</sequential>
</macrodef>
</project>
Second Antfile, named addCompositeInternal.ant
<project name="composite">
<target name="run">
<add.composite.repository.internal
composite.repository.location="${composite.location}"
composite.repository.name="${composite.name}"
composite.repository.child="${composite.child}"
/>
</target>
<!-- = = = = = = = = = = = = = = = = =
macrodef: add.composite.repository.internal
= = = = = = = = = = = = = = = = = -->
<macrodef name="add.composite.repository.internal">
<attribute name="composite.repository.location" />
<attribute name="composite.repository.name" />
<attribute name="composite.repository.child" />
<sequential>
<echo message=" " />
<echo message="Composite repository : #{composite.repository.location}" />
<echo message="Composite name : #{composite.repository.name}" />
<echo message="Adding child repository : #{composite.repository.child}" />
<p2.composite.repository>
<repository compressed="false" location="#{composite.repository.location}" name="#{composite.repository.name}" />
<add>
<repository location="#{composite.repository.child}" />
</add>
</p2.composite.repository>
<echo file="#{composite.repository.location}/p2.index">version=1
metadata.repository.factory.order=compositeContent.xml,\!
artifact.repository.factory.order=compositeArtifacts.xml,\!
</echo>
</sequential>
</macrodef>
</project>