I have the following code working. I've done some searching and can't find anything on how to associate a time stamp for when each file is uploaded. This would be helpful since I can get an idea on when a file fails during the upload process.
<ftp password="${password}" server="${server}" userid="${userid}" passive="true" remotedir="${remoteDir}">
<fileset dir="${localDir}">
<include name="**/*"/>
</fileset>
Basically, instead of this being produced in the log:
[ftp] File /DirectorytoUploadto/File.xml copied to server
I want to have something along the lines of:
[ftp] File /DirectorytoUploadto/File.xml copied to server at 2013-10-01 12:19:09
Does anyone know how to go about doing this?
To get a timestamp for each logged message, use the Log4J Listener.
Related
I have code for creating zip file in ant build script.
<target name="zip-dist" description="archiving artifacts">
<zip destfile="${artifacts}/${zipfile}.zip" update="false" basedir="${target.dist}" includes="*.xyz-*" />
</target>
When file is being extracted using win zip right click -> Extract All... there's no warning, but while extracting with 7-zip showing 'Warnings: Headers Error' but its successful.
I know this has no effect on the output as its just a warning so suggested users to ignore it or use win-zip method.
But trust me it is impossible to make them understand and they all are keep on eating my head.
There are many users and I am banging my head repeating same thing again and again. Still they want it to be fixed.
Can I use any attribute in ant-zip target or should I use any different zipping technique in ant build?
I have searched multiple online sources, this is last hope!
Please help.
I had the same issue.
Fixed adding only one attribute, to force Zip64 extensions:
zip64Mode="always"
Try and should work for you too.
Instead of regular zip target used 7-zip to create zip.
<property name="7z.exe" value="C:/Program Files/7-Zip/7z.exe" />
<target name="zip-dist" description="archiving artifacts">
<exec executable="${7z.exe}">
<arg value="a" />
<arg value="-tzip" />
<arg value="${artifacts}/${zipfile}.zip" />
<arg value="${target.dist}/*.xyz-*" />
</exec>
</target>
As 7-zip includes all necessary information regarding header, so that warning will not occur.
Of course, 7-zip must be available in system.
I have XML file named TIBCOUniversalInstaller_TRA_5.10.0.silent as below.I want to replace values in XML file using "replace" target in ant script using xmltask task.
XML File is below:
<?xml version="1.0"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>---Universal Installer Silent Installation Properties---</comment>
<!--accept the license agreement-->
<entry key="acceptLicense">true</entry>
<entry key="installationRoot">/opt/tibco</entry>
<entry key="environmentName">TRA</entry>
</properties>
At time of parsing XML file ,since my server can not reach java.sun.com , so i had downloaded properties.dtd on my local machine and using xmlcatalog task i am forcing ant script to read local copy of properties.dtd.Below is my ant script
<xmlcatalog id="dtd">
<dtd publicId="SYSTEM" location="/home/tibco/BW-AUTOMATION-
PROJECT/Environments/properties.dtd"/>
</xmlcatalog>
<xmltask source="${TRASoftwareFolder}/TIBCOUniversalInstaller_TRA_5.10.0.silent" dest="${TRASoftwareFolder}/TIBCOUniversalInstaller_TRA_5.10.0.silent">
<xmlcatalog refid="dtd">
</xmlcatalog>
<replace path="/:properties/:entry/:[#key='installationRoot']/text()"
withText="/home/tibco"/>
</xmltask>
But still at time of parsing XML contents , everytime it is going to http://java.sun.com/dtd/properties.dtd and i get "Connection Refused Error".
When i did debug i see below which i believe can be issue and it is always going to website instead of local dtd file.
DEBUG LOGS:
"No matching catalog entry found, parser will use: 'http://java.sun.com/dtd/properties.dtd'"
I believe it is because i gave "SYSTEM" as value in "publicId" attribute inside dtd element.
Can you please advise what should be correct value for "publicID" attribute for this given dtd so that it matches catalog at the time of parsing.
If there is another way of reading/replacing this XML file please advise.
Thanks
The JUnit official documentation states:
junitreport collects individual xml files generated by the JUnit task using the nested element.
Other part of the same page states:
<junitreport todir="./reports">
<fileset dir="./reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="./report/html"/>
</junitreport>
would generate a TESTS-TestSuites.xml file in the directory reports
and generate the default framed report in the directory report/html.
Let's say, I have file TEST-all.xml generated by junit task in the "reports" directory. I want to use it as data source for junitreport task:
<fileset dir="./reports">
<include name="TEST-all*.xml"/>
</fileset>
I would expect html report based on my data will be generated.
I tried to do it. Empty TESTS-TestSuites.xml file was generated and as a result empty html file.
Two documentation statements I quoted above somehow contradict each other: the first one says it will use already generated files to create a report and the second one says it will generate new file. Can somebody explain how it works? How can I control what data source will be used to generate html report?
Thanks.
Try running ant with -debug. I suspect
<include name="TEST-all*.xml"/>
is not matching any files. Please try with
<fileset dir="./reports">
<include name="TEST-*.xml"/>
</fileset>
Well, I figured out what was the problem: file TEST-all.xml was generated in wrong format. It seems the correct format is:
<testsuite>
<testcase classname="..." name="..." ...>
<properties>
<property name="..."/>
</properties>
</testcase>
</testsuite>
It didn't solve the problem completely though. The html report is still not generated properly:
In spite the fact that file TESTS-TestSuits.xml is not empty now and contains all necessary tests' information, main page of HTML report (index.html) still shows 0 tests.
If I click the link in Tests column (0 in this case) it opens list of tests, but if I try to open individual test in this page, I get "File not found" error.
I suspect the problem is still with the format of TEST-all.xml. I was looking for the description of the format, but found only pieces of information here and there. Any ideas?
I have jar file having some properties files in it like log4j.properties and config.properties. Following is my ant script for yguard. Everything else is working but the properties file updation.
<target name="yguard">
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="lib/yguard.jar" />
<yguard>
<inoutpairs resources="none">
<fileset dir="${basedir}">
<include name="MyApp.jar" />
</fileset>
<mapper type="glob" from="MyApp.jar" to="MyAppObs.jar" />
</inoutpairs>
<externalclasses>
<pathelement location="lib/log4j-1.2.17.jar" />
</externalclasses>
<rename conservemanifest="true" mainclass="com.amit.Application" >
<adjust replaceContent="true" >
<include name="**/*.properties" />
</adjust>
</rename>
</yguard>
</target>
config.properties file
com.amit.Application.param1 = something
I found some question in stackoverflow but they didn't help. One place it was mentioned that the file (like jsp, xml, properties) should be in the jar file which I already have. But my yguard obfuscated file just get the files copied as it is.
I tried many combinations with rename & adjust tags but nothing worked for me.
Following post I already visited
Is it possible to manage logs through Obfuscation with yGuard?
How to include obfuscated jar file into a war file
Apparently you want yGuard to obfuscate the name of the field param1, because com.amit.Application is obviously your entry point and yGuard excludes the given main class automatically. So basically you want the outcome to be something like
com.amit.Application.AÖÜF = something
This isn't possible, because yGuard can only adjust class names in property files, as state here: yGuard Manual
I have a directory tree that I need to process as follows:
I have a certain file that needs to be copied to a select few sub directories
A sub directory of interest is one that contains a file within which I can regex match a known search string
Ideally I would like to:
Perform a regex match across all files within a directory
If the regex matches, copy the file to that directory
The trouble is that I am quite new to ANT and I'm having difficulties finding my way around. I can't find any tasks in the docs about per directory operations based on regex search. The closest thing I've found is a regex replace task (<replaceregexp>) that can search and replace patterns across files.
Is this even possible? I'd really appreciate a sample to get started with. I apologize for requesting code - I simply don't know how to begin composing the tasks together to achieve this.
Alternatively I have the option of hardcoding all the copy operations per directory, but it would mean manually keeping everything in sync as my project grows. Ideally I'd like to automate it based on the regex search/copy approach I described.
Thanks!
Your requirement is a bit non-standard, so I've solved it using a custom Groovy task.
Here's a working example:
<project name="find-files" default="copy-files">
<!--
======================
Groovy task dependency
======================
-->
<path id="build.path">
<pathelement location="jars/groovy-all-1.8.6.jar"/>
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<!--
=========================
Search for matching files
=========================
-->
<target name="search-files">
<fileset id="filesContainingSearchString" dir="src">
<include name="**/*.txt"/>
<containsregexp expression="[4-6]\.[0-9]"/>
</fileset>
</target>
<!--
===================================
Copy file into each directory found
===================================
-->
<target name="copy-files" depends="search-files">
<groovy>
project.references.filesContainingSearchString.each { file ->
def dir = new File(file.toString()).parent
ant.copy(file:"fileToBeCopied.txt", toDir:dir)
}
</groovy>
</target>
</project>
Notes:
Groovy jar can be downloaded from Maven Central
Use the copy task with a fileset and regular expression selector :
<copy todir="your/target/dir">
<fileset dir="rootdir/of/your/directorytree" includes="**/*.txt">
<containsregexp expression="[4-6]\.[0-9]"/>
</fileset>
</copy>
This example is taken from the ant manual and slightly adapted.
Means select all files with .txt extension anywhere beyond rootdir/of/your/directorytree that match the regular expression (have a 4,5 or 6 followed by a period and a number from 0 to 9) and copy them to your/target/dir.
Just adapt it for your needs.