findbugs not generating html report - ant

the below is my taskdef in a ant build file
<target name="findbugs">
<echo message="${findbugs.home}"/>
<findbugs home="${findbugs.home}"
output="html"
outputFile="E:\reports\findbugs-report.html"
effort="max"
reportLevel="low" >
<sourcePath path="${basedir}/enterpriseapplication/**" />
<class location="${basedir}/**/*.class" />
</findbugs>
</target>
I checked file permissions on the directry every thing is fine. I get the cli output but no file is generated.
Any help please.

I have run into this problem before. It seems that findbugs is unable to create the file.
Create an empty file named findbugs-report.html in the directory E:\reports\
Hope that helps.
Do not forget to mark an answer as the accepted answer if it solves your question.

There were some problems with the paths that I has put in the configuration. Fixing those paths resolved the problems. Also we need to be sure that the file system has permissions to create/modify files where the result file is placed.
Thanks for all your answers/comments guys.

Related

Process leaked file descriptors jenkins ERROR on Jenkins

Can someone help me to solve an issue "process leaked file descriptors jenkins"?
I tried whit BUIL_ID = dontkillme but it doesnt work.
Thx
It would help to know more about what you're trying to run but this question came up as a result of troubleshooting an issue I was having so here's how I resolved it. I am using Windows so if you're using something else it may not work for you.
First of all you need to read and understand the Jenkins documentation on the issue: https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors
I had to install Ant first since it was not installed.
https://ant.apache.org/bindownload.cgi
The Jenkins documentation gives you an example Ant script:
<exec executable="cscript.exe">
<env key="ANTRUN_TITLE" value="Title for Window" /> <!-- optional -->
<env key="ANTRUN_OUTPUT" value="output.log" /> <!-- optional -->
<arg value="//NoLogo" />
<arg value="antRunAsync.js" /> <!-- this script -->
<arg value="real executable" />
</exec>
You will change the "real executable" to be the executable you are wanting to run.
See that .js file in the 2nd arg value? You will need to create that. There's a link to this on the Jenkins documentation page too. Grab it here: https://wiki.jenkins.io/download/attachments/1835010/antRunAsync.js?version=1&modificationDate=1184046328000&api=v2
I didn't make any edits to the contents, just pasted it right in and saved it as antRunAsync.js
So now you take your Ant example script I posted above and throw that in a text editor, save as build.xml
From this point you should be able to test on the command line by typing ant and pressing enter. Your application should load in a different window.
If you haven't set up Ant in the Jenkins Global Tool Configuration do so now and point it to your Ant install (might have to uncheck the Install checkbox). In the Jenkins project add a build step Invoke Ant. Set that up how you like according to Ant documentation.
Hope this answer helps someone else who has stumbled across this problem and this question.

ant-contrib installation failure on linux

I would like to use 'ant-contrib', but I could not use it. I tried to use 3 way, without success.
Apache Ant(TM) version 1.8.2
echo $ANT_HOME
/usr/share/ant
./usr/share/ant/lib/ant-contrib-1.0b2.jar
./usr/share/java/ant/ant-contrib-1.0b2.jar
./usr/share/java/ant.jar
*1.*
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
RESULT:
Buildfile: /home/username/build.xml
[taskdef] Could not load definitions from resource net/sf/antcontrib
/antcontrib.properties. It could not be found.
*2.*
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
RESULT:
Buildfile: /home/username/build.xml
[taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.
*3.* build.xml in my home, and ant-contrib in home/lib
<classpath id="contrib.classpath.ref">
<fileset dir="${basedir}/lib"/>
</classpath>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="contrib.classpath.ref"/>
RESULT:
Buildfile: /home/username/build.xml:2: Problem: failed to create task or type classpath
Cause: The name is undefined.
Action: Check the spelling.
I dont know other solution where I can iterate through a fileset/custom list doing something on them one by one. Thats why its important me.
Honestly, why there is no clear documentation ?
The problem was that YAN mentioned above. I have more ant in my system.
All in all, I removed them, a tried again my build xml with a brand new downloaded ant.
What is not on the PATH, and started from directory where it is.
I know this is not the best settings, but I could try it what I want, and solving the right setting is just question of time.
Thanks guys above your time and effort.

How to delete a symlink using Ant?

I am trying to delete a symlink in ant script using the below line :
<symlink action="delete" link="/path/of/link/symlink"/>
But it is showing an error:
Could not create tempfile in /directory/where/symlink/points
The /directory/where/symlink/points is supposed to be read-only.
Is there a way in which I could just delete the symlink and not mess up other things? It's a part of a big script.
Symlinks pointing to read-only resources may be deleted using the <delete> Ant task.
<target name="delete-symlink">
<delete file="/path/of/link/symlink" followsymlinks="false"
removenotfollowedsymlinks="true" />
</target>
And this is from the delete Ant task documentation:
removeNotFollowedSymlinks Whether symbolic links (not the files/directories
they link to) should be removed if they haven't been
followed because followSymlinks was false or the
maximum number of symbolic links was too big. Since
Ant 1.8.0
Hope it works.

Is there a way in ANT to extract one class file from a JAR and put it in another JAR?

My ANT build script uses a WebSphere command called createEJBStubs that produces a JAR file with everything plus one new generated class, namely: com/myapp/services/_User_Service_Stub.class.
Since this stub class is only used for running JUnit tests at dev time, I would like it to be in its own JAR file.
How can I tell ANT to copy everything in AAA.JAR that matches, say, _*Stub.class and copy only those files into BBB.JAR (also, maintaining the same directory/package structure)?
Any ideas or pointers would be GREATLY appreciated! Thanks,
Rob
Ok -- answering my own question -- that was surprisingly easy. Sorry I asked.
<unzip src="AAA.JAR" dest="./temp">
<patternset>
<include name="**/_*Stub.class" />
</patternset>
</unzip>
<zip destfile="BBB.JAR" basedir="./temp" />
Thanks ANT.

MSBuild Fails to remove Binaries directory

I am building two solutions with MSBuild:
<ItemGroup>
<SolutionToBuild Include="$(BuildProjectFolderPath)/HostASPX/SolutionA.sln"/>
<SolutionToBuild Include="$(BuildProjectFolderPath)/../Installer/SolutionB.sln"/>
</ItemGroup>
It seems that this build fails with the error message:
Unable to remove directory "c:\TeamBuild\Team Solutions\Solution\Binaries". The directory is not empty.
It appears that MSBuild creates this 'Binaries' directory by default and the build passes. When I build again the build fails with the above message. If I try a 3rd build.. it works again.
Can someone tell me how to ensure that his folder is deleted/overwritten each time?
You sure there isn't an observer effect at play? i.e., something isn't locking the directory like explorer.exe :P
You can rule it out by using \\live.sysinternals.com\procmon.exe (to find out who is doing what to the dir) and procexp (to find out who is locking it).
I experienced the same problem of "Unable to remove directory ... the directory is not empty" while running a target that looks something like this:
<Target Name="CleanFiles"
DependsOnTargets="Prepare_Files"
Inputs="#(Files->'%(OutputPath)'->Distinct())"
Outputs="_Non_Existent_Item_To_Batch_">
<ItemGroup>
<DirsToDelete Include="#(Files->'%(OutputPath)'->Distinct())"/>
</ItemGroup>
<RemoveDir Directories="#(DirsToDelete)"/>
</Target>
Occasionally it worked fine and deleted the directories, but often I got the error above.
Eventually I found out that MSBuild itself is locking the files, beacuase they appear on the target's "Inputs", and not unlocking them in time for RemoveDir to delete them.
Changing the above to:
<Target Name="CleanFiles"
DependsOnTargets="Prepare_Files">
<ItemGroup>
<DirsToDelete Include="#(Files->'%(OutputPath)'->Distinct())"/>
</ItemGroup>
<RemoveDir Directories="#(DirsToDelete)"/>
</Target>
seems to solve the problem.
It's still OK to delete all directories always since RemoveDir skips non-existent directories and does not report an error.

Resources