本文整理汇总了Java中org.apache.tools.ant.taskdefs.Copy类的典型用法代码示例。如果您正苦于以下问题:Java Copy类的具体用法?Java Copy怎么用?Java Copy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Copy类属于org.apache.tools.ant.taskdefs包,在下文中一共展示了Copy类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyFile
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
static public void copyFile(File src, File obj) {
final class AntCopy extends Copy {
@SuppressWarnings("deprecation")
public AntCopy() {
project = new Project();
project.init();
taskType = "copy";
taskName = "copy";
target = new Target();
}
}
AntCopy ant = new AntCopy();
ant.setFile(src);
ant.setTofile(obj);
ant.execute();
}
示例2: copySet
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
private void copySet(LayoutFileSet set) {
Copy task = new Copy();
task.setTaskName("copy");
task.setProject(getProject());
String prefix = set.getPrefix(getProject());
File target = prefix.length() > 0 ? new File(destDirectory, prefix + "/") : destDirectory;
target.mkdirs();
task.setTodir(target);
LayoutFileSet unprefixed = (LayoutFileSet) set.clone();
unprefixed.setPrefix("");
task.addFileset(unprefixed);
task.perform();
}
示例3: copyFiles
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
/**
* Move java or class files to temp files or moves the temp files back to
* java or class files. This must be done because javac is too nice and
* sticks already compiled classes and ones depended on in the classpath
* destroying the compile time wall. This way, we can keep the wall up.
*
* @param srcDir
* Directory to copy files from/to(Usually the java files dir or
* the class files dir)
* @param fileset
* The fileset of files to include in the move.
* @param moveToTempFile
* true if moving src files to temp files, false if moving temp
* files back to src files.
* @param isJavaFiles
* true if we are moving .java files, false if we are moving
* .class files.
*/
private void copyFiles(File srcDir, File destDir, FileSet fileset) {
fileset.setDir(srcDir);
if (!srcDir.exists())
throw new BuildException("Directory=" + srcDir + " does not exist", getLocation());
// before we do this, we have to move all files not
// in the above fileset to xxx.java.ant-tempfile
// so that they don't get dragged into the compile
// This way we don't miss anything and all the dependencies
// are listed or the compile will break.
Copy move = (Copy) getProject().createTask("SilentCopy");
move.setProject(getProject());
move.setOwningTarget(getOwningTarget());
move.setTaskName(getTaskName());
move.setLocation(getLocation());
move.setTodir(destDir);
// move.setOverwrite(true);
move.addFileset(fileset);
move.perform();
}
示例4: signOrCopy
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
/**
* 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()));
}
}
示例5: copyFile
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
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();
}
示例6: copyDirectory
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
public 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();
}
示例7: installApp
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
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();
}
示例8: copyClassFiles
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
private void copyClassFiles(File jspCompileDir) {
Copy copy = new Copy();
copy.setProject(getProject());
copy.setTaskName(getTaskName());
destdir.mkdirs();
copy.setTodir(destdir);
FileSet files = new FileSet();
files.setDir(jspCompileDir);
files.setIncludes("**/*.class");
copy.addFileset(files);
copy.execute();
}
示例9: copyIcon
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
void copyIcon() throws BuildException {
if (parent.getIcon() != null && parent.getIcon().isFile()) {
Copy cp = createTask(Copy.class);
cp.setTodir(resourcesDir);
cp.setFile(parent.getIcon());
cp.execute();
}
}
示例10: copyJars
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
void copyJars() {
if (!parent.getLibs().isEmpty()) {
Copy cp = createTask(Copy.class);
cp.setTodir(javaDir);
cp.setFlatten(true);
for (FileSet fs : parent.getLibs()) {
cp.addFileset(fs);
}
cp.execute();
}
}
示例11: RenamedFileContainer
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
public RenamedFileContainer() {
copyTask = new Copy();
copyTask.setTaskName("copy");
}
示例12: signOrCopy
import org.apache.tools.ant.taskdefs.Copy; //导入依赖的package包/类
/**
* Signs or copies the given files according to the signJars variable value.
*/
private JarConfigResolved signOrCopy(File from, File to)
{
final JarConfigResolved[] jarConfigResolved = new JarConfigResolved[1];
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 jarConfigResolved[0];
}
if (signJars) {
if (to != null) {
// #125970: might be .../modules/locale/something_ja.jar
to.getParentFile().mkdirs();
}
SignJar signJar = createSignTask();
signJar.setSigningListener(
new SignJar.SigningListener()
{
@Override
public void beforeSigning( JarConfigResolved jarConfig )
{
jarConfigResolved[0] = jarConfig;
}
});
signJar.setJar( from );
signJar.setSignedjar( to );
signJar.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<File>();
}
jarDirectories.add(new File(to.getParent()));
}
return jarConfigResolved[0];
}