I'm looking for my build to delete the contents of a directory without touching a certain folder. Below is what I'm trying, and it even looks wrong to me...aside from the fact that it bombs when I run it. Do I need to be deleting the contents of the dir explicitly and at the same time exclude my Reports folder?
<delete includeemptydirs="true">
<fileset dir="${PublishLocation}" >
<exclude name="**Reports**"/>
</fileset>
</delete>
Cheers.
It should be:
<delete>
<fileset basedir="${PublishLocation}">
<include name="**/*"/>
<exclude name="**/Reports/**/*" />
</fileset>
</delete>
Please notice the following:
includeemptydirs="true" is default
The attribute for fileset is basedir instead of dir
if you specify <exclude name="**/Reports/**" /> instead of <exclude name="**/Reports/**/*" /> all files named Reports are kept as well
Related
I am trying to deploy a stand-alone build of my JavaFx application and have followed the tutorial from Code.Makery.
I am getting this error:
init-fx-tasks:
[taskdef] Could not load definitions from resource com/sun/javafx/tools/ant/antlib.xml. It could not be found.
do-deploy:
[copy] Copying 1 file to C:_source\MasterGuildWarsCode\build\dist\libs
BUILD FAILED C:_source\MasterGuildWarsCode\build\build.xml:91:
C:_source\MasterGuildWarsCode\resources does not exist.
Total time: 2 seconds
This is the section of my build.xml file that seems to be the problem:
<mkdir dir="dist/resources" />
<copy todir="dist/resources" >
<fileset dir="../resources" />
</copy>
<mkdir dir="package" />
<!-- Icons only for Windows -->
<mkdir dir="package/windows" />
<copy todir="package/windows">
<fileset dir="..">
<include name="AXI.ico" />
<include name="AXI.bmp" />
</fileset>
</copy>
<!-- Icons only for MacOS -->
<mkdir dir="package/macosx" />
<copy todir="package/macosx">
<fileset dir="..">
<include name="AXI.icns" />
</fileset>
</copy>
<fx:resources id="appRes">
<fx:fileset dir="dist" includes="MasterGuildWarsCode.jar"/>
<fx:fileset dir="dist" includes="libs/*"/>
<fx:fileset dir="dist" includes="resources/**"/>
</fx:resources>
Any help is greatly appreciated!
You may want to try this tutorial instead: Efxclipse/Tutorials/AddingE(fx)clipse to eclipse. I've tested it and works perfectly.
Make sure you follow all the steps. Specially this one: "Configure eclipse to use a JDK not a JRE". This will guarantee that you won't have any trouble when you ant build and run your app.
Looking at that tutorial (Step 4), there is a section like this in the build.xml:
<path id="fxant">
<filelist>
<file name="${java.home}\..\lib\ant-javafx.jar"/>
<file name="${java.home}\lib\jfxrt.jar"/>
<file name="${basedir}"/>
</filelist>
</path>
Do those jars exist at the specified paths in the JDK that Ant executes with?
A very similar question was asked here: JAVAFx Build Failed, with suggestion to change from
<file name="${java.home}\lib\jfxrt.jar"/>
to
<file name="${java.home}\lib\ext\jfxrt.jar"/>
I don't know whether that is correct or not, but I do suggest checking those paths.
I have a build_ folders in my directory like build_10320 or build_10321.
I need to write a target clean that deletes such a folder.
I am trying doing this
<target name="clean">
<echo msg="clean directory ./build_" />
<delete includeemptydirs="true" verbose="true" failonerror="false" >
<fileset dir="./">
<include name="./build_*" />
</fileset>
</delete>
</target>
But this doesn't work. Kindly help.
Phing still doesn't have the <dirset> feature working (which would be the natural choice). You can however make this work using <exec> & the relevant command for deleting files from your operating system.
For linux:
<exec command = "rm -rf ./build_*" passthru = "true" />
A <fileset> returns, as the name suggests, only files.
There is an undocumented <dirset> type that unfortunately cannot be used with <delete> at the moment.
With Phing 3.x you can use <dirset> inside the <delete> task.
<project name="delete-with-dirset" default="clean" basedir=".">
<target name="clean">
<echo msg="clean directory ./build_" />
<delete includeemptydirs="true" verbose="true" failonerror="false">
<dirset dir="./">
<include name="./build_*" />
</dirset>
</delete>
</target>
</project>
How can I craft up a NAnt include/exclude pattern to include the root /bin directory and its files, but exclude bin directories that are children of other directories?
<target name="createArtifacts">
<copy todir="${destdir}" includeemptydirs="false">
<fileset basedir="${sourcedir}">
<include name="**" /> <!-- this will get the root \bin folder -->
<exclude name="**\bin\*.pdb" />
<exclude name="**\bin\*.xml" />
...
</fileset>
</copy>
</target>
I want this to exclude any bin folder that is not the root bind folder:
<exclude name="\**\bin\" />
But it ends up removing the root bin as well.
You have been very close to the answer. You should just add an asterisk as a very first character in the exclude pattern. Taking your sample, this will loot like this:
<target name="createArtifacts">
<copy todir="${destdir}" includeemptydirs="false">
<fileset basedir="${sourcedir}">
<include name="**" />
<exclude name="*\**\bin\*.pdb" />
<exclude name="*\**\bin\*.xml" />
...
</fileset>
</copy>
</target>
That first asterisk basically means "we don't want to take first-level folder into consideration".
I have Three GWT projects. 2 common GWT(Bootstrap & Data Transfer Objects) projects, it doesnt contain any UI part. So, I want to compile these two projects and create jar and want to include it in third GWT project. I have done in Eclipse[Project->Export->Jar file]. It works fine. I want do it command line or through ant build.xml. Please if you know anyone, can you help on this.
We have a similar case and here is the target we use for building an external jar for our task engine. This will build you a jar from command line that can be included in other projects. In our case we have a large project that contains all of our domain objects and some services. We wanted to include this into our task engine.
<target name="taskengine-jar" depends="enhance">
<mkdir dir="build" />
<mkdir dir="build/META-INF"/>
<copy todir="build/META-INF">
<fileset dir="src/META-INF">
<include name="persistence.xml" />
<include name="server.properties" />
<include name="crypto.properties" />
<include name="sqlDrivers.xml" />
</fileset>
</copy>
<jar destfile="taskengine-jobs.jar">
<fileset dir="war/WEB-INF/classes">
<include name="com/hp/vf/server/**" />
<include name="com/hp/vf/shared/**" />
</fileset>
<fileset dir="build">
<include name="META-INF/**" />
</fileset>
<zipgroupfileset dir="war/WEB-INF/lib">
<include name="axis2.jar" />
<include name="javamail-1.4.4.jar" />
<include name="commons-pool-1.6.jar" />
<include name="openjpa-all-2.2.0.jar" />
<include name="commons-logging-adapters-1.1.1.jar" />
<include name="commons-logging-api-1.1.1.jar" />
<include name="commons-vfs2-2.0.jar" />
<include name="postgresql-9.0-801.jdbc4.jar" />
<include name="poi-3.8-beta5-20111217.jar"/>
<include name="poi-ooxml-schemas-3.8-beta5-20111217.jar"/>
<include name="poi-ooxml-3.8-beta5-20111217.jar"/>
<include name="itext-2.1.7.jar"/>
<include name="REngine.jar" />
<include name="Rserve.jar" />
<include name="jsoup-1.6.1.jar" />
<include name="jfreechart-1.0.13.jar" />
<include name="jcommon-1.0.16.jar" />
</zipgroupfileset>
<fileset dir="war/WEB-INF/lib">
<include name="addressing-1.1.1.mar" />
<include name="rampart-1.1.mar" />
</fileset>
</jar>
<delete dir="build" />
</target>
I think, the most easy and flexible way is to use Maven. Each project represents the separate Maven artefact which is stored in your local repository. And only one thing you should do in your main project is to add couple of dependencies to your POM file. That's it. I use this schema for a long time.
Pretty new to this so bear with me. I've gotten my Ant build.xml to run and populate everything that I want, but my content (js, css, jsp, etc) is just jammed into the WAR at its topmost directory. I'm looking to put this content into the WEB-INF folder that I would need to make within the war. Here's what I have so far as a reference. If I could just see an example of how to do this I think I would be good. Tried to follow this thread, is that dist setup what I am missing??
<war warfile="${build}/${project.name}.war" webxml="${appconf}/web.xml">
<classes dir="${appconf}/classes" />
<fileset dir="${appcontent}" includes="jsp/**,js/**,images/**,css/**,tg/**" excludes="**/*.~js,**/*.~jav,**/*.java,cvs,annotation">
<patternset id="jsp_images_package">
<include name="**/*.jsp,**/*.js,**/*.gif,**/*.html,**/*.css"/>
<exclude name="**/*.~js,**/*.~jav"/>
</patternset>
</fileset>
<fileset dir="${appcontent}" includes="WEB-INF/lib/*.jar,WEB-INF/*.jar"/>
<fileset dir="${appcontent}" includes="WEB-INF/lib/*.css"/>
<fileset dir="${appcontent}" includes="docs/*.doc"/>
</war>
What you want to use in this case is <zipfileset>. It should look something like this (Your structure is weird, so I can't tell exactly where you want files).
<war warfile="${build}/${project.name}.war" webxml="${appconf}/web.xml">
<classes dir="${appconf}/classes" />
<zipfileset dir="${appcontent}/jsp" includes="**/*.jsp" prefix="WEB-INF"/>
<zipfileset dir="${appcontent}/js" includes="**/*.js" prefix="WEB-INF"/>
<zipfileset dir="${appcontent}/css" includes="**/*.css" prefix="WEB-INF"/>
<fileset dir="${appcontent}">
<include name="docs/*.doc"/>
<include name="images/**"/>
<include name="WEB-INF/*.jar"/>
<include name="WEB-INF/lib/*.jar"/>
<include name="WEB-INF/lib/*.css"/>
</fileset>
</war>