Java Code Examples for org.codehaus.plexus.util.FileUtils#cleanDirectory()

The following examples show how to use org.codehaus.plexus.util.FileUtils#cleanDirectory() . 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: ApiTestMojoTest.java    From tcases with MIT License 6 votes vote down vote up
/**
 * Clean configured output directory.
 */
private void clean( ApiTestMojo apiMojo)
  {
  File outDir = apiMojo.getOutDirFile();
  if( outDir.exists())
    {
    try
      {
      FileUtils.cleanDirectory( outDir);
      }
    catch( Exception e)
      {
      throw new RuntimeException( "Can't clear outDir=" + outDir, e);
      }
    }
  }
 
Example 2
Source File: ApiMojoTest.java    From tcases with MIT License 6 votes vote down vote up
/**
 * Clean configured output directory.
 */
private void clean( ApiMojo apiMojo)
  {
  File outDir = apiMojo.getOutDirFile();
  if( outDir.exists())
    {
    try
      {
      FileUtils.cleanDirectory( outDir);
      }
    catch( Exception e)
      {
      throw new RuntimeException( "Can't clear outDir=" + outDir, e);
      }
    }
  }
 
Example 3
Source File: TcasesMojoTest.java    From tcases with MIT License 6 votes vote down vote up
/**
 * 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);
      }
    }
  }
 
Example 4
Source File: ReducerMojoTest.java    From tcases with MIT License 6 votes vote down vote up
/**
 * 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);
    }
  }
 
Example 5
Source File: GolangCleanMojo.java    From mvn-golang with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example 6
Source File: TransformMojoTest.java    From xml-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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() );
}
 
Example 7
Source File: TransformMojoTest.java    From xml-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
    }
}
 
Example 8
Source File: TransformMojoTest.java    From xml-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
    }
}