Build to parent folder with HTML5 Boilerplate Build Script - ant

When i try to build to the parent folder with HTML5 Boilerplate build script i get this message:
Your dir.publish folder is set to ../ which could delete your entire site or worse.
Firstly, the build script doesn't delete any files, it just replaces them right?
Secondly, "or worse"? It's not like I'm googling google or mixing nitroglycerin here :(
Is there a work around?
EDIT:
I deleted this line in build.xml:
<equals arg1="${dir.publish}" arg2="../"/>
It works fine but i feel a bit dirty. Should i?

Haha, I wrote that error message, sorry :( but there is an ant task (clean) in build script which is to delete the publish and intermediate folders. And if you set your publish folder to ../ you can imagine what can happen :)

As stated in the edit. I funked around in the build.xml and deleted this line:
<equals arg1="${dir.publish}" arg2="../"/>
I haven't had any problems yet but use with caution.

Related

TFS copy and deploy: exclude files using minimatch

According to many different SO-questions, it should be possible to exclude files being copied/deployed using the Task "Copy and Publish Build Artifacts" in the new TFS build system.
However it doesn't work for me (it is not excluding anything). What could I be doing wrong:
This should work (I know the question is old but I needed an answer myself)
**\!(System.Windows.Interactivity.resources.dll|*.dll.config|*fluentassertions*)
This is a known issue of the build task “Copy and Publish Build Artifacts”,bitbonk.
Q: This step didn't produce the outcome I was expecting. How can I fix it?
This step has a couple of known issues:
Some minimatch patterns don't work.
It eliminates the most common root path for all paths matched.
Source Link: Utility: Copy and Publish Build Artifacts
Well, it's nothing business with your settings of minimatch. It's just not work for that build task. Certainly, you can also doulbe check your minimatch with Copy Files task to verify this.
For now, you can avoid these issues by instead using the Copy Files step and the Publish Build Artifacts step.
Note: If it's still not working on copy files step, you should pay attention to the architecture of file when using minimatch. There must be something wrong on it.
The task copies the files base on the contents you entered one line by one line and the "!" only exclude the files during the copy, it does not delete the files that already been copied. So with the "**\*" you entered in the first line, all the files have already been copied and published. You need to remove the first line in "Contents". And for the excluded files, if there are in the same folded, you need to exclude them in one line. For example: using
!?(1.txt|2.txt)
to exclude both 1.txt and 2.txt file instead of using
!1.txt
!2.txt

Ant Cannot Copy Error

I'm running an ant build through Jenkins and on the stage where it is deploying to windows-share its returning the following error:
Failed to copy FILE to FILE2 due to failed to create the parent directory for FILE2 (I've taken the paths out to keep the question shorter).
I'm guessing that there might be some problem with permissions with the jenkins default user but this problem has only just started occurring, and any help would be great.
Thanks
This is a pretty old question but I thought I'd come back and complete it with a short update as to what was actually going on. Someone had changed the password for the user that was logged on to the vm that jenkins was running on, and when it was trying to create the directory to stick the files into it was running into permissions errors. Only problem was the error message wasn't very descriptive.
So in the end this was an infrastructure problem rather than anything to do with the ant script.
I take it you're doing something like this:
<copy file="${from.dir}/${from.file}"
tofile="${to.dir}/${to.file}"/>
And, you're getting an error that ${to.dir} doesn't exist.
In earlier versions of Ant, you definitely had to create the directory before doing a copy:
<mkdir dir="${to.dir}"/>
<copy file="${from.dir}/${from.file}"
tofile="${to.dir}/${to.file}"/>
I think I also noticed that later versions of Ant will create the directory for you when that directory didn't exist. I've always been in the habit of putting <mkdir/> in front of any task that creates a new file in a new directory, including things like <zip/> and <tar/>.
Here are some questions:
Do your users also use Ant to run their builds? I know that this isn't always the case. Many users use Eclipse and don't bother with Ant.
Is the version of Ant your users have vs. what your users have the same?
Do you do a clean? Jenkins can emulate a clean either by doing an update, reverting and removing unversioned element, or by simply creating a brand new working directory. If your users don't remove the destination directory where ${to.file} is being placed, it might work locally, but not on Jenkins.
Can you manually run Ant from the Jenkins working directory. If so, what results do you get? (Remember to disable this Jenkins job before doing this. You don't want Jenkins to do a build while you're experimenting in the working directory.)

Deployment of Jar using Ant and OJDeploy for packaging ADF

I'm trying to Deploy a Jar File from an ANT script (with OjDeploy), which compiles successfully. But when I run the main project (Which has the Jar dependency), I get a huge incident, when I analysed the incident log, it says
"Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist"
I analysed both the jar files (One generated by the ANT script and the other generated from Jdev). I couldn't find any difference b/w Manifest of those two jars. The other folders are also the same, In other words, both are almost the same, or I'm not able to figure out the difference between the two jar files generated.
I know, I'm missing something, config of build.xml or something, but not able to figure out the exact problem.
Thanks,
Shiva Shankar
My guess is that the problem is not in the JAR file but rather in the project that consumes it.
Seems like the DB connection in that project is different than the one in your JAR project - which causes one of the tables that is needed in the DB not be found.
I figured out a way to solve the problem. Not sure what was the cause of this issue, but a couple of changes made both to JAR/EAR build scripts set the things right
While building JAR files:
Uncheck "Make this the project build file" while creating the ANT build file, while the "Include Packaging Tasks (uses OjDeploy)" must be checked.
Remove "nocompile" parameter from tag in the OjDeploy.
While Building EAR files:
Create EAR in the view controller project.
Go to the View Controller Project Properties-> Project Source Path -> Resources, remove the newly created build file dependency, which specifies that the build file is for the whole project and not for the individual project.
Remove "Project" parameter from tag in the OjDeploy. (Ensures to build for the whole application)
Remove "nocompile" parameter from tag in the OjDeploy.
These are the exhaustive set of changes, which I made to ensure the ANT files are building correctly, if you get any other errors after this EAR is deployed, then its definitely due to code, EO/VO or DB related.
Thanks for all the help!!
Shiva Shankar

How to get error code of ant command

My ant files are already present and I am not allowed to change those for various reasons. I have created a batch file and I am writing all those ant commands in that batch file just to automate the process. The code looks something like this
1. cd abc
2. ant realclean && ant
3. cd..
4. cd pqr
5. ant realclean && ant
6. cd..
However now I have to check if the build fired on line 2 is successful then only goto line 3 otherwise exit.
I googled a bit and found %errorlevel% as one option but it is not working in my case.
Any suggestions?
Thanks in advance.
How about adding another ANT file which contains the tasks to execute the existing ANT files?
That would give you error handling without doing anything, you could reuse that file on different OSs and your CI server and the syntax would be saner than batch...
You can have ANT execute, say project.xml, with ant -f project.xml
[EDIT] You don't even have to change the existing projects: Just create a new project, assign paths to the old projects to properties in the new build.xml and then you can build the old projects from the new one.
This gives you:
A sane[*] syntax that you already know (no need to learn the ugly/buggy/handicapped rules of DOS batch programming; you did know that DOS was once named QDOS "Quick and Dirty OS", yes?)
Proper error handling
A simple way to pass arguments to the sub-builds
Cross-platform support
Useful error messages when something goes wrong
[*]: Compared to DOS...

Delete read only files with Ant on windows

I have an Ant script performing some updating etc and one task is to delete a few files and folders.
In Windows and especially version 7 there seem to be some kind of Read Only Attribute mayhem and I have tried several solutions with no success.
There are several other SO issues similar to this but no solution really.
Ant is not able to delete some files on windows
Is there any way to make Ant ignore the Read Only Attribute?
The ant chmod task seems only to work for Linux; searching for "ant chmod windows" yielded i.a. Attr. Then you could first make all writable. Maybe with ant delete failonerror=false.
Okay, that does not work too. Maybe use PsExec, a tool to run things as Administrator. Unlikely that a solution in the form of an ant task may be found.

Resources