ant: delete files from dir 'a 'that exist in dir 'b' - ant

Given two directories ('a' and 'b'), each containing files, neither containing directories.
My goal is to remove all files from 'b' that for which there are files with the same name in 'a'.
Can anyone suggest an ant recipe for this (short of writing javascript or java code)?

You need to look at how fileset selectors work in Ant, specifically the present selector.
The following contains an example:
How do I iterate through files in an ant script?

Related

ANT invert (reverse) directory structure

How can I reverse the directory structure for files using Ant.
For example, I have the following
C:\some\path\a\b\file1.txt
C:\some\path\y\z\file2.txt
I would like to convert this to
C:\some\dir\b\a\file1.txt
C:\some\dir\z\y\file2.txt
In terms of variables in Ant, I know C:\some\path and C:\some\dir, but I don't know the directories a,b,y,z (those are entirely dynamic).
Ideally it would to be a separate directory (e.g. from path -> dir), but in-place is OK to since I can just copy elsewhere first.
I thought globmatcher/regexmatcher might help, but I think they only change the file name, not the directory name.
There is actually a somewhat relevant sample in the ant docs for mapper
Just use the regex mapper during the move or copy and reverse the directory order in the match:
<mapper type="regexp" from="^(.*)/([^/]+)/([^/]*)$$" to="\2/\1/-\3"/>

Is there a way to pass non-project .fs files into a command-line argument in an FSharp .exe?

Let's say that I have an exe that has a function called compareTwoThings. I'd like compareTwoThings to be able to take, as arguments, two directories that have identical file names in each: a .json and a .fs. In compareTwoThings, I want to be able to read in each .json (easy-peasy) and each .fs file. The contents of each .fs file will be known.
How can I read in each .fs file and use the values in those .fs files without them being a part of the overall project structure? Can I? I understand that to build a project and have the project "see" into the .fs files, they need to be added to the .fsproj file, but can I not use open on an external file that has a module name?
Example dir structure of the proj:
myProj
|-proj
|-compareTwoThings.fs
|-myProj.fs
|-myProj.fsproj
Thing1
|-Thing1.fs
|-Thing1.json
Thing2
|-Thing2.fs
|-Thing2.json
And ultimately, the CLI statement would be something like
myProj compareTwoThings [dir to Thing1] [dir to Thing2] [output dir]
I feel like I'm overlooking something very simple here.
Edit: I do not believe that this question is related as I'm asking how to open a non-project .fs file.

Exclude directory in uDeploy plugin for jenkins

I'm trying to import a new version of a udeploy component through Jenkins and the uDeploy plugin that comes from a Git repository and has the .git folder in it. Everything I've tried to exclude the .git folder from syncing doesn't work. I'm thinking that the plugin is looking for files with a .git extension rather than folder. How do I exclude the .git folder form syncing?
I tried ".git", **/.git/, *.git/*, **.git/*, and a handful of other 'terms' and they all show up in the console output as:
Working Directory: C:\Program Files (x86)\Jenkins\jobs\DIT Com\workspace
Includes: **/
Excludes: ".git" Uploading files in C:\Program Files (x86)\Jenkins\jobs\DIT Com\workspace Uploading: .git/hooks/pre-commit.sample
...
Uploading: .git/refs/heads Files committed Finished: SUCCESS
This is what the exclude section looks like, with the help bubble clicked (that's what's in the gray box)
Unable to comment so adding as an answer-
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
Other consecutive asterisks are considered invalid.
Have you tried a regular expression? say, ^/.*/.git/
Looks like the answer to excluding directories is in the form of **/dir_name/**.
If someone could give some more information on what the leading *'s are doing (not sure how the second * wildcard interacts, nor the trailing second *) I would be really interested in understanding why it works!
reference: ant fileset dir exclude certain directory

jenkins archive artifact excluding all subdirectory

I have a couple of job in Jenkins that archive artifact from the source tree for another job (some unit tests or alike). I have the current situation :
top_dir
\scripts_dir
\some_files
\dir1
\dir2
\dir3
\other_dir
I would like to archive all that is in "top_dir" including the files in "scripts_dir", but not the subdirectories "dir1, dir2,...", which I do not know the name, that are in "scripts_dir". These subdirs are actually Windows directory joints that point to other places on the disk, and I do not want them to be copied.
How do I achieve this with the inculde/excludes pattern of Jenkins ?
I already tried, having include=top_dir/ , exclude=
**/scripts_dir/*/
**/scripts_dir/*/**
**/scripts_dir/**/*
but it always exculdes the whole "scripts_dir" folder.
Finally, by using brute force, I found that the following expression does exclude all the files in the subdirectories of scripts_dir (whatever symlink or not), then removing these subdirs, while keeping the files directly in scripts_dir :
**/scripts_dir/**/*/*/
Thanks for the help anyway.
Reading the ANT manual, there an followsymlinks attribute that defaults to true. You said those things you want to exclude are symlinks (although i am not sure if this will work with Windows joints). Try adding followsymlinks=false
Another solution: if all your files under scripts_dir have a set number of characters in the extension, you can put that into your include statement. This will only pickup files with extensions of 3 characters:
**/scripts_dir/*.???
More on this here

How to ignore error in 'excludesfile' in Ant if file is not present

I use
<zipfileset ..><excludesfile name="D:\SW\abc.h"/>..</zipfileset>
to exclude this file while zipping
Problem is if this file does not exist, Ant throws error.
Are there any ignore settings?
I have many <excludesfile> tag
The excludesfile element or attribute is intended to specify the name of a file, each line of which is taken to be an exclude pattern. See the documentation for PatternSet.
I think you are incorrectly using the attribute to specify the names of files you want to exclude literally, rather than in the named excludes file itself.
One solution would be to list all the files you require to be excluded from your zip in a file (each on a new line) and give the name of this file in the excludesfile attribute or element of your zipfileset.
Alternatively, you could use a comma or space separated list of the files in the excludes attribute. Or you could replace your multiple excludesfile elements with multiple exclude elements.

Resources