I tried to implement the awstasks Class for uploading files via an ant script to an S3 bucket.
Downloaded all dependencies and used the following code:
<taskdef name="S3Upload" classname="dak.ant.taskdefs.S3Upload">
<classpath refid="classpath.compile"/>
</taskdef>
<target name="final2S3">
<basename property="customer.id" file="${basedir}"/>
<basename property="customer.name" file="${basedir.parent.parent}"/>
<basename property="customer.campaign" file="${basedir.parent}"/>
<basename property="customer.final" file="${basedir.parent}\_final\${customer.id}\"/>
<S3Upload verbose="true"
accessId="${aws.accessId}"
secretKey="${aws.secretKey}"
bucket="${aws.bucket}\${customer.id}"
publicRead="true">
<fileset dir="${customer.final}">
<include name="**/*.json"/>
<include name="**/*.swf"/>
</fileset>
</S3Upload>
</target>
I get the following error:
Reference classpath.compile not found.
I tried to set the property classpath.compile to the lib folder in the Ant home but nothing changes.
Related
I have in ant build.xml directive
<target name="war" depends="compile">
<war destfile="dist/app.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent">
<include name="**/*.*"/>
<include name="._arrow.png"/>
</fileset>
<lib dir="WebContent/WEB-INF/lib"/>
<classes dir="build/classes"/>
</war>
</target>
in the war file I got only :
favicon.ico
robots.txt
sitemap.xml
I am unable to add the files without base name of the file and who has only .extention like
._arrow.png
Can someone help me, please?
Thanks Raul
I wrote this simple script to transfer files from my machine to remote machine. Here I included the jars of ant.
<?xml version="1.0" encoding="UTF-8"?>
<project name="File_Transfer_using_ANT" default=".">
<property name="lib" location="lib" />
<path id="project.classpath">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
</path>
<target name="copy">
<classpath refid="project.classpath" />
<scp todir="username:password#ip:path/">
<fileset dir="source path">
<include name="**/*.txt" />
</fileset>
</scp>
</target>
</project>
Error:
java.lang.NoSuchMethodError: com.jcraft.jsch.Session.setConfig(Ljava/lang/String;Ljava/lang/String;)V
at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:221)
I also Added jar file required into ant lib path. I don't know where I did wrong.
I am trying to deploy my zip file from local machine to remote machine, i am using jenkins with ant. the problem is build gets success but 0 files has been sent to remote machine using ftp.
my build.xml file as below
<project name="test" default="test">
<target name="test">
<zip destfile="htmlfiles.zip">
<fileset dir=".">
<include name="**/*.php"/>
</fileset>
</zip>
<ftp server="192.168.0.66"
userid="admin"
password="admin">
<fileset dir="C:\Users\ADMIN\Desktop\ftp">
<include name="*"/>
</fileset>
</ftp>
</target>
</project>
and following my result of jenkins
test:
[zip] Building zip: C:\Users\ADMIN\.jenkins\workspace\test\htmlfiles.zip
[ftp] sending files
[ftp] 0 files sent
BUILD SUCCESSFUL
Total time: 0 seconds
Finished: SUCCESS
anyone help me out that why it is happening?
Try this and let me know if its works for you.
<project name="test" default="test">
<target name="test">
<property name="distdir" value="C:\Users\ADMIN\Desktop\ftp"/>
<zip destfile="${distdir}/htmlfiles.zip">
<fileset dir=".">
<include name="**/*.php"/>
</fileset>
</zip>
<ftp server="192.168.0.66"
userid="admin"
password="admin">
<fileset dir="C:\Users\ADMIN\Desktop\ftp">
<include name="*"/>
</fileset>
</ftp>
</target>
</project>
As i can see from logs that your .zip file is created at C:\Users\ADMIN\.jenkins\workspace\test\htmlfiles.zip but in ftp tag you have specified the location "C:\Users\ADMIN\Desktop\ftp". fileset in ftp folder doesn't specify the destination directory. The file will be put in default folder for ftp user(here which is admin)
I have written the below script which is copying files which were changed after the specified time. What i also want is to get the same files which has different suffix with these files.
<project name="copy latest files test" basedir="." xmlns:sf="antlib:com.salesforce">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="C:/apache-ant-1.9.6/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<property name="src.dir" value="retrieveUnpackaged"/>
<property name="dest.dir" value="tempFolder"/>
<!-- Copy contents of classes folder from source folder -->
<target name="moveFolders" >
<copy toDir="${dest.dir}">
<fileset dir="${src.dir}">
<scriptselector language="javascript">
import(java.io.file);
self.setselected(true);
</scriptselector>
<include name="*/**"/>
<date datetime="04/20/2016 10:35 AM" when="after"/>
</fileset>
</copy>
</target>
I was trying to use , but couldnt figure it out.
The files that are getting copied will have another file in the same folder ending with "-meta.xml" as suffix. What I want is to get those files together as well.
I have a ANT script and I have a lot of duplicated path to same set JAR files.
But there is so many double wording in the classpath and also in the war element.
<path id="my.classpath">
<pathelement location="folderA/subFolderA/1.0/A.jar"/>
<pathelement location="folderC/subFolderB/1.0/B.jar"/>
<pathelement location="folderF/subFolderZ/2.0/Z.jar"/>
<pathelement location="compile/subFolderX/1.0/onlyForJavac.jar"/>
</path>
....
<javac ...>
<classpath refid="my.classpath" />
</javac>
....
<war ...>
<lib file="folderA/subFolderA/1.0/A.jar"/>
<lib file="folderC/subFolderB/1.0/B.jar"/>
<lib file="folderF/subFolderZ/2.0/Z.jar"/>
<lib file="moreFolderF/subFolderZ/2.0/additionFile.jar"/>
<lib file="moreFolderF/subFolderZ/2.0/additionRuntimeFile.jar"/>
</war>
I want to summary them into ONE list which is easier to keep update.
But I am blocked as I have no idea how to share a path-like-structure with a fileset-like-structure.
Since Ant 1.8.0 there is a new resource collection - mappedresources that
can be used in place of the war task lib element.
So, the task might look like this (pretty much straight from the docs):
<war ... >
<mappedresources>
<restrict>
<path refid="my.classpath"/>
<type type="file"/>
</restrict>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="WEB-INF/lib/*"/>
</chainedmapper>
</mappedresources>
</war>
This feature was added to resolve a long-standing feature request to make
the task flatten jars when deploying to WEB-INF/lib.
previous answer:
Although you can't easily convert a path to a fileset with vanilla Ant, you can go the other way.
So one option would be to define your jars in a fileset, and derive the path from it.
Something like this perhaps:
<fileset id="my.fileset" dir="${basedir}">
<include name="folderA/subFolderA/1.0/A.jar"/>
<include name="folderC/subFolderB/1.0/B.jar"/>
<include name="folderF/subFolderZ/2.0/Z.jar"/>
<include name="moreFolderF/subFolderZ/2.0/additionFile.jar"/>
<include name="moreFolderF/subFolderZ/2.0/additionRuntimeFile.jar"/>
</fileset>
<path id="my.classpath">
<fileset refid="my.fileset" />
</path>
<!-- javac stays the same -->
<war ...>
<lib refid="my.fileset" />
</war>
Another possibility is to use the ant-contrib pathtofileset task.
Another solution, possibly 'not the best' will be to place required jar file in WEB-INF/lib, and then set the classpath from there.
<path id="compile.classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
When its time to build the war, you need not worry about the <lib> at all, as jars are already placed in WEB-INF/lib folder.
<war destfile="${dist.dir}/${project.name}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}"/>
<classes dir="${build.dir}/classes"/>
</war>