I'm working on an Ant script to help with a Wordpress deployment (I know...). The idea here is to:
delete the entire vendor directory.
delete the entire public_html/wp directory.
delete everything from public_html/content/plugins except for the one PHP file: public_html/content/plugins/w3tc-wp-loader.php.
This is what I've tried (along many variations):
<delete failonerror="false" quiet="false" includeEmptyDirs="true">
<fileset dir="vendor" />
<fileset dir="public_html/wp" />
<fileset dir="public_html/content/plugins">
<exclude name="w3tc-wp-loader.php" />
</fileset>
</delete>
This kinda works:
it deletes the contents of the vendor directory except for a few .gitignore files that exist in subdirs, so those files and their parent dirs still exist (i.e. vendor/composer/installers/.gitignore).
public_html/wp is deleted, as expected.
public_html/content/plugins is left containing a bunch of subdirectories, each of which is empty (except one has a .gitignore file). The excluded file noted in the Ant script is left, as expected.
Any idea why a) the empty dirs aren't removed and b) .gitignore files seem to stay as well (as well as their parent dirs)? What am I doing wrong?
What about this way:
<delete failonerror="false" quiet="false" includeemptydirs="true">
<fileset dir="${root}" defaultexcludes="false">
<include name="vendor/**" />
<include name="public_html/wp/**" />
<include name="public_html/content/plugins/**" />
<exclude name="public_html/content/plugins/w3tc-wp-loader.php" />
</fileset>
</delete>
where ${root} is the parent directory for vendor and public_html.
defaultexcludes="false" will make sure your .gitignores will be deleted as well.
Your .gitignore files are excluded by default http://ant.apache.org/manual/dirtasks.html#defaultexcludes. To delete them add defaultexcludes="false" to fileset
Related
I have a .net core project file (*.csproj) like this:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<!-- Create RS.cs -->
<ItemGroup>
<ResourceGeneratorInputs Include="strings.resx" />
<ResourceGeneratorOutputs Include="RS.cs" />
</ItemGroup>
<Target Name="GenerateTheResourceFile"
BeforeTargets="PrepareForBuild"
Inputs="#(ResourceGeneratorInputs)"
Outputs="#(ResourceGeneratorOutputs)">
<Exec Command="ResourceStringGenerator.exe strings.resx RS.cs " />
</Target>
</Project>
This projects has a target that generates a csharp code file called RS.cs, which also must be compiled.
The problem is the file is generated too late. The build engine has already read the list of files in the project directory, and the RS.cs file gets ignored.
I have tried changing the BeforeTargets attribute to various other Targets with no luck at all. (Described here: https://learn.microsoft.com/en-us/dotnet/core/tools/csproj#build-events)
I've tried turning off automatic inclusion of files too:
<PropertyGroup>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
and making my own list of files to compile. But that didn't work either. The RS.cs file was still generated too late.
The new project file format seems to be so eager to get the list of files, that it seems to leave no room for auto-generated files.
What is the work-around here?
The static portion of a project file is always evaluated before targets run.
However, you can also add items inside your target:
<Target Name="GenerateTheResourceFile"
BeforeTargets="PrepareForBuild"
Inputs="#(ResourceGeneratorInputs)"
Outputs="#(ResourceGeneratorOutputs)">
<Exec Command="ResourceStringGenerator.exe strings.resx RS.cs " />
<ItemGroup>
<EmbeddedResource Include="strings.resx" Exclude="#(EmbeddedResource)" />
<Compile Include="RS.cs" Exclude="#(Compile)" />
</ItemGroup>
</Target>
The "exclude" part ensures that the file isn't added twice if it was already picked up during static evaluation (i.e. additional builds)
I'm using Phing to run phpunit on a folder called runtest which contains all my phpunit tests.
My build.xml is below:
<project name="TiVO" default="build">
<target name="clean">
<delete dir="build"/>
</target>
<target name="prepare">
<mkdir dir="build/logs"/>
</target>
<target name="phpunit">
<phpunit bootstrap="runtest/initalize.php" printsummary="true" haltonfailure="true">
<formatter todir="build/logs" type="xml"/>
<batchtest>
<fileset dir="runtest">
<include name="*.php"/>
</fileset>
</batchtest>
</phpunit>
</target>
<target name="build" depends="clean,prepare,phpunit"/>
</project>
The problem is it does not run any php files (e.g. Channel.php, Video.php) which all end in .php and only works if I change the include name to:
<include name="*Test.php"/>
Then it runs the one file MyChannelTest.php which matches the pattern *Test.php which is fair enough.
How do i change my build.xml to run any file which ends in .php in the runtest directory?
Thanks
Apologies the include name filter was working there was a problem with the first phpunit file when it was executing it caused the build to fail and no tests to execute after it there was no error reported by php unit making it look like it hadn't executed any files.
When i set the output folder in FDT, this is always REALTIVE to the project folder, even if it has a forward slash...
ex: /Users/paolo/deploy will create the folder in /User/paolo/my_project/Users/paolo/deploy
first.... WHY?????
second: is there a way to set this folder as ABSOLUTE?
many thanx
The reason is to enable multiple developers to develop on the same project. The path is saved in the project. If you share the project via CVS/SVN other developers would need to have the same path. Absolute paths are a bad idea when developing in a team.
I don't know if there is a way to force an absolute path, but I doubt it.
Edit:
I remember there was the possibility to attach an ant script to an run configuration to be executed each time the project is build. You might be able to write the ant script such that it copies the output files to an absolute directory.
In your launch configuration there is a tab for Ant tasks. Add a post-compile ant script, here's an example:
<project name="copy files">
<property name="from" value="../bin"/>
<property name="to" value="/Users/username/deploy>
<target name="Copy All">
<copy todir="${to}" >
<fileset dir="${from}">
<exclude name="Test.swf"/>
</fileset>
</copy>
</target>
</project>
With NAnt script, I'm looking for solution to remove all folder named .svn recursively in a given folder.
Using delete task just delete one file/folder but not recursively.
Please help if you know how to.
This should work:
<delete>
<fileset defaultexcludes="false" >
<include name="**/.svn/**" />
</fileset>
</delete>
I'm attempting to compile a Flex application from an ANT script, inside of Eclipse (CFBuilder, based on Eclipse), and I've run into this error:
Could not load definitions from resource flexTasks.tasks. It could not be found.
I haven't been able to find anything that gives directions on where this file (flexTasks.tasks) should be copied to, if it's needed at all. Some places indicate that it should be part of the flexTasks.jar file. I've tried two different things:
Copy the jar file into the ant/plugins/lib folder (and restart my CF Builder instance)
Specify the path to the jar in the classpath attribute, as suggested by the comment on this page
Neither helps me get past this error.
Here's my build script, for reference:
<project name="Tagging" default="compile-tagging" basedir=".">
<!-- setup flex compilation capability -->
<taskdef resource="flexTasks.tasks" />
<property name="flex.src" value="./src" />
<property name="flex.bin" value="./bin"/>
<target name="compile-tagging">
<mxmlc
file="${flex.src}/main.mxml"
output="${flex.bin}/main.swf"
keep-generated-actionscript="true">
<source-path path-element="${FLEX_HOME}/frameworks" />
</mxmlc>
</target>
</project>
Adam, I believe you need to tell taskdef where to look for the file. try keeping flextasks.jar in the same directory as your ant file (for now... you can move it later after you get it working).
then, you can do something like this:
<taskdef name="mxmlc" classname="WhateverTheTaskIsNamed" classpath="flexTAsks.jar" />
While not ideal, this code is working for me at the moment:
<project name="IOLTagging" default="go" basedir=".">
<!-- setup flex compilation capability -->
<property name="FLEX_HOME" value="C:/program files (x86)/Adobe/Adobe Flash Builder Beta 2/sdks/3.4.1/" />
<taskdef name="mxmlc" classname="flex.ant.MxmlcTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<taskdef name="html-wrapper" classname="flex.ant.HtmlWrapperTask" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<property name="flex.src" value="./src" />
<property name="flex.bin" value="./bin"/>
<property name="swf.name" value="main" />
<target name="go" depends="compile-flex" />
<target name="compile-flex">
<mxmlc
file="${flex.src}/main.mxml"
output="${flex.bin}/${swf.name}.swf"
debug="false"
keep-generated-actionscript="false">
<source-path path-element="${FLEX_HOME}/frameworks" />
<compiler.library-path dir="${basedir}/libs" append="true">
<include name="*.swc" />
</compiler.library-path>
</mxmlc>
</target>
</project>
I had the same problem, and the reason was in lack of permissions to acces $FLEX_HOME/ant.
You can also put the flexTasks.jar in ~/.ant/lib directory
If you run ant -diagnostics you should see the jar in USER_HOME/.ant/lib jar listing
I think you should have solved this problem. just trying flexmonkey today and also got the same problem.
"Could not load definitions from resource flexTasks.tasks. It could not be found."
solution is to make sure the flexTasks.jar is included in the dir lib of your project workplace.
when I copied flexTasks.jar from flashbuild folder \ant\lib and built it again. the problem is fixed.