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>
Related
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>
When I want to compile my GTW project I got this output in my console:
ant -f "C:\\Users\\Donatas\\Desktop\\b2b\\servlet" "-Dbrowser.context=C:\\Users\\Donatas\\Desktop\\b2b\\servlet" -DforceRedeploy=false -Ddirectory.deployment.supported=true -Dnb.internal.action.name=run run
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
wsimport-init:
wsimport-client-ic:
files are up to date
wsimport-client-generate:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
GWT4NB https://github.com/gwt4nb/gwt4nb
GWT installation directory: C:\Users\Donatas\Desktop\b2b\lib\gwt-2.7.0
init:
do-gwt-compile-15:
GWT Compiling client-side code.
Error: Could not find or load main class com.google.gwt.dev.GWTCompiler
C:\Users\Donatas\Desktop\b2b\servlet\nbproject\build-gwt.xml:326: The following error occurred while executing this line:
C:\Users\Donatas\Desktop\b2b\servlet\nbproject\build-gwt.xml:356: Java returned: 1
My build-gtw.xml 326 line is:
<target name="-pre-dist" depends="-gwt-define-compile-unneeded">
<antcall target="-gwt-print-dir"/>
326: <antcall target="do-gwt-compile-15" />
<antcall target="do-gwt-compile-16" />
<antcall target="do-gwt-compile-17" />
<antcall target="do-gwt-compile-20" />
<antcall target="do-gwt-compile-23" />
<antcall target="do-gwt-compile-25" />
</target>
My build-gtw.xml 356 line is:
<target name="do-gwt-compile-15" if="gwt.version.15"
unless="gwt.compile.unneeded" depends="-init-gwt-dir">
<!-- You can override this property in the 'gwt.properties' file -->
<property name="gwt.compiler.output.style" value="OBFUSCATED"/>
<property name="gwt.compiler.logLevel" value="WARN"/>
<echo>GWT Compiling client-side code.</echo>
<java failonerror="true"
classname="com.google.gwt.dev.GWTCompiler" fork="true"
line 356: jvmargs="${gwt.compiler.jvmargs}">
<classpath>
<!--
GWT libraries are mentioned here explicitly so they are always
at the front of the class path.
-->
<pathelement path="${gwt.dir}/gwt-user.jar"/>
<fileset dir="${gwt.dir}">
<include name="gwt-dev-*.jar"/>
</fileset>
<pathelement path="${gwt.dir}/gwt-servlet.jar"/>
<pathelement path="${javac.classpath}"/>
<pathelement path="${src.dir}"/>
<pathelement path="${build.classes.dir}"/>
</classpath>
<arg value="-out"/>
<arg path="${build.web.dir}/"/>
<arg value="-style"/>
<arg value="${gwt.compiler.output.style}"/>
<arg value="-logLevel"/>
<arg value="${gwt.compiler.logLevel}"/>
<arg line="${gwt.compiler.args}"/>
<arg line="${gwt.module}"/>
</java>
<property name="gwt.output.dir" value="${gwt.module}"/>
<move todir="${build.web.dir}/${gwt.output.dir}">
<fileset dir="${build.web.dir}/${gwt.module}"/>
</move>
<touch file="${build.dir}/gwtc.run"/>
</target>
I know that GWTCompiler is deprecated, but how to change it if I change in Compiler I got error that my console arguments like [-out] is not recognized. So how to compile it. I'm using GTW 2.7 version.
It looks like a bug in GWT4NB. It should invoke do-gwt-compile-25 for GWT 2.7, not do-gwt-compile-15.
Try manually updating build-gwt.xml to add a 2.7 case to gwt.version.25: https://github.com/ksfreitas/gwt4nb/blob/1001c4fa8e9f6c0fed3c79ba19320b315737357f/trunk/src/org/netbeans/modules/gwt4nb/resources/build-gwt.xml#L139-L147
But it might not work, due to another bug (issue still open, don't know if it's been fixed or not, I don't use Netbeans): https://github.com/ksfreitas/gwt4nb/issues/32 (a quick grep in the code seems to indicate you could define gwt.version=2.6 or gwt.version=2.7 in nbproject/gwt.properties of your project, not sure if it'll work or be overwritten by the Netbeans plugin)
The compiler hasn't been called GWTCompiler since GWT 1.7 or so. Use com.google.gwt.dev.Compiler as the classname instead.
<!--
Check for GWT 2.5
-->
<condition property="gwt.version.25" value="true">
<or>
<equals arg1="${gwt.version}" arg2="2.5"/>
<equals arg1="${gwt.version}" arg2="2.6"/>
<equals arg1="${gwt.version}" arg2="2.7"/> --> add this line
</or>
</condition>
I added version 2.7 on build-gwt.xml and it works for me :D
Open build-gwt.xml
Then,
Try removing:
<antcall target="do-gwt-compile-15" />
Run, This should work
I just started using NAnt today, I followed some of the examples. I am having a hard time with one issue:
Its saying: "Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work."
Now I was able to track down the project. Here is my directory structure:
c:\dev\stockclockbuild -> this is where the solution and build file is located.
So I run the command:
nant -buildfile:c:\dev\stockclockbuild\stocks.build
I have a project that it located in c:\dev\_sharedlibs\mdrlibs called "MDR.StockPlatform" which seems to get included, but within that project file I found the project (dependency) that has the GUID mentioned in the error.
That project is called "MDR.Base" but its located in the same folder as MDR.StockPlatform.
Also if I were to open this solution and build it in visual studio it builds without errors.
Here is the complete verbose output:
c:\Dev\_Misc\Tools\nAnt\bin>nant -buildfile:c:\dev\stockclockbuild\stocks.build
NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012)
Copyright (C) 2001-2012 Gerry Shaw
http://nant.sourceforge.net
Buildfile: file:///c:/dev/stockclockbuild/stocks.build
Target framework: Microsoft .NET Framework 4.0
Target(s) specified: rebuild
clean:
build:
build.stockclock:
[solution] Starting solution build.
[solution] Loading projects...
[solution] Loading project 'c:\dev\stockclockbuild\StockClock.Common\StockClock
.Common.csproj'.
[solution] Using MSBuild version 4.0.30319.1.
[solution] Loading referenced project 'c:\dev\_SharedLibs\MDRLibs\MDR.StockPlat
form\MDR.StockPlatform.csproj'.
BUILD FAILED
Project with GUID '{32845370-6F32-411F-B4C5-383F9C3EDE29}' must be included for
the build to work.
Total time: 0.6 seconds.
Here is a copy of the build file:
<project name="Solution Build Example" default="rebuild">
<property name="configuration" value="release"/>
<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
<include name="**/bin/**" />
<include name="**/obj/**" />
<include name="**/*.suo" />
<include name="**/*.user" />
</fileset>
</delete>
</target>
<target name="build" description="Build all targets.">
<call target="build.stockclock"/>
</target>
<target name="rebuild" depends="clean, build" />
<target name="build.stockclock">
<solution configuration="${configuration}" solutionfile="Stockclock.sln" verbose="true">
</solution>
</target>
</project>
I'm assuming you're using a modern IDE, and from the NAnt Documentation:
Note: Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and
projects are supported. Support for .NET Compact Framework projects is also not
available at this time.
In my NAnt scripts I use the NauckIT MSBuild task:
<msbuild projectFile="${solution.file}" targets="Build" verbosity="Quiet">
<property name="Configuration" value="${build.configuration}" />
<property name="Platform" value="${build.platform}" />
<arg value="/flp:NoSummary;Verbosity=normal;LogFile=${build.log}" />
<arg value="/p:SignAssembly=true" if="${isReleaseBuild}" />
<arg value="/p:AssemblyOriginatorKeyFile=${solution.keyfile}" if="${isReleaseBuild}" />
<arg value="/p:DelaySign=false" if="${isReleaseBuild}" />
</msbuild>
However that is a personal preference as you could also use the NAnt exec task and call msbuild directly.
Theres about 20 diff ant files, that make up the build. Im not sure how to configure run-jetty-runs eclipse plugin to use this information. Can anyone point me towards a tutorial or some documentation:
<target name="run-jetty" depends="build" description="Runs application in included Jetty container">
<property file="credentials.properties" />
<property name="jetty.port" value="8080" />
<java jar="${jetty.dir}/start.jar" fork="true" dir="${basedir}" maxmemory="512M">
<arg value="${jetty.conf.dir}/jetty.xml" />
<arg value="${jetty.conf.dir}/jetty-jndi.xml" />
<sysproperty key="jetty.port" value="${jetty.port}" />
<jvmarg value="-XX:MaxPermSize=128m" />
<jvmarg value="-Dfile.encoding=UTF-8" />
<jvmarg value="-Djetty.home=${jetty.dir}" />
<jvmarg value="-Djetty.datasource.lanter.username=${jetty.datasource.lanter.username}" />
<jvmarg value="-Djetty.datasource.lanter.password=${jetty.datasource.lanter.password}" />
<jvmarg value="-Djetty.datasource.vs.username=${jetty.datasource.us.username}" />
<jvmarg value="-Djetty.datasource.vs.password=${jetty.datasource.us.password}" />
<jvmarg value="-DSTOP.PORT=${jetty.stop.port}" />
<jvmarg value="-DSTOP.KEY=${jetty.stop.key}" />
</java>
</target>
You have two options:
Start the app using the run-jetty-run plugin; this will give you an entry in the debug menu which means that Jetty (and the app) will be launched in the debugger if you select it.
Use the information in the code block above to create your own run configuration. The classpath should already be correct; you just need to select the correct main class (open META-INF/MANIFEST.MF in start.jar to find that out). Replace all the properties with their values and put each into a new line into the argument text fields of the run configuration.
On the tab "Common", you can set a file name and save the launch config as a file in your project, so everyone working on it will get it.
I use:
<java failonerror="true" classname="com.google.web.bindery.requestfactory.apt.ValidationTool">
<arg path="${path.to.ouput.jar}" />
<arg value="com.my.RequestFactory" />
<classpath>
<path refid="my_classpath" />
</classpath>
</java>
my_classpath has all requestfactory-client.jar, requestfactory-server.jar, requestfactory-apt.jar + my source & the jar produced from it in the path (that's confirmed with just printing it), but I still get:
[java] error: Unable to find RequestFactory built-in type. Is requestfactory-[client|server].jar on the classpath?
What could be wrong here?
For me, this works only, if I specify <javac fork="true" ...
From the official ant documentation on the java task:
If odd things go wrong when you run this task, set fork="true" to use a new JVM.
Without any deep investigation, I would say it's most likely a classloader problem.