ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <ddevie...@gmail.com>
Subject RE: Sync removing cvs information in target directory
Date Thu, 18 Aug 2005 14:35:23 GMT
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" <mark_benussi@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


Mime
View raw message