本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.copyDirectoryStructure方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyDirectoryStructure方法的具体用法?Java FileUtils.copyDirectoryStructure怎么用?Java FileUtils.copyDirectoryStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.copyDirectoryStructure方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void initialize()
throws MojoExecutionException
{
outputDirectory.mkdirs();
workDirectory.mkdirs();
try
{
FileUtils.copyDirectoryStructure( schemaDirectory, workDirectory );
importDirectories.add( capnpJavaSchemaFile.getParentFile() );
importDirectories.add( schemaDirectory );
setBase();
}
catch ( IOException e )
{
throw new MojoExecutionException( "Unable to initialize capnp environment.", e );
}
}
示例2: copyDirectoryStructure
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void copyDirectoryStructure( File sourceDirectory, File targetDirectory )
throws MojoExecutionException
{
makeDirectoryIfNecessary( targetDirectory );
// hopefully available from FileUtils 1.0.5-SNAPSHOT
try
{
FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
}
catch ( IOException e )
{
throw new MojoExecutionException(
"Could not copy directory structure from " + sourceDirectory + " to " + targetDirectory, e );
}
}
示例3: copyDirectory
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Copies all the contents from the directory given by the source path to the directory given by the
* target path
*
* <p>
* If source directory does not exist nothing is performed. The target directory will be created if it
* does not exist. Any hidden directories (directory names that start with ".") will be deleted from the
* target directory
* </p>
*
* @param sourceDirectoryPath absolute path to the source directory
* @param targetDirectoryPath absolute path to the target directory
* @throws IOException
*/
public static void copyDirectory(String sourceDirectoryPath, String targetDirectoryPath)
throws IOException {
File sourceDir = new File(sourceDirectoryPath);
if (!sourceDir.exists()) {
return;
}
File targetDir = new File(targetDirectoryPath);
if (targetDir.exists()) {
// force removal so the copy starts clean
FileUtils.forceDelete(targetDir);
}
targetDir.mkdir();
FileUtils.copyDirectoryStructure(sourceDir, targetDir);
// remove hidden directories from the target
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(targetDir);
scanner.scan();
for (String includedDirectory : scanner.getIncludedDirectories()) {
File subdirectory = new File(targetDir, includedDirectory);
if (subdirectory.exists() && subdirectory.isDirectory()) {
if (subdirectory.getName().startsWith(".")) {
FileUtils.forceDelete(subdirectory);
}
}
}
}
示例4: testMojo
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testMojo() throws Exception {
FileUtils.copyDirectoryStructure(new File("src/test/resources/sample-pmd"), new File("target/unit/sample-pmd"));
File pom = getTestFile("target/unit/sample-pmd/pom.xml");
assertNotNull(pom);
assertTrue(pom.exists());
PmdPreSite myMojo = (PmdPreSite) lookupMojo("pmd-pre-site", pom);
assertNotNull(myMojo);
myMojo.execute();
String codeSizeRuleset = IOUtils
.toString(new File("target/unit/sample-pmd/target/generated-xdocs/rules/java/codesize.md").toURI());
assertTrue(codeSizeRuleset.contains("minimum"));
String basicRuleset = IOUtils
.toString(new File("target/unit/sample-pmd/target/generated-xdocs/rules/java/basic.md").toURI());
assertEquals(3, StringUtils.countMatches(basicRuleset, "## "));
String indexPage = IOUtils
.toString(new File("target/unit/sample-pmd/target/generated-xdocs/rules/index.md").toURI());
assertFalse(indexPage.contains("<li>: </li>"));
String site = IOUtils.toString(new File("target/unit/sample-pmd/src/site/site.xml").toURI());
assertTrue(site.contains("<item name=\"Basic\""));
assertTrue(site.contains("<item name=\"Code Size\""));
assertTrue(site.indexOf("<item name=\"Basic\"") < site.indexOf("<item name=\"Code Size\""));
}
示例5: setUp
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
resourcesDir = new File(getBaseDir(), "src/test/resources/unit/java-processor-test");
testDir = temporaryFolder.newFolder();
dictionaryFile = new File(testDir, "dictionaries/env01.dict");
FileUtils.mkdir(new File(testDir, "conf.d").getAbsolutePath());
FileUtils.copyDirectoryStructure(resourcesDir, testDir);
}
示例6: setUp
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
resourcesDir = new File(getBaseDir(), "src/test/resources/unit/java-processor-test");
testDir = temporaryFolder.newFolder();
dictionaryFile = new File(testDir, "dictionaries/env01.dict");
FileUtils.mkdir(new File(testDir, "conf.d").getAbsolutePath());
FileUtils.copyDirectoryStructure(resourcesDir, testDir);
}
示例7: addContent
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Copies the contents from the specified directory to the working directory.
*
* @param dir to copy content from
* @throws MojoExecutionException if the content directory is not found or the files cannot be copied
*/
public void addContent(File dir) throws MojoExecutionException {
if (!dir.exists())
throw new MojoExecutionException("No resources found at : " + dir.getAbsolutePath());
log.info("Copying content from \"" + dir.getPath() + "\" to \"" + contentDir.getPath() + "\"");
try {
FileUtils.copyDirectoryStructure(dir, contentDir);
} catch (IOException e) {
throw new MojoExecutionException("Could not copy resources to repository");
}
}
示例8: setUp
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Before
@Override
public void setUp()
throws Exception
{
super.setUp();
File sourceRepoDir = new File( "./src/test/repositories/default-repository" );
repoDir = new File( "./target/default-repository" );
FileUtils.deleteDirectory( repoDir );
assertFalse( "Default Test Repository should not exist.", repoDir.exists() );
repoDir.mkdir();
FileUtils.copyDirectoryStructure( sourceRepoDir, repoDir );
// set the timestamps to a time well in the past
Calendar cal = Calendar.getInstance();
cal.add( Calendar.YEAR, -1 );
for ( File f : (List<File>) FileUtils.getFiles( repoDir, "**", null ) )
{
f.setLastModified( cal.getTimeInMillis() );
}
// TODO: test they are excluded instead
for ( String dir : (List<String>) FileUtils.getDirectoryNames( repoDir, "**/.svn", null, false ) )
{
FileUtils.deleteDirectory( new File( repoDir, dir ) );
}
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
assertNotNull( archivaConfig );
// Create it
ManagedRepositoryConfiguration repositoryConfiguration = new ManagedRepositoryConfiguration();
repositoryConfiguration.setId( TEST_REPO_ID );
repositoryConfiguration.setName( "Test Repository" );
repositoryConfiguration.setLocation( repoDir.getAbsolutePath() );
archivaConfig.getConfiguration().getManagedRepositories().clear();
archivaConfig.getConfiguration().addManagedRepository( repositoryConfiguration );
metadataRepository = mock( MetadataRepository.class );
factory.setRepository( metadataRepository );
}
开发者ID:ruikom,项目名称:apache-archiva,代码行数:46,代码来源:ArchivaRepositoryScanningTaskExecutorAbstractTest.java
示例9: testExecutorScanOnlyNewArtifacts
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testExecutorScanOnlyNewArtifacts()
throws Exception
{
RepositoryTask repoTask = new RepositoryTask();
repoTask.setRepositoryId( TEST_REPO_ID );
repoTask.setScanAll( false );
createAndSaveTestStats();
taskExecutor.executeTask( repoTask );
// check no artifacts processed
Collection<ArtifactReference> unprocessedResultList = testConsumer.getConsumed();
assertNotNull( unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected. No new artifacts should have been found.", 0,
unprocessedResultList.size() );
// check correctness of new stats
RepositoryStatistics newStats =
repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
assertEquals( 0, newStats.getNewFileCount() );
assertEquals( 31, newStats.getTotalFileCount() );
// FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
// assertEquals( 8, newStats.getTotalArtifactCount() );
// assertEquals( 3, newStats.getTotalGroupCount() );
// assertEquals( 5, newStats.getTotalProjectCount() );
// assertEquals( 14159, newStats.getTotalArtifactFileSize() );
File newArtifactGroup = new File( repoDir, "org/apache/archiva" );
assertFalse( "newArtifactGroup should not exist.", newArtifactGroup.exists() );
FileUtils.copyDirectoryStructure( new File( "target/test-classes/test-repo/org/apache/archiva" ),
newArtifactGroup );
// update last modified date
new File( newArtifactGroup, "archiva-index-methods-jar-test/1.0/pom.xml" ).setLastModified(
Calendar.getInstance().getTimeInMillis() + 1000 );
new File( newArtifactGroup,
"archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ).setLastModified(
Calendar.getInstance().getTimeInMillis() + 1000 );
assertTrue( newArtifactGroup.exists() );
taskExecutor.executeTask( repoTask );
unprocessedResultList = testConsumer.getConsumed();
assertNotNull( unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
unprocessedResultList.size() );
// check correctness of new stats
RepositoryStatistics updatedStats =
repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
assertEquals( 2, updatedStats.getNewFileCount() );
assertEquals( 33, updatedStats.getTotalFileCount() );
// FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
// assertEquals( 8, newStats.getTotalArtifactCount() );
// assertEquals( 3, newStats.getTotalGroupCount() );
// assertEquals( 5, newStats.getTotalProjectCount() );
// assertEquals( 19301, updatedStats.getTotalArtifactFileSize() );
}
示例10: testExecutorScanOnlyNewArtifactsChangeTimes
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testExecutorScanOnlyNewArtifactsChangeTimes()
throws Exception
{
RepositoryTask repoTask = new RepositoryTask();
repoTask.setRepositoryId( TEST_REPO_ID );
repoTask.setScanAll( false );
createAndSaveTestStats();
File newArtifactGroup = new File( repoDir, "org/apache/archiva" );
assertFalse( "newArtifactGroup should not exist.", newArtifactGroup.exists() );
FileUtils.copyDirectoryStructure( new File( "target/test-classes/test-repo/org/apache/archiva" ),
newArtifactGroup );
// update last modified date, placing shortly after last scan
new File( newArtifactGroup, "archiva-index-methods-jar-test/1.0/pom.xml" ).setLastModified(
Calendar.getInstance().getTimeInMillis() + 1000 );
new File( newArtifactGroup,
"archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ).setLastModified(
Calendar.getInstance().getTimeInMillis() + 1000 );
assertTrue( newArtifactGroup.exists() );
// scan using the really long previous duration
taskExecutor.executeTask( repoTask );
// check no artifacts processed
Collection<ArtifactReference> unprocessedResultList = testConsumer.getConsumed();
assertNotNull( unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
unprocessedResultList.size() );
// check correctness of new stats
RepositoryStatistics newStats =
repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
assertEquals( 2, newStats.getNewFileCount() );
assertEquals( 33, newStats.getTotalFileCount() );
// FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
// assertEquals( 8, newStats.getTotalArtifactCount() );
// assertEquals( 3, newStats.getTotalGroupCount() );
// assertEquals( 5, newStats.getTotalProjectCount() );
// assertEquals( 19301, newStats.getTotalArtifactFileSize() );
}
示例11: testExecutorScanOnlyNewArtifactsMidScan
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testExecutorScanOnlyNewArtifactsMidScan()
throws Exception
{
RepositoryTask repoTask = new RepositoryTask();
repoTask.setRepositoryId( TEST_REPO_ID );
repoTask.setScanAll( false );
createAndSaveTestStats();
File newArtifactGroup = new File( repoDir, "org/apache/archiva" );
assertFalse( "newArtifactGroup should not exist.", newArtifactGroup.exists() );
FileUtils.copyDirectoryStructure( new File( "target/test-classes/test-repo/org/apache/archiva" ),
newArtifactGroup );
// update last modified date, placing in middle of last scan
new File( newArtifactGroup, "archiva-index-methods-jar-test/1.0/pom.xml" ).setLastModified(
Calendar.getInstance().getTimeInMillis() - 50000 );
new File( newArtifactGroup,
"archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" ).setLastModified(
Calendar.getInstance().getTimeInMillis() - 50000 );
assertTrue( newArtifactGroup.exists() );
// scan using the really long previous duration
taskExecutor.executeTask( repoTask );
// check no artifacts processed
Collection<ArtifactReference> unprocessedResultList = testConsumer.getConsumed();
assertNotNull( unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1,
unprocessedResultList.size() );
// check correctness of new stats
RepositoryStatistics newStats =
repositoryStatisticsManager.getLastStatistics( metadataRepository, TEST_REPO_ID );
assertEquals( 2, newStats.getNewFileCount() );
assertEquals( 33, newStats.getTotalFileCount() );
// FIXME: can't test these as they weren't stored in the database, move to tests for RepositoryStatisticsManager implementation
// assertEquals( 8, newStats.getTotalArtifactCount() );
// assertEquals( 3, newStats.getTotalGroupCount() );
// assertEquals( 5, newStats.getTotalProjectCount() );
// assertEquals( 19301, newStats.getTotalArtifactFileSize() );
}
示例12: setUp
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
FileUtils.deleteDirectory(testDir);
FileUtils.copyDirectoryStructure(new File("src/test/resources/sample-pmd"), testDir);
}
示例13: nolimitedResult
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void nolimitedResult()
throws Exception
{
File repo = new File( "target/repo-release" );
File indexDirectory = new File( repo, ".index" );
FileUtils.copyDirectoryStructure( new File( "src/test/repo-release" ), repo );
createIndex( "repo-release", Collections.<File>emptyList(), false );
nexusIndexer.addIndexingContext( REPO_RELEASE, REPO_RELEASE, repo, indexDirectory,
repo.toURI().toURL().toExternalForm(),
indexDirectory.toURI().toURL().toString(), search.getAllIndexCreators() );
SearchResultLimits limits = new SearchResultLimits( SearchResultLimits.ALL_PAGES );
limits.setPageSize( 300 );
EasyMock.expect( archivaConfig.getConfiguration() ).andReturn( config ).times( 1, 5 );
archivaConfigControl.replay();
SearchResults searchResults = search.search( null, Arrays.asList( REPO_RELEASE ), "org.example", limits,
Collections.<String>emptyList() );
log.info( "results: {}", searchResults.getHits().size() );
assertEquals( 255, searchResults.getHits().size() );
SearchFields searchFields = new SearchFields();
searchFields.setGroupId( "org.example" );
searchFields.setRepositories( Arrays.asList( REPO_RELEASE ) );
searchResults = search.search( null, searchFields, limits );
log.info( "results: {}", searchResults.getHits().size() );
assertEquals( 255, searchResults.getHits().size() );
archivaConfigControl.verify();
}