Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.Copy


      }
    }
    if ((null != sourceRootCopyFilter) && (null != sourceRoots)) {
      String[] paths = sourceRoots.list();
      if (!LangUtil.isEmpty(paths)) {
        Copy copy = new Copy();
        copy.setProject(project);
        copy.setTodir(destDir);
        for (int i = 0; i < paths.length; i++) {
          FileSet fileSet = new FileSet();
          fileSet.setDir(new File(paths[i]));
          fileSet.setIncludes("**/*");
          fileSet.setExcludes(sourceRootCopyFilter);
          copy.addFileset(fileSet);
        }
        copy.execute();
      }
    }
    if ((null != inpathDirCopyFilter) && (null != inpath)) {
      String[] paths = inpath.list();
      if (!LangUtil.isEmpty(paths)) {
        Copy copy = new Copy();
        copy.setProject(project);
        copy.setTodir(destDir);
        boolean gotDir = false;
        for (int i = 0; i < paths.length; i++) {
          File inpathDir = new File(paths[i]);
          if (inpathDir.isDirectory() && inpathDir.canRead()) {
            if (!gotDir) {
              gotDir = true;
            }
            FileSet fileSet = new FileSet();
            fileSet.setDir(inpathDir);
            fileSet.setIncludes("**/*");
            fileSet.setExcludes(inpathDirCopyFilter);
            copy.addFileset(fileSet);
          }
        }
        if (gotDir) {
          copy.execute();
        }
      }
    }
  }
View Full Code Here


                        // we'd like to
                        // later delete the old copy, but we can't reliably do
                        // so, as before the VM
                        // shuts down there might be a new job created under the
                        // old name.
                        Copy cp = new Copy();
                        cp.setProject(new org.apache.tools.ant.Project());
                        cp.setTodir(newRoot);
                        FileSet src = new FileSet();
                        src.setDir(getRootDir());
                        cp.addFileset(src);
                        cp.setOverwrite(true);
                        cp.setPreserveLastModified(true);
                        cp.setFailOnError(false); // keep going even if
                                                    // there's an error
                        cp.execute();

                        // try to delete as much as possible
                        try {
                            Util.deleteRecursive(oldRoot);
                        } catch (IOException e) {
View Full Code Here

    /**
     * Copies a single file by using Ant.
     */
    public static void copyFile(File src, File dst) throws BuildException {
        Copy cp = new Copy();
        cp.setProject(new org.apache.tools.ant.Project());
        cp.setTofile(dst);
        cp.setFile(src);
        cp.setOverwrite(true);
        cp.execute();
    }
View Full Code Here

        copySingleFileWithOverwrite(sourceFile, destFile, false);
    }

    protected static void copySingleFileWithOverwrite(File sourceFile, File destFile, boolean overwrite) {
        Project p = new Project();
        Copy c = new Copy();
        c.setProject(p);
        c.setTofile(destFile);
        FileSet fs = new FileSet();
        fs.setProject(p);
        fs.setFile(sourceFile);
        c.addFileset(fs);
        c.setOverwrite(overwrite);
        c.execute();
    }
View Full Code Here

        c.execute();
    }
   
    protected static void copyDirectory(File source, File dest) {
        Project p = new Project();
        Copy c = new Copy();
        c.setProject(p);
        c.setTodir(dest);
        FileSet fs = new FileSet();
        fs.setDir(source);
        c.addFileset(fs);
        c.execute();
    }
View Full Code Here

     */
    protected static boolean copyDirectory(File source, String suffix, File dest) {
      boolean result = false;
      try {
        Project p = new Project();
        Copy c = new Copy();
        c.setProject(p);
        c.setTodir(dest);
        FileSet fs = new FileSet();
        fs.setDir(source);
        if (null != suffix) {
          fs.setIncludes("*" + suffix); // add the wildcard.
        }
        c.addFileset(fs);
        c.execute();
       
        // handle case where no files match; must create empty directory.
        if (!dest.exists()) {
          result = dest.mkdirs();
        } else {
View Full Code Here

     * @param inDestinationDirectory The destination directory to copy to.
     * @param inPattern              The file pattern to match to locate files to copy.
     */
    protected void copyGeneratedObjects(final String inSourceDirectory, final String inDestinationDirectory,
                                        final String inPattern) {
        Copy copyTask = (Copy) antProject.createTask("copy");

        FileSet fileSet = AntUtils.createFileset(inSourceDirectory, inPattern, new ArrayList());
        log("Installing generated files (pattern: " + inPattern + ")...");
        copyTask.setTodir(new File(inDestinationDirectory));
        copyTask.addFileset(fileSet);
        copyTask.execute();
    }
View Full Code Here

            File sqlMapsDir = new File(destinationDirectory + "/src/main/resources/sqlmaps");
            if (sqlMapsDir.exists()) {
                sqlMapsDir.mkdir();
            }

            Copy copy = (Copy) antProject.createTask("copy");
            copy.setFile(new File(sourceDirectory + "/src/main/resources/sqlmaps/" + pojoName + "SQL.xml"));
            copy.setTodir(new File(destinationDirectory + "/src/main/resources/sqlmaps"));
            copy.execute();

            // Add compass gps bean if it doesn't exist
            File ctx = new File(destinationDirectory + "/src/main/webapp/WEB-INF/applicationContext.xml");
            try {
                File appCtx = new File(destinationDirectory + "/src/main/webapp/WEB-INF/applicationContext.xml");
View Full Code Here

    }

    // =================== Views ===================

    private void installJSFViews() {
        Copy copy = (Copy) antProject.createTask("copy");
        copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "Form.xhtml"));
        copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + pojoNameLower + "Form.xhtml"));
        copy.execute();

        copy.setFile(new File(sourceDirectory + "/src/main/webapp/" + pojoName + "s.xhtml"));
        copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + util.getPluralForWord(pojoNameLower) + ".xhtml"));
        copy.execute();
    }
View Full Code Here

        copy.setTofile(new File(destinationDirectory + "/src/main/webapp/" + util.getPluralForWord(pojoNameLower) + ".xhtml"));
        copy.execute();
    }

    private void installSpringViews() {
        Copy copy = (Copy) antProject.createTask("copy");
        copy.setFile(new File(sourceDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoName + "form.jsp"));
        copy.setTofile(new File(destinationDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoNameLower + "form.jsp"));
        copy.execute();

        copy.setFile(new File(sourceDirectory + "/src/main/webapp/WEB-INF/pages/" + pojoName + "s.jsp"));
        copy.setTofile(new File(destinationDirectory + "/src/main/webapp/WEB-INF/pages/" + util.getPluralForWord(pojoNameLower) + ".jsp"));
        copy.execute();
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.Copy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.