You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mark Benussi <ma...@hotmail.com> on 2005/08/18 12:44:03 UTC

Sync removing cvs information in target directory

Hi Guys,

 

Any ideas how I could use the sync task but not remove any directories in
the target that are named CVS. Basically my CVS information is getting wiped
and this is causing problems.

 

 


RE: Sync removing cvs information in target directory

Posted by Matt Benson <gu...@yahoo.com>.
A while back Stefan added support to CVS HEAD
 <sync> for a <preserveintarget> element that should
do what you want.  It was based on Dominique's code
IIRC.

-Matt

--- Mark Benussi <ma...@hotmail.com> wrote:

> Um Rock and roll... thanks for that.
> 
> I will have to get my head round the code as I am
> not too good at the custom
> tasks stuff
> 
> -----Original Message-----
> From: Dominique Devienne
> [mailto:ddevienne@gmail.com] 
> Sent: 18 August 2005 15:35
> To: 'Ant Users List'
> Subject: RE: Sync removing cvs information in target
> directory
> 
> Using the code below, you can patch the <sync> task
> to preserve arbitrary
> files. You'll have to code and compile it yourself
> though. --DD
> 
>     <bm:lsync2 todir="jar">
>       <preservedfiles includes="**/CVS/**" />
> 
>       <fileset dir="${sync.win32.from}">
>         <include name="com_lgc_foo_devkit.jar" />
>         <include name="com_lgc_foo_dataTypes.jar" />
>         <include name="com_lgc_bar_devkit.jar" />
>       </fileset>
>     </bm:lsync2>
> 
>   /** The <em>untouchable</em> files: the ones not
> to delete. */
>   private PreservedFiles _untouchables;
> 
> 
> Between Pass#1 and Pass#2, in execute():
> 
>     // Gather the untouchable files, if any (yes,
> we're scanning
>     // the sync'd dir twice here and in
> removeOrphanFiles...)
>     if (_untouchables != null) {
>       _untouchables.setTargetDir(_todir);
>       DirectoryScanner scanner =
> _untouchables.getDirectoryScanner(prj);
>       String[] preserved =
> scanner.getIncludedFiles();
>       for (int i = 0; i < preserved.length; ++i) {
>         String name = preserved[i];
>         File untouchable = new File(_todir, name);
>         target2source.put(untouchable, _todir);
>       }
>       final int preservedCount =
> target2source.size() - targetCount;
>       log("(preversing " + preservedCount + "
> file(s))",
>           logLevel(preservedCount));
>     }
> 
>   /**
>    * Adds a pseudo-fileset of files not to remove.
>    *
>    * @param  untouchables the <em>do not remove</em>
> files.
>    *         Like a fileset, except the dir
> attribute is implicit.
>    */
>   public void addPreservedFiles(PreservedFiles
> untouchables) {
>     if (_untouchables != null) {
>       throw new BuildException("Too many
> <preservedfiles> elements: >1!");
>     }
>     _untouchables = untouchables;
>   }
> 
>   /**
>    * A pseudo-fileset for files that should not be
> removed from the
>    * sync'd directory, even though they don't have
> an equivalent source.
>    */
>   public static class PreservedFiles extends
> AbstractFileSet {
> 
>     /**
>      * Instantiates a new preserved file
> pseudo-fileset.
>      * <p>
>      * Sets "defaultexcludes" to <code>false</code>
>      * (instead of <code>true</code>) by default.
>      */
>     public PreservedFiles() {
>       super();
>       setDefaultexcludes(false);
>     }
> 
>     /**
>      * Always throws an exception, since disallowed.
>      *
>      * @param  dir ignored
>      * @throws BuildException always
>      */
>     public void setDir(File dir) throws
> BuildException {
>       throw new BuildException("Cannot set
> directory. Sync'd directory
> used!");
>     }
> 
>     /**
>      * Sets the implicit fileset directory.
>      *
>      * @param  dir the sync'd directory.
>      */
>     private void setTargetDir(File dir) throws
> BuildException {
>       super.setDir(dir);
>     }
> 
>   } // END static class PreservedFiles
> 
> 
> 
> 
> > -----Original Message-----
> > From: Mark Benussi
> [mailto:mark_benussi@hotmail.com]
> > Sent: Thursday, August 18, 2005 7:08 AM
> > To: 'Ant Users List'
> > Subject: RE: Sync removing cvs information in
> target directory
> > 
> > Great idea!
> > 
> > -----Original Message-----
> > From: Jeffrey E Care [mailto:carej@us.ibm.com]
> > Sent: 18 August 2005 12:25
> > To: Ant Users List
> > Subject: Re: Sync removing cvs information in
> target directory
> > 
> > I move the CVS directories to a temporary holding
> area, perform the sync,
> > then move them back. You'll also need to fiddle
> with the default excludes
> > to make this work.
> > 
> > --
> > Jeffrey E. Care (carej@us.ibm.com)
> > WebSphere v7 Release Engineer
> > WebSphere Build Tooling Lead (Project Mantis)
> > 
> > 
> > "Mark Benussi" <ma...@hotmail.com> wrote on
> 08/18/2005 06:44:03 AM:
> > 
> > > Hi Guys,
> > >
> > >
> > >
> > > Any ideas how I could use the sync task but not
> remove any directories
> > in
> > > the target that are named CVS. Basically my CVS
> information is getting
> > wiped
> > > and this is causing problems.
> > >
> > >
> > >
> > >
> > >
> > 
> >
>
---------------------------------------------------------------------
> > 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
> 
> 



		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

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


RE: Sync removing cvs information in target directory

Posted by Mark Benussi <ma...@hotmail.com>.
Um Rock and roll... thanks for that.

I will have to get my head round the code as I am not too good at the custom
tasks stuff

-----Original Message-----
From: Dominique Devienne [mailto:ddevienne@gmail.com] 
Sent: 18 August 2005 15:35
To: 'Ant Users List'
Subject: RE: Sync removing cvs information in target directory

Using the code below, you can patch the <sync> task to preserve arbitrary
files. You'll have to code and compile it yourself though. --DD

    <bm:lsync2 todir="jar">
      <preservedfiles includes="**/CVS/**" />

      <fileset dir="${sync.win32.from}">
        <include name="com_lgc_foo_devkit.jar" />
        <include name="com_lgc_foo_dataTypes.jar" />
        <include name="com_lgc_bar_devkit.jar" />
      </fileset>
    </bm:lsync2>

  /** The <em>untouchable</em> files: the ones not to delete. */
  private PreservedFiles _untouchables;


Between Pass#1 and Pass#2, in execute():

    // Gather the untouchable files, if any (yes, we're scanning
    // the sync'd dir twice here and in removeOrphanFiles...)
    if (_untouchables != null) {
      _untouchables.setTargetDir(_todir);
      DirectoryScanner scanner = _untouchables.getDirectoryScanner(prj);
      String[] preserved = scanner.getIncludedFiles();
      for (int i = 0; i < preserved.length; ++i) {
        String name = preserved[i];
        File untouchable = new File(_todir, name);
        target2source.put(untouchable, _todir);
      }
      final int preservedCount = target2source.size() - targetCount;
      log("(preversing " + preservedCount + " file(s))",
          logLevel(preservedCount));
    }

  /**
   * Adds a pseudo-fileset of files not to remove.
   *
   * @param  untouchables the <em>do not remove</em> files.
   *         Like a fileset, except the dir attribute is implicit.
   */
  public void addPreservedFiles(PreservedFiles untouchables) {
    if (_untouchables != null) {
      throw new BuildException("Too many <preservedfiles> elements: >1!");
    }
    _untouchables = untouchables;
  }

  /**
   * A pseudo-fileset for files that should not be removed from the
   * sync'd directory, even though they don't have an equivalent source.
   */
  public static class PreservedFiles extends AbstractFileSet {

    /**
     * Instantiates a new preserved file pseudo-fileset.
     * <p>
     * Sets "defaultexcludes" to <code>false</code>
     * (instead of <code>true</code>) by default.
     */
    public PreservedFiles() {
      super();
      setDefaultexcludes(false);
    }

    /**
     * Always throws an exception, since disallowed.
     *
     * @param  dir ignored
     * @throws BuildException always
     */
    public void setDir(File dir) throws BuildException {
      throw new BuildException("Cannot set directory. Sync'd directory
used!");
    }

    /**
     * Sets the implicit fileset directory.
     *
     * @param  dir the sync'd directory.
     */
    private void setTargetDir(File dir) throws BuildException {
      super.setDir(dir);
    }

  } // END static class PreservedFiles




> -----Original Message-----
> From: Mark Benussi [mailto:mark_benussi@hotmail.com]
> Sent: Thursday, August 18, 2005 7:08 AM
> To: 'Ant Users List'
> Subject: RE: Sync removing cvs information in target directory
> 
> Great idea!
> 
> -----Original Message-----
> From: Jeffrey E Care [mailto:carej@us.ibm.com]
> Sent: 18 August 2005 12:25
> To: Ant Users List
> Subject: Re: Sync removing cvs information in target directory
> 
> I move the CVS directories to a temporary holding area, perform the sync,
> then move them back. You'll also need to fiddle with the default excludes
> to make this work.
> 
> --
> Jeffrey E. Care (carej@us.ibm.com)
> WebSphere v7 Release Engineer
> WebSphere Build Tooling Lead (Project Mantis)
> 
> 
> "Mark Benussi" <ma...@hotmail.com> wrote on 08/18/2005 06:44:03 AM:
> 
> > Hi Guys,
> >
> >
> >
> > Any ideas how I could use the sync task but not remove any directories
> in
> > the target that are named CVS. Basically my CVS information is getting
> wiped
> > and this is causing problems.
> >
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> 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


RE: Sync removing cvs information in target directory

Posted by Dominique Devienne <dd...@gmail.com>.
Using the code below, you can patch the <sync> task to preserve arbitrary
files. You'll have to code and compile it yourself though. --DD

    <bm:lsync2 todir="jar">
      <preservedfiles includes="**/CVS/**" />

      <fileset dir="${sync.win32.from}">
        <include name="com_lgc_foo_devkit.jar" />
        <include name="com_lgc_foo_dataTypes.jar" />
        <include name="com_lgc_bar_devkit.jar" />
      </fileset>
    </bm:lsync2>

  /** The <em>untouchable</em> files: the ones not to delete. */
  private PreservedFiles _untouchables;


Between Pass#1 and Pass#2, in execute():

    // Gather the untouchable files, if any (yes, we're scanning
    // the sync'd dir twice here and in removeOrphanFiles...)
    if (_untouchables != null) {
      _untouchables.setTargetDir(_todir);
      DirectoryScanner scanner = _untouchables.getDirectoryScanner(prj);
      String[] preserved = scanner.getIncludedFiles();
      for (int i = 0; i < preserved.length; ++i) {
        String name = preserved[i];
        File untouchable = new File(_todir, name);
        target2source.put(untouchable, _todir);
      }
      final int preservedCount = target2source.size() - targetCount;
      log("(preversing " + preservedCount + " file(s))",
          logLevel(preservedCount));
    }

  /**
   * Adds a pseudo-fileset of files not to remove.
   *
   * @param  untouchables the <em>do not remove</em> files.
   *         Like a fileset, except the dir attribute is implicit.
   */
  public void addPreservedFiles(PreservedFiles untouchables) {
    if (_untouchables != null) {
      throw new BuildException("Too many <preservedfiles> elements: >1!");
    }
    _untouchables = untouchables;
  }

  /**
   * A pseudo-fileset for files that should not be removed from the
   * sync'd directory, even though they don't have an equivalent source.
   */
  public static class PreservedFiles extends AbstractFileSet {

    /**
     * Instantiates a new preserved file pseudo-fileset.
     * <p>
     * Sets "defaultexcludes" to <code>false</code>
     * (instead of <code>true</code>) by default.
     */
    public PreservedFiles() {
      super();
      setDefaultexcludes(false);
    }

    /**
     * Always throws an exception, since disallowed.
     *
     * @param  dir ignored
     * @throws BuildException always
     */
    public void setDir(File dir) throws BuildException {
      throw new BuildException("Cannot set directory. Sync'd directory
used!");
    }

    /**
     * Sets the implicit fileset directory.
     *
     * @param  dir the sync'd directory.
     */
    private void setTargetDir(File dir) throws BuildException {
      super.setDir(dir);
    }

  } // END static class PreservedFiles




> -----Original Message-----
> From: Mark Benussi [mailto:mark_benussi@hotmail.com]
> Sent: Thursday, August 18, 2005 7:08 AM
> To: 'Ant Users List'
> Subject: RE: Sync removing cvs information in target directory
> 
> Great idea!
> 
> -----Original Message-----
> From: Jeffrey E Care [mailto:carej@us.ibm.com]
> Sent: 18 August 2005 12:25
> To: Ant Users List
> Subject: Re: Sync removing cvs information in target directory
> 
> I move the CVS directories to a temporary holding area, perform the sync,
> then move them back. You'll also need to fiddle with the default excludes
> to make this work.
> 
> --
> Jeffrey E. Care (carej@us.ibm.com)
> WebSphere v7 Release Engineer
> WebSphere Build Tooling Lead (Project Mantis)
> 
> 
> "Mark Benussi" <ma...@hotmail.com> wrote on 08/18/2005 06:44:03 AM:
> 
> > Hi Guys,
> >
> >
> >
> > Any ideas how I could use the sync task but not remove any directories
> in
> > the target that are named CVS. Basically my CVS information is getting
> wiped
> > and this is causing problems.
> >
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> 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


RE: Sync removing cvs information in target directory

Posted by Mark Benussi <ma...@hotmail.com>.
Great idea!

-----Original Message-----
From: Jeffrey E Care [mailto:carej@us.ibm.com] 
Sent: 18 August 2005 12:25
To: Ant Users List
Subject: Re: Sync removing cvs information in target directory

I move the CVS directories to a temporary holding area, perform the sync, 
then move them back. You'll also need to fiddle with the default excludes 
to make this work.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


"Mark Benussi" <ma...@hotmail.com> wrote on 08/18/2005 06:44:03 AM:

> Hi Guys,
> 
> 
> 
> Any ideas how I could use the sync task but not remove any directories 
in
> the target that are named CVS. Basically my CVS information is getting 
wiped
> and this is causing problems.
> 
> 
> 
> 
> 

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


Re: Sync removing cvs information in target directory

Posted by Jeffrey E Care <ca...@us.ibm.com>.
I move the CVS directories to a temporary holding area, perform the sync, 
then move them back. You'll also need to fiddle with the default excludes 
to make this work.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


"Mark Benussi" <ma...@hotmail.com> wrote on 08/18/2005 06:44:03 AM:

> Hi Guys,
> 
> 
> 
> Any ideas how I could use the sync task but not remove any directories 
in
> the target that are named CVS. Basically my CVS information is getting 
wiped
> and this is causing problems.
> 
> 
> 
> 
>