本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.cleanDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.cleanDirectory方法的具体用法?Java FileUtils.cleanDirectory怎么用?Java FileUtils.cleanDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.cleanDirectory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clean
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Clean configured output directory.
*/
private void clean( TcasesMojo tcasesMojo)
{
File outDir = tcasesMojo.getOutDirFile();
if( outDir.exists())
{
try
{
FileUtils.cleanDirectory( outDir);
}
catch( Exception e)
{
throw new RuntimeException( "Can't clear outDir=" + outDir, e);
}
}
}
示例2: clean
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Clean configured output directory.
*/
private void clean( File baseDirTest)
{
File outDir = null;
try
{
TcasesMojo tcasesMojo = (TcasesMojo) mojoHelper.lookupConfiguredMojo( baseDirTest, "tcases");
outDir = tcasesMojo.getOutDirFile();
if( outDir.exists())
{
FileUtils.cleanDirectory( outDir);
}
}
catch( Exception e)
{
throw new RuntimeException( "Can't clear outDir=" + outDir, e);
}
}
示例3: initializeRepository
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public static void initializeRepository( File repositoryRoot )
throws Exception
{
if ( repositoryRoot.exists() )
{
FileUtils.deleteDirectory( repositoryRoot );
}
Assert.assertTrue( "Could not make repository root directory: " + repositoryRoot.getAbsolutePath(),
repositoryRoot.mkdirs() );
//ScmTestCase.execute( repositoryRoot.getParentFile(), SVNADMIN_COMMAND_LINE, "create " + repositoryRoot.getName() );
if (repositoryRoot.exists())
{
FileUtils.cleanDirectory( repositoryRoot );
}
ISVNOptions options = SVNWCUtil.createDefaultOptions( true );
SVNClientManager.newInstance().getAdminClient().doCreateRepository( repositoryRoot, null, true, true );
loadSvnDump( repositoryRoot,
new SvnJavaScmTestUtils().getClass().getClassLoader().getResourceAsStream( "tck/tck.dump" ) );
}
示例4: cleanGoPath
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void cleanGoPath() throws MojoFailureException {
try {
final File[] goPathFolders = findGoPath(false);
for (final File f : goPathFolders) {
if (f.isDirectory()) {
getLog().warn("Cleaning the Go Path folder : " + f);
FileUtils.cleanDirectory(f);
} else {
getLog().info("Can't find GOPATH folder : " + f);
}
}
} catch (IOException ex) {
throw new MojoFailureException("Can't clean the Go Path folder", ex);
}
}
示例5: init
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
public void init(InputConfiguration configuration) {
super.init(configuration);
final String configurationPath = configuration.getProperty("configPath");
final String pathToFolder = configuration.getProperty("folderPath");
InputConfiguration inputConfiguration = null;
try {
inputConfiguration = new InputConfiguration(configurationPath);
InputProgram inputProgram = InputConfiguration.initInputProgram(inputConfiguration);
inputConfiguration.setInputProgram(inputProgram);
inputProgram.setProgramDir(pathToFolder);
String dependencies = AutomaticBuilderFactory.getAutomaticBuilder(inputConfiguration)
.buildClasspath(inputProgram.getProgramDir());
File output = new File(inputProgram.getProgramDir() + "/" + inputProgram.getClassesDir());
try {
FileUtils.cleanDirectory(output);
} catch (IllegalArgumentException ignored) {
//the target directory does not exist, do not need to clean it
}
this.pathToChangedVersionOfProgram = pathToFolder +
DSpotUtils.shouldAddSeparator.apply(pathToFolder) +
(inputConfiguration.getProperty("targetModule") != null ?
inputConfiguration.getProperty("targetModule") +
DSpotUtils.shouldAddSeparator.apply(pathToFolder)
: "");
DSpotCompiler.compile(this.pathToChangedVersionOfProgram +
inputProgram.getRelativeSourceCodeDir() +
DSpotUtils.shouldAddSeparator.apply(inputProgram.getRelativeSourceCodeDir()),
dependencies, output);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例6: testIt11
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Builds the it11 test project, tests in-place modification.
* @throws Exception The test failed.
*/
public void testIt11()
throws Exception
{
String projectPath = "src/test/it11";
File projectDirectory = new File( getBasedir(), projectPath );
File targetDirectory = new File( projectPath, "target" );
if ( targetDirectory.exists() )
{
FileUtils.cleanDirectory( targetDirectory );
}
File xmlInputDirectory = new File( projectDirectory, "xml" );
File xmlOutputDirectory = new File( targetDirectory, "generated-resources/xml/xslt" );
/* copy to target since that is in an SCM-ignored directory */
FileUtils.copyDirectory( xmlInputDirectory, xmlOutputDirectory, "*.xml", null );
TransformMojo mojo = (TransformMojo) newMojo( projectPath );
mojo.execute();
String fileToTransform = "doc1.xml";
Document doc1 = parse( new File( xmlInputDirectory, fileToTransform ) );
doc1.normalize();
Document doc2 = parse( new File( xmlOutputDirectory, fileToTransform ) );
doc2.normalize();
Element doc1Element = doc1.getDocumentElement();
assertEquals( "doc1", doc1Element.getLocalName() );
assertNull( doc1Element.getNamespaceURI() );
Element doc2Element = doc2.getDocumentElement();
assertEquals( "doc2", doc2Element.getLocalName() );
assertNull( doc2Element.getNamespaceURI() );
Node text1 = doc1Element.getFirstChild();
assertNotNull( text1 );
assertNull( text1.getNextSibling() );
assertEquals( Node.TEXT_NODE, text1.getNodeType() );
Node text2 = doc2Element.getFirstChild();
assertNotNull( text2 );
assertNull( text2.getNextSibling() );
assertEquals( Node.TEXT_NODE, text2.getNodeType() );
assertEquals( text1.getNodeValue(), text2.getNodeValue() );
}
示例7: testItXIncludeEnabled
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Builds the xinclude test project, tests xinclude enabled transformation
* @throws Exception The test failed.
*/
public void testItXIncludeEnabled()
throws Exception
{
String projectPath = "src/test/xinclude-xsl";
File projectDirectory = new File( getBasedir(), projectPath );
File targetDirectory = new File( projectPath, "target" );
if ( targetDirectory.exists() )
{
FileUtils.cleanDirectory( targetDirectory );
}
File xmlInputDirectory = new File( projectDirectory, "xml" );
File xmlOutputDirectory = new File( targetDirectory, "generated-resources/xml/xslt" );
/* copy to target since that is in an SCM-ignored directory */
FileUtils.copyDirectory( xmlInputDirectory, xmlOutputDirectory, "*.xml", null );
TransformMojo mojo = (TransformMojo) newMojo( projectPath );
mojo.execute();
Document doc = parse( new File( xmlOutputDirectory, "book.xml" ) );
XPath xPath = XPathFactory.newInstance().newXPath();
// Make simple assertions
List<String> xPathNodes = Arrays.asList(
"//book",
"//book/chapter",
"//book/chapter/section"
);
for (String xpath : xPathNodes) {
assertNotNull("Missing :" + xpath, xPath.evaluate(xpath, doc, XPathConstants.NODE));
}
}
示例8: testItXIncludeDisabled
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Builds the xinclude test project, tests xinclude disabled transformation
* @throws Exception The test failed.
*/
public void testItXIncludeDisabled()
throws Exception
{
String projectPath = "src/test/xinclude-xsl";
File projectDirectory = new File( getBasedir(), projectPath );
File targetDirectory = new File( projectPath, "target" );
if ( targetDirectory.exists() )
{
FileUtils.cleanDirectory( targetDirectory );
}
File xmlInputDirectory = new File( projectDirectory, "xml" );
File xmlOutputDirectory = new File( targetDirectory, "generated-resources/xml/xslt" );
/* copy to target since that is in an SCM-ignored directory */
FileUtils.copyDirectory( xmlInputDirectory, xmlOutputDirectory, "*.xml", null );
TransformMojo mojo = (TransformMojo) newMojo( projectPath );
mojo.execute();
Document doc = parse( new File( xmlOutputDirectory, "chapter.xml" ) );
XPath xPath = XPathFactory.newInstance().newXPath();
// Make simple assertions
List<String> xPathNodes = Arrays.asList(
"//chapter",
"//chapter/*[local-name()='include']",
"//chapter/*[local-name()='include']/*[local-name()='fallback']/fallbackSection"
);
for (String xpath : xPathNodes) {
assertNotNull("Missing :" + xpath, xPath.evaluate(xpath, doc, XPathConstants.NODE));
}
}
示例9: createModuleDirectory
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
protected void createModuleDirectory( File moduleDirectory, boolean overwrite )
throws IOException
{
if ( moduleDirectory.exists() )
{
if ( moduleDirectory.isDirectory() )
{
if ( overwrite )
{
FileUtils.cleanDirectory( moduleDirectory );
}
}
else
// file if ( moduleDirectory.isFile() )
{
getLog().info( String.format( "Deleting \"%s\" file", moduleDirectory ) ); // TODO-more descriptive message
if ( !moduleDirectory.delete() )
{
throw new IOException( String.format( "Cannot delete \"%s\" file",
moduleDirectory.getCanonicalPath() ) );
}
}
}
if ( !moduleDirectory.exists() )
{
if ( !moduleDirectory.mkdirs() )
{
throw new IOException( String.format( "Cannot create \"%s\" directory",
moduleDirectory.getCanonicalPath() ) );
}
}
}
示例10: createDir
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void createDir( File directory )
throws IOException
{
if ( directory.exists() )
{
if ( directory.isDirectory() )
{
if ( homeOverwrite )
{
FileUtils.cleanDirectory( directory );
}
}
else
{
throw new IOException( String.format( "\"%s\" is not a directory", directory.getCanonicalPath() ) );
}
}
else
{
if ( !directory.mkdirs() )
{
throw new IOException( String.format( "Cannot create \"%s\" directory", directory.getCanonicalPath() ) );
}
}
if ( !directory.exists() )
{
if ( !directory.mkdirs() )
{
throw new IOException( String.format( "Cannot create \"%s\" directory", directory.getCanonicalPath() ) );
}
}
}