本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.copyFileToDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyFileToDirectory方法的具体用法?Java FileUtils.copyFileToDirectory怎么用?Java FileUtils.copyFileToDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.copyFileToDirectory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execution
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
File fileTo = getFileTo(transformedAppFolder, transformationContext);
TOExecutionResult result = null;
// TODO
// Check if it is really a file and if it exists!
try {
String details = String.format("File '%s' has been moved to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo));
FileUtils.copyFileToDirectory(fileFrom, fileTo);
FileUtils.fileDelete(fileFrom.getAbsolutePath());
result = TOExecutionResult.success(this, details);
} catch (IOException e) {
result = TOExecutionResult.error(this, e);
}
return result;
}
示例2: execution
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
File fileTo = getFileTo(transformedAppFolder, transformationContext);
TOExecutionResult result = null;
try {
String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo));
FileUtils.copyFileToDirectory(fileFrom, fileTo);
result = TOExecutionResult.success(this, details);
} catch (IOException e) {
result = TOExecutionResult.error(this, e);
}
return result;
}
示例3: generateConfdArtefacts
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public static void generateConfdArtefacts(
PrepareContext context,
List<TemplateConfig> templates,
boolean forceDestToLocalFileSystemType,
Log log
) throws IOException {
File workingDirectory = context.getWorkingDirectory();
File templatesDirectory = new File(workingDirectory, TEMPLATES_DIRECTORY);
File tomlDirectory = new File(workingDirectory, CONF_D_DIRECTORY);
if (workingDirectory.exists()) {
FileUtils.deleteDirectory(workingDirectory);
}
FileUtils.mkdir(templatesDirectory.getAbsolutePath());
FileUtils.mkdir(tomlDirectory.getAbsolutePath());
for (TemplateConfig tc : templates) {
String tomlBaseName = FileUtils.basename(tc.getSrc().getAbsolutePath()) + TOML_FILE_EXT;
File tomlFile = new File(tomlDirectory, tomlBaseName);
writeToml(tomlFile, tc, forceDestToLocalFileSystemType);
FileUtils.copyFileToDirectory(tc.getSrc(), templatesDirectory);
warnAboutKeysExcludedByNamespace(tc, context, log);
}
}
示例4: processSei
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
protected void processSei( String aSei )
throws MojoExecutionException
{
getLog().info( "Processing: " + aSei );
ArrayList<String> args = getWsGenArgs( aSei );
getLog().info( "jaxws:wsgen args: " + args );
exec( args );
if ( metadata != null )
{
try
{
FileUtils.copyFileToDirectory( metadata, getClassesDir() );
}
catch ( IOException ioe )
{
throw new MojoExecutionException( ioe.getMessage(), ioe );
}
}
}
示例5: doPackaging
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void doPackaging(PackagingContext context) throws Exception {
File larsDir = new File(context.getExtensionDirectory(), Constants.DIR_ARCHIVES);
File jarsDir = new File(context.getExtensionDirectory(), Constants.DIR_JARS);
// copy dependencies in
Artifact a;
for (Object aObj : context.getArtifacts()) {
if (aObj instanceof Artifact) {
a = (Artifact)aObj;
if (a.getType().equals("lar"))
FileUtils.copyFileToDirectory(a.getFile(), larsDir);
else if (a.getType().equals("jar"))
FileUtils.copyFileToDirectory(a.getFile(), jarsDir);
else if (a.getType().equals("lex"))
// dont know how to do this better?
System.out.println("[WARNING] Unable to include "+a.toString()+"");
//throw new MojoFailureException("Lucee extension dependency "+a.toString()+" not included!", );
}
}
if (context.getProject().getPackaging().equals(Constants.LEX_PACKAGING)) {
File scanDir = context.getOutputDirectory();
File scanFile;
for (String file : scanDir.list()) {
scanFile = new File(scanDir,file);
if (file.endsWith(".lar")) {
FileUtils.copyFileToDirectory(scanFile, larsDir);
scanFile.delete();
} else if (file.endsWith(".jar")) {
FileUtils.copyFileToDirectory(scanFile, jarsDir);
scanFile.delete();
}
}
}
}
示例6: copyJnlpFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyJnlpFiles()
throws MavenReportException
{
if ( !jnlpSourceDirectory.exists() )
{
throw new MavenReportException( "jnlpSourceDirectory does not exist" );
}
try
{
File destinationDirectory = new File( outputDirectory, siteJnlpDirectory );
List<File> files = FileUtils.getFiles( jnlpSourceDirectory, "**/*", "" );
for ( File file : files )
{
getLog().debug( "Copying " + file + " to " + destinationDirectory );
String path = file.getAbsolutePath().substring( jnlpSourceDirectory.getAbsolutePath().length() + 1 );
File destDir = new File( destinationDirectory, path );
getLog().debug( "Copying " + file + " to " + destDir );
if ( file.isDirectory() )
{
destDir.mkdirs();
}
else
{
FileUtils.copyFileToDirectory( file, destDir.getParentFile() );
}
}
}
catch ( IOException e )
{
throw new MavenReportException( "Failed to copy jnlp files", e );
}
}
示例7: copyFileToDirectoryIfNecessary
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public boolean copyFileToDirectoryIfNecessary( File sourceFile, File targetDirectory )
throws MojoExecutionException
{
if ( sourceFile == null )
{
throw new IllegalArgumentException( "sourceFile is null" );
}
File targetFile = new File( targetDirectory, sourceFile.getName() );
boolean shouldCopy = shouldCopyFile( sourceFile, targetFile );
if ( shouldCopy )
{
try
{
FileUtils.copyFileToDirectory( sourceFile, targetDirectory );
}
catch ( IOException e )
{
throw new MojoExecutionException(
"Could not copy file " + sourceFile + " to directory " + targetDirectory, e );
}
}
else
{
getLogger().debug(
"Source file hasn't changed. Do not overwrite " + targetFile + " with " + sourceFile + "." );
}
return shouldCopy;
}
示例8: execute
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
*
*/
public void execute() throws MojoExecutionException, MojoFailureException
{
if ( puXMLFile == null || !FileUtils.fileExists( puXMLFile ) )
{
throw new MojoExecutionException( "missing pu.xml file" );
}
if ( warFile == null || !FileUtils.fileExists( warFile ) )
{
throw new MojoExecutionException( "missing war file" );
}
try
{
String puTargetDir = serverDirectory + File.separator + "META-INF" + File.separator + "spring";
String libTargetDir = serverDirectory + File.separator + "lib";
FileUtils.mkdir( serverDirectory );
FileUtils.mkdir( puTargetDir );
FileUtils.mkdir( libTargetDir );
FileUtils.copyFileToDirectory( new File( puXMLFile ), new File( puTargetDir ) );
FileUtils.copyFileToDirectory( new File( warFile ), new File( serverDirectory ) );
for (Iterator artifactIterator = pluginArtifacts.iterator(); artifactIterator.hasNext();)
{
Artifact artifact = (Artifact) artifactIterator.next();
if (artifact.getGroupId().equals("org.mortbay.jetty") )
{
FileUtils.copyFileToDirectory( artifact.getFile().getPath(), libTargetDir );
}
}
jarArchiver.addDirectory( new File(serverDirectory) );
jarArchiver.setDestFile( new File(artifactName) );
jarArchiver.createArchive();
}
catch ( IOException ioe )
{
throw new MojoExecutionException( "unable to assemble",ioe );
}
catch ( ArchiverException ae )
{
throw new MojoExecutionException( "unable to assembly jar", ae );
}
}
示例9: copyDirectoryStructureWithIO
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyDirectoryStructureWithIO( final File sourceDirectory, final File destinationDirectory,
final File rootDestinationDirectory )
throws IOException
{
preconditionsCopyDirectoryStructure( sourceDirectory, destinationDirectory, rootDestinationDirectory );
File[] files = sourceDirectory.listFiles();
if ( files == null )
{
return;
}
String sourcePath = sourceDirectory.getAbsolutePath();
for ( File file : files )
{
if ( file.equals( rootDestinationDirectory ) )
{
// We don't copy the destination directory in itself
continue;
}
String dest = file.getAbsolutePath();
dest = dest.substring( sourcePath.length() + 1 );
File destination = new File( destinationDirectory, dest );
if ( file.isFile() )
{
destination = destination.getParentFile();
if ( isFileDifferent( file, destination ) )
{
copied++;
FileUtils.copyFileToDirectory( file, destination );
}
}
else if ( file.isDirectory() )
{
if ( !destination.exists() && !destination.mkdirs() )
{
throw new IOException( "Could not create destination directory '" + destination.getAbsolutePath()
+ "'." );
}
copyDirectoryStructureWithIO( file, destination, rootDestinationDirectory );
}
else
{
throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
}
}
}