ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Baz" <ba...@goodconsultants.com>
Subject Re: cp or <copy> in windows? and in unix like system
Date Wed, 17 Mar 2004 15:58:04 GMT
All,

Not sure if it is better to check "cp" instead of "uname" with the code that
i sent. Here is the output and i hope it helps others with the same problems
that i have. Please comment...

On cygwin and unix:

$ ant
Buildfile: build.xml
barry2:

     [exec] Result: 1
     [echo] is.UnixLike is .cp: missing file arguments
     [echo] Try `cp --help' for more information..
     [echo] is.DosLike is .${is.DosLike}.

barry1:
     [echo] It is a UnixLike system.

BUILD SUCCESSFUL
Total time: 17 seconds

On DOS: Please notice that task barry1 not output anything and bypassed is
normal. Imagine that barry1 is nonperm.copy task.

C:\cygwin\home\barry\barry\server\src\java\policyServer>ant
Buildfile: build.xml

barry2:
     [exec] Execute failed: java.io.IOException: CreateProcess: cp error=2
     [echo] is.UnixLike is .${is.UnixLike}.
     [echo] is.DosLike is .true.

barry1:

BUILD SUCCESSFUL
Total time: 4 seconds

----- Original Message ----- 
From: "Baz" <barry@goodconsultants.com>
To: "Ant Users List" <user@ant.apache.org>
Sent: Wednesday, March 17, 2004 7:43 AM
Subject: cp or <copy> in windows? and in unix like system


> Jan, Jack and all,
>
> Funny thing is... I wasted a day searching for a better solution such as
> <chmod>, blah blah, but still going back to same implementation as Jan's
:)
>
> However, I am not using OS to switch between perm copy and nonperm copy. I
> use the avaiilability of the command "uname". If you can do "uname" in the
> environment, then it is "unixlike"... Perm copy is using "cp -rp" and its
> for unix like system. Non perm copy is using <copy> and its for non unix
> like system.
>
> Here is the code and I hope that it is useful and please comment if it
works
> or not.
>
> <target name="deploy"
>     depends="check,pre-deploy, deploy-unix,deploy-dos,post-deploy"/>
>
>
> <target name="pre-deploy">
>
>     <delete dir="${serverdeploy.home}/bin"/>
>     <delete dir="${serverdeploy.home}/certs"/>
>     <delete dir="${serverdeploy.home}/conf"/>
>     <delete dir="${serverdeploy.home}/webapps/${app.name}"/>
>     <delete file="${serverdeploy.home}/webapps/${app.name}.war"/>
>
>     <mkdir dir="${serverdeploy.home}"/>
>     <mkdir dir="${serverdeploy.home}/lib"/>
>     <mkdir dir="${serverdeploy.home}/logs"/>
>     <mkdir dir="${serverdeploy.home}/temp"/>
>     <mkdir dir="${serverdeploy.home}/uploads"/>
>     <mkdir dir="${serverdeploy.home}/webapps"/>
>     <mkdir dir="${serverdeploy.home}/bin"/>
>     <mkdir dir="${serverdeploy.home}/conf"/>
>     <mkdir dir="${serverdeploy.home}/certs"/>
>
> </target>
>
> <target name="check">
>
>     <exec executable="uname" failifexecutionfails="false"
>         errorproperty="is.UnixStyle"/>
>
>     <condition property="is.DosStyle">
>     <not>
>     <isset property="is.UnixStyle"/>
>     </not>
>     </condition>
>
>     <echo message="Style is ${is.UnixStyle}"/>
>     <echo message="Style is ${is.DosStyle}"/>
>
> </target>
>
> <target name="deploy-unix" if="is.UnixStyle">
>
>     <echo message="This is a unix style system."/>
>     <exec executable="cp" >
>         <arg value="-rp"/>
>         <arg value="../bin"/>
>         <arg value="${serverdeploy.home}"/>
>     </exec>
>
>     <exec executable="cp" >
>         <arg value="-rp"/>
>         <arg value="../certs"/>
>         <arg value="${serverdeploy.home}"/>
>     </exec>
>
>     <exec executable="cp" >
>         <arg value="-rp"/>
>         <arg value="../conf"/>
>         <arg value="${serverdeploy.home}"/>
>     </exec>
>
> </target>
>
> <target name="deploy-dos" if="is.DosStyle">
>
>     <echo message="This is a unix style system."/>
>     <copy todir="${serverdeploy.home}/bin">
>     <fileset dir="../bin"/>
>     </copy>
>
>     <chmod perm="a+rx" type="file">
>     <fileset dir="${serverdeploy.home}/bin"/>
>     </chmod>
>
>     <copy todir="${serverdeploy.home}/certs">
>     <fileset dir="../certs"/>
>     </copy>
>
>     <chmod perm="a+r" type="file">
>     <fileset dir="${serverdeploy.home}/certs"/>
>     </chmod>
>
>     <copy todir="${serverdeploy.home}/conf">
>     <fileset dir="../conf"/>
>     </copy>
>
>     <chmod perm="a+rx" type="file">
>     <fileset dir="${serverdeploy.home}/conf"/>
>     </chmod>
>
>     <chmod perm="a-w" type="file">
>     <fileset dir="${serverdeploy.home}/bin"/>
>     <fileset dir="${serverdeploy.home}/conf"/>
>     <fileset dir="${serverdeploy.home}/certs"/>
>     </chmod>
>
> </target>
>
> <target name="post-deploy">
>
>     <copy file="${dist.home}/${app.name}.war"
>         todir="${serverdeploy.home}/webapps"/>
>
> </target>
>
>
>
> ----- Original Message ----- 
> From: <Jan.Materne@rzf.fin-nrw.de>
> To: <user@ant.apache.org>
> Sent: Monday, March 15, 2004 10:36 PM
> Subject: RE: cp or <copy> in windows?
>
>
> > Using <copy> you can copy the files in a cross platform manner.
> >
> > Setting the permissions the perms of the original files is another
> > topic. <chmod> is used to set permission. But there is no easy way
> > to "copy" the permissions from one fileset to a target. You can
> > use <script> and <chmod>: iterate over a src-fileset, if the file exists
> > in a target dir, get the file permissions from src and set them on
target.
> >
> > If "cp" does the job you can use dependend targets for copying:
> >
> >   <target name="copy"
> > depends="copy.check,copy.withPerms,copy.withoutPerms"/>
> >
> >   <taret name="copy.check">
> >       <condition property="copy.withPerms">
> >           <os family="unix"/>
> >       </>
> >   </>
> >
> >   <target name="copy.withoutPerms" unless="copy.withPerms">
> >       <copy> ... </>
> >   </>
> >
> >   <target name="copy.withPerms" if="copy.withPerms">
> >       <exec executable="sh"><arg line="cp ..."/></>
> >   </>
> >
> > (syntax not checked :)
> >
> >
> > Jan
> >
> > > -----Original Message-----
> > > From: Baz [mailto:barry@goodconsultants.com]
> > > Sent: Tuesday, March 16, 2004 6:02 AM
> > > To: Ant Users List
> > > Subject: cp or <copy> in windows?
> > >
> > >
> > > All,
> > >
> > > I am trying to support both Dos and cygwin in Windows  as
> > > well as all Unix
> > > platforms. I am trying to copy some files and was using
> > > <copy>, and soon
> > > enough, i found out from the manual that the <copy> does not preserve
> > > permission and using "cp" is recommended.
> > >
> > > So my question is: How can copy files in a task that is cross
> > > platform?
> > >
> > > Thanks.
> > >
> > > Barry
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message