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

The following examples show how to use org.apache.tools.ant.taskdefs.Copy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenerateJnlpFileTask.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void copyFile(File src, File dest) {
    Copy copyTask = (Copy) getProject().createTask("copy"); //NOI18N
    copyTask.setFile(src);
    copyTask.setTodir(dest);
    copyTask.setFailOnError(false);
    copyTask.init();
    copyTask.setLocation(getLocation());
    copyTask.execute();
}
 
Example #2
Source File: MakeJNLP.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Signs or copies the given files according to the signJars variable value.
 */
private void signOrCopy(File from, File to) {
    if (!from.exists() && from.getParentFile().getName().equals("locale")) {
        // skip missing locale files, probably the best fix for #103301
        log("Localization file " + from + " is referenced, but cannot be found. Skipping.", Project.MSG_WARN);
        return;
    }
    if (signJars) {
        getSignTask().setJar(from);
        if (to != null) {
            // #125970: might be .../modules/locale/something_ja.jar
            to.getParentFile().mkdirs();
        }
        getSignTask().setSignedjar(to);
        getSignTask().setDigestAlg("SHA1");
        getSignTask().execute();
    } else if (to != null) {
        Copy copy = (Copy)getProject().createTask("copy");
        copy.setFile(from);
        copy.setTofile(to);
        copy.execute();
    }        
    if (processJarVersions) {
      if (jarDirectories == null) {
        jarDirectories = new HashSet<>();
      }
      jarDirectories.add(new File(to.getParent()));
    }
}
 
Example #3
Source File: DeployMojoSupport.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
protected void installApp(Artifact artifact) throws Exception {

    if (artifact.getFile() == null || artifact.getFile().isDirectory()) {
        String warName = getAppFileName(project);
        File f = new File(project.getBuild().getDirectory() + "/" + warName);
        artifact.setFile(f);
    }

    if (!artifact.getFile().exists()) {
        throw new MojoExecutionException(messages.getString("error.install.app.missing"));
    }

    File destDir = new File(serverDirectory, getAppsDirectory());
    log.info(MessageFormat.format(messages.getString("info.install.app"), artifact.getFile().getCanonicalPath()));

    Copy copyFile = (Copy) ant.createTask("copy");
    copyFile.setFile(artifact.getFile());
    String fileName = artifact.getFile().getName();
    if (stripVersion) {
        fileName = stripVersionFromName(fileName, artifact.getBaseVersion());
        copyFile.setTofile(new File(destDir, fileName));
    } else {
        copyFile.setTodir(destDir);
    }

    // validate application configuration if appsDirectory="dropins" or inject
    // webApplication
    // to target server.xml if not found for appsDirectory="apps"
    validateAppConfig(fileName, artifact.getArtifactId());

    deleteApplication(new File(serverDirectory, "apps"), artifact.getFile());
    deleteApplication(new File(serverDirectory, "dropins"), artifact.getFile());
    // application can be expanded if server.xml configure with <applicationManager
    // autoExpand="true"/>
    deleteApplication(new File(serverDirectory, "apps/expanded"), artifact.getFile());
    copyFile.execute();

    verifyAppStarted(fileName);
}