本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.copyDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyDirectory方法的具体用法?Java FileUtils.copyDirectory怎么用?Java FileUtils.copyDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.copyDirectory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: failLocalChangeItTest
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
@Ignore
// svn local db corrupted
public void failLocalChangeItTest()
throws Exception
{
File projDir = resources.getBasedir( "failed-local-change" );
MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File basedir = result.getBasedir();
File foo = new File( basedir, "foo.txt" );
FileUtils.fileWrite( foo, "hello" );
FileUtils.copyDirectory( new File( basedir, "DotSvnDir" ), new File( basedir, ".svn" ) );
result = mavenExec.execute( "verify" );
// this fail local dotSvnDir corrupted, not b/c we change local file
result.assertLogText( "BUILD FAILURE" );
}
示例2: gitBasicItMBUILDNUM66Test
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
@Ignore
// git local database corrected
public void gitBasicItMBUILDNUM66Test()
throws Exception
{
File projDir = resources.getBasedir( "git-basic-it-MBUILDNUM-66" );
MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File basedir = result.getBasedir();
File foo = new File( basedir, "foo.txt" );
FileUtils.fileWrite( foo, "hello" );
FileUtils.copyDirectory( new File( basedir, "dotGitDir" ), new File( basedir, ".git" ) );
result = mavenExec.execute( "verify" );
// this fail local dotSvnDir corrupted, not b/c we change local file
}
示例3: Mojo1668Test
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void Mojo1668Test()
throws Exception
{
if ( !isSvn18() )
{
System.out.println( "Not Subversion 1.8 compatible. Skip test" );
return;
}
File projDir = resources.getBasedir( "MOJO-1668" );
MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File testDir = result.getBasedir();
FileUtils.copyDirectory( new File( testDir, "DotSvnDir" ), new File( testDir, ".svn" ) );
result = mavenExec.execute( "clean", "verify" );
File artifact = new File( testDir, "target/buildnumber-maven-plugin-MOJO-1668-1.0-SNAPSHOT.jar" );
JarFile jarFile = new JarFile( artifact );
Attributes manifest = jarFile.getManifest().getMainAttributes();
jarFile.close();
String buildDate = manifest.getValue( "Build-Date" );
Assert.assertTrue( buildDate.length() > 0 );
}
示例4: 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() );
}
示例5: 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));
}
}
示例6: 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));
}
}
示例7: attachWsdl
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void attachWsdl()
throws IOException
{
File target = new File( project.getBuild().getDirectory() );
if ( !"war".equalsIgnoreCase( project.getPackaging() ) )
{
// META-INF/wsdl for jar etc packagings
target = new File( project.getBuild().getOutputDirectory(), "META-INF/wsdl" );
}
else
{
// WEB-INF/wsdl for war
String targetPath = null;
Plugin war = project.getBuild().getPluginsAsMap().get( "org.apache.maven.plugins:maven-war-plugin" );
for ( PluginExecution exec : war.getExecutions() )
{
// check execution/configuration
String s = getWebappDirectory( exec.getConfiguration() );
if ( s != null )
{
targetPath = s;
break;
}
}
if ( targetPath == null )
{
// check global plugin configuration
targetPath = getWebappDirectory( war.getConfiguration() );
}
target =
targetPath != null ? new File( targetPath ) : new File( target, project.getBuild().getFinalName() );
target = new File( target, "WEB-INF/wsdl" );
}
if ( !target.mkdirs() && !target.exists() )
{
getLog().warn( "Cannot create directory: " + target.getAbsolutePath() );
}
getLog().debug( "Packaging WSDL(s) to: " + target );
FileUtils.copyDirectory( getResourceDestDir(), target );
}
示例8: basicItTest
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void basicItTest()
throws Exception
{
if ( !isSvn18() )
{
System.out.println( "Not Subversion 1.8 compatible. Skip test" );
return;
}
File projDir = resources.getBasedir( "basic-it" );
MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File testDir = result.getBasedir();
FileUtils.copyDirectory( new File( testDir, "DotSvnDir" ), new File( testDir, ".svn" ) );
result = mavenExec.execute( "clean", "verify" );
result.assertLogText( "Storing buildNumber: 19665" );
result.assertLogText( "Storing buildScmBranch: trunk" );
File artifact = new File( testDir, "target/buildnumber-maven-plugin-basic-it-1.0-SNAPSHOT.jar" );
JarFile jarFile = new JarFile( artifact );
Attributes manifest = jarFile.getManifest().getMainAttributes();
jarFile.close();
String scmRev = manifest.getValue( "SCM-Revision" );
Assert.assertEquals( "19665", scmRev );
}
示例9: basicItNoDevScmTest
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void basicItNoDevScmTest()
throws Exception
{
if ( !isSvn18() )
{
System.out.println( "Not Subversion 1.8 compatible. Skip test" );
return;
}
File projDir = resources.getBasedir( "basic-it-no-devscm" );
MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File testDir = result.getBasedir();
FileUtils.copyDirectory( new File( testDir, "DotSvnDir" ), new File( testDir, ".svn" ) );
result = mavenExec.execute( "clean", "verify" );
result.assertLogText( "Storing buildNumber: 19665" );
result.assertLogText( "Storing buildScmBranch: trunk" );
File artifact = new File( testDir, "target/buildnumber-maven-plugin-basic-it-no-devscm-1.0-SNAPSHOT.jar" );
JarFile jarFile = new JarFile( artifact );
Attributes manifest = jarFile.getManifest().getMainAttributes();
jarFile.close();
String scmRev = manifest.getValue( "SCM-Revision" );
Assert.assertEquals( "19665", scmRev );
}
示例10: basicItSvnJavaTest
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void basicItSvnJavaTest()
throws Exception
{
if ( !isSvn18() )
{
System.out.println( "Not Subversion 1.8 compatible. Skip test" );
return;
}
File projDir = resources.getBasedir( "basic-it-svnjava" );
MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File testDir = result.getBasedir();
FileUtils.copyDirectory( new File( testDir, "DotSvnDir" ), new File( testDir, ".svn" ) );
result = mavenExec.execute( "clean", "verify" );
result.assertLogText( "Storing buildNumber: 19665" );
result.assertLogText( "Storing buildScmBranch: trunk" );
File artifact = new File( testDir, "target/buildnumber-maven-plugin-basic-it-svnjava-1.0-SNAPSHOT.jar" );
JarFile jarFile = new JarFile( artifact );
Attributes manifest = jarFile.getManifest().getMainAttributes();
jarFile.close();
String scmRev = manifest.getValue( "SCM-Revision" );
Assert.assertEquals( "19665", scmRev );
}