本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.copyFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyFile方法的具体用法?Java FileUtils.copyFile怎么用?Java FileUtils.copyFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.copyFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Does the actual copy of the file and logging.
*
* @param artifact represents the file to copy.
* @param destFile file name of destination file.
*
* @throws MojoExecutionException with a message if an
* error occurs.
*/
protected void copyFile ( File artifact, File destFile )
throws MojoExecutionException
{
Log theLog = this.getLog();
try
{
theLog.info( "Copying "
+ ( this.outputAbsoluteArtifactFilename ? artifact.getAbsolutePath() : artifact.getName() ) + " to "
+ destFile );
FileUtils.copyFile( artifact, destFile );
}
catch ( Exception e )
{
throw new MojoExecutionException( "Error copying artifact from " + artifact + " to " + destFile, e );
}
}
示例2: copyEmoServiceArtifactToWorkingDirectory
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyEmoServiceArtifactToWorkingDirectory() throws MojoExecutionException, MojoFailureException {
// NOTE: this emo service artifact is an "uberjar" created by the maven-shade-plugin
final ArtifactItem emoServiceArtifact = new ArtifactItem();
emoServiceArtifact.setGroupId("com.bazaarvoice.emodb");
emoServiceArtifact.setArtifactId("emodb-web");
emoServiceArtifact.setVersion(pluginVersion());
resolveArtifactItems(asList(emoServiceArtifact));
final File emoServiceJar = emoServiceArtifact.getResolvedArtifact().getArtifact().getFile();
try {
// copy to "emodb.jar" so that we always overwrite any prior
FileUtils.copyFile(emoServiceJar, new File(emoProcessWorkingDirectory(), "emodb.jar"));
} catch (IOException e) {
throw new MojoFailureException("failed to copy: " + emoServiceArtifact, e);
}
}
示例3: getDependencyFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private File getDependencyFile( Artifact artifact, boolean doCopy )
throws MojoExecutionException
{
File newLocation =
new File( this.externalLibDirectory, artifact.getArtifactId() + "."
+ artifact.getArtifactHandler().getExtension() );
try
{
if ( doCopy && !artifact.getFile().isDirectory()
&& ( !newLocation.exists() || newLocation.lastModified() <= artifact.getFile().lastModified() ) )
{
FileUtils.copyFile( artifact.getFile(), newLocation );
}
}
catch ( IOException ioe )
{
throw new MojoExecutionException( "Unable to copy dependency to staging area. Could not copy "
+ artifact.getFile() + " to " + newLocation, ioe );
}
return newLocation;
}
示例4: addBom
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void addBom() throws MojoFailureException, IOException {
getLog().info("Add the bom to the repository");
String[] groupIdParts = project.getGroupId().split("\\.");
FileSystem fs = FileSystems.getDefault();
Path groupIdDir = fs.getPath(repoDir.getAbsolutePath(), groupIdParts);
Path targetDir = fs.getPath(groupIdDir.toString(), project.getArtifactId(), project.getVersion());
String fileName = String.format("%s-%s.%s",
project.getArtifactId(), project.getVersion(), "pom"
);
File targetFile = new File(targetDir.toFile(), fileName);
FileUtils.copyFile(getBomFile(), targetFile);
getLog().info("Copied the bom to " + targetFile.getAbsolutePath());
}
示例5: execute
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void execute()
throws MojoExecutionException, MojoFailureException
{
File outFile = project.getFile();
File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" );
if ( backupFile.exists() )
{
getLog().info( "Restoring " + outFile + " from " + backupFile );
try
{
FileUtils.copyFile( backupFile, outFile );
FileUtils.forceDelete( backupFile );
}
catch ( IOException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
}
}
示例6: copy
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void copy(File output, String groupId, String artifactId, String version, String exclusion)
throws MojoExecutionException {
output.mkdirs();
boolean atLeastOne = false;
for(Artifact artifact: resolve(groupId, artifactId, version, exclusion)) {
try {
FileUtils.copyFile(artifact.getFile(), new File(output, artifact.getFile().getName()));
atLeastOne = true;
} catch (IOException e) {
throw new MojoExecutionException("could not copy: " + artifact, e);
}
}
if (!atLeastOne) {
throw new MojoExecutionException("could not resolve: " + groupId + ":" + artifactId + ":" + version);
}
}
示例7: executeWithGems
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected void executeWithGems() throws MojoExecutionException,
ScriptException, IOException {
final boolean pluginDependenciesOnly;
switch(type) {
case archive:
if (this.pluginDependenciesOnly == null) {
pluginDependenciesOnly = true;
}
else {
pluginDependenciesOnly = this.pluginDependenciesOnly;
}
break;
default:
pluginDependenciesOnly = false;
}
executeWithGems(pluginDependenciesOnly);
if (bootstrap != null) {
FileUtils.copyFile(bootstrap, new File(project.getBuild().getOutputDirectory(),
"jar-bootstrap.rb"));
}
}
示例8: run
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
public void run() {
File target = data.getJavadocFile();
try {
FileUtils.copyFile(source, target);
} catch (IOException ex) {
ex.printStackTrace();
target.delete();
}
refreshNode();
}
示例9: copyEmoConfigurationFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyEmoConfigurationFile() throws MojoExecutionException, IOException {
if (StringUtils.isBlank(emoConfigurationFile)) {
copyDefaultEmoConfigurationFile();
} else {
try {
// copy configuration file to well-known emodb config directory and filename "config.yaml"
FileUtils.copyFile(new File(emoConfigurationFile), new File(emoConfigurationDirectory(), "config.yaml"));
} catch (Exception e) {
throw new MojoExecutionException("failed to copy configuration file from " + emoConfigurationFile, e);
}
}
}
示例10: copyDdlConfigurationFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyDdlConfigurationFile() throws MojoExecutionException, IOException {
if (StringUtils.isBlank(ddlConfigurationFile)) {
copyDefaultDdlConfigurationFile();
} else {
try {
// copy configuration file to well-known emodb DDL config directory and filename "config-ddl.yaml"
FileUtils.copyFile(new File(ddlConfigurationFile), new File(emoConfigurationDirectory(), "config-ddl.yaml"));
} catch (Exception e) {
throw new MojoExecutionException("failed to copy configuration file from " + ddlConfigurationFile, e);
}
}
}
示例11: makeBackup
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* gestice i backup di un file
*
* @param fileName nome del file che si vuole backuppare
*/
public static void makeBackup(String fileName) {
try {
File original = new File(fileName);
if (original.exists()) {
String localPath = original.getParent() + "/backup";
File lp = new File(localPath);
if (!lp.exists()) {
lp.mkdirs();
}
String savingFileName = localPath + "/" + original.getName();
String pattern = savingFileName;
long oldestTime = System.currentTimeMillis();
for (int i = 0; i < 20; i++) {
String fn = pattern + "." + i + ".bck";
File back = new File(fn);
if (!back.exists()) {
savingFileName = fn;
break;
} else if (back.lastModified() < oldestTime) {
oldestTime = back.lastModified();
savingFileName = back.getAbsolutePath();
}
}
FileUtils.copyFile(original, new File(savingFileName));
}
} catch (Exception e) {
LogGui.printException(e);
}
}
示例12: copyMissingContent
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Copies all content (files and directories) from the source directory to the target directory, except content
* that already exists in the target directory (same name and path), in other words it does not override any
* existing content
*
* <p>
* Files from the source directory can be excluded from the copying by setting one or more patterns in the
* source excludes list
* </p>
*
* @param sourceDirectory directory to copy content from
* @param targetDirectory directory to copy content to
* @param sourceExcludes list of patterns to match on for source exclusions
* @throws IOException
*/
public static void copyMissingContent(File sourceDirectory, File targetDirectory, List<String> sourceExcludes)
throws IOException {
String[] copyExcludes = null;
if ((sourceExcludes != null) && !sourceExcludes.isEmpty()) {
copyExcludes = new String[sourceExcludes.size()];
copyExcludes = sourceExcludes.toArray(copyExcludes);
}
List<String> sourceDirectoryContents = getDirectoryContents(sourceDirectory, null, copyExcludes);
List<String> targetDirectoryContents = getDirectoryContents(targetDirectory, null, null);
for (String sourceContent : sourceDirectoryContents) {
if (targetDirectoryContents.contains(sourceContent)) {
continue;
}
// copy file to target
File sourceFile = new File(sourceDirectory, sourceContent);
File targetFile = new File(targetDirectory, sourceContent);
if (sourceFile.isDirectory()) {
targetFile.mkdir();
} else {
FileUtils.copyFile(sourceFile, targetFile);
}
}
}
示例13: copyJars
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void copyJars() throws IOException {
for(Artifact a: artifacts) {
if (!a.getScope().equals("system")) {
File targetFile = new File(target, a.getGroupId().replace('.', '/') + "/" +
a.getArtifactId() + "/" +
a.getVersion() + "/" +
a.getArtifactId() + "-" + a.getVersion() + "." + a.getType());
FileUtils.copyFile(a.getFile(), targetFile);
}
}
}
示例14: copyExternalFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyExternalFile( File from, File to )
throws DaemonGeneratorException
{
try
{
from.getParentFile().mkdirs();
FileUtils.copyFile( from, to );
}
catch ( IOException e )
{
throw new DaemonGeneratorException( "Could not copy external file: " + from, e );
}
}
示例15: copyFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void copyFile( File sourceFile, File targetFile )
throws MojoExecutionException
{
makeDirectoryIfNecessary( targetFile.getParentFile() );
try
{
FileUtils.copyFile( sourceFile, targetFile );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Could not copy file " + sourceFile + " to " + targetFile, e );
}
}