Java Code Examples for io.fabric8.utils.Files#recursiveDelete()
The following examples show how to use
io.fabric8.utils.Files#recursiveDelete() .
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: SpringBootFabric8SetupTest.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected void removeSnapshotFabric8Artifacts() { File fabric8Folder = new File(localMavenRepo, "io/fabric8"); if (Files.isDirectory(fabric8Folder)) { File[] artifactFolders = fabric8Folder.listFiles(); if (artifactFolders != null) { for (File artifactFolder : artifactFolders) { File[] versionFolders = artifactFolder.listFiles(); if (versionFolders != null) { for (File versionFolder : versionFolders) { if (versionFolder.getName().toUpperCase().endsWith("-SNAPSHOT")) { LOG.info("Removing snapshot version from local maven repo: " + versionFolder); Files.recursiveDelete(versionFolder); } } } } } } }
Example 2
Source File: PopulateMavenRepositoryTest.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected void removeSnapshotFabric8Artifacts() { File fabric8Folder = new File(localMavenRepo, "io/fabric8"); if (Files.isDirectory(fabric8Folder)) { File[] artifactFolders = fabric8Folder.listFiles(); if (artifactFolders != null) { for (File artifactFolder : artifactFolders) { File[] versionFolders = artifactFolder.listFiles(); if (versionFolders != null) { for (File versionFolder : versionFolders) { if (versionFolder.getName().toUpperCase().endsWith("-SNAPSHOT")) { LOG.info("Removing snapshot version from local maven repo: " + versionFolder); Files.recursiveDelete(versionFolder); } } } } } } }
Example 3
Source File: ForgeClientAsserts.java From fabric8-forge with Apache License 2.0 | 6 votes |
/** * Asserts that we can git clone the given repository */ public static Git assertGitCloneRepo(String cloneUrl, File outputFolder) throws GitAPIException, IOException { LOG.info("Cloning git repo: " + cloneUrl + " to folder: " + outputFolder); Files.recursiveDelete(outputFolder); outputFolder.mkdirs(); CloneCommand command = Git.cloneRepository(); command = command.setCloneAllBranches(false).setURI(cloneUrl).setDirectory(outputFolder).setRemote("origin"); Git git; try { git = command.call(); } catch (Exception e) { LOG.error("Failed to git clone remote repo " + cloneUrl + " due: " + e.getMessage(), e); throw e; } return git; }
Example 4
Source File: RepositoryResource.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected CommitInfo doRemove(Git git, List<String> paths) throws Exception { if (paths != null && paths.size() > 0) { int count = 0; for (String path : paths) { File file = getRelativeFile(path); if (file.exists()) { count++; Files.recursiveDelete(file); String filePattern = getFilePattern(path); git.rm().addFilepattern(filePattern).call(); } } if (count > 0) { CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message); return createCommitInfo(commitThenPush(git, commit)); } } return null; }
Example 5
Source File: GitCloneWithTagExample.java From fabric8-forge with Apache License 2.0 | 6 votes |
public static void main(String[] args) { if (args.length < 2) { System.out.println("Arguments: gitUrl gitTag"); return; } String cloneUrl = args[0]; String tag = args[1]; File projectFolder = new File("target/myproject"); if (projectFolder.exists()) { Files.recursiveDelete(projectFolder); } String remote = "origin"; ProjectFileSystem.cloneRepo(projectFolder, cloneUrl, null, null, null, remote, tag); }
Example 6
Source File: SshGitCloneExample.java From fabric8-forge with Apache License 2.0 | 6 votes |
public static void main(String[] args) { if (args.length < 3) { System.out.println("Arguments: gitUrl privateKeyFile publicKeyFile"); return; } String cloneUrl = args[0]; String privateKeyPath = args[1]; String publicKeyPath = args[2]; File projectFolder = new File("target/myproject"); if (projectFolder.exists()) { Files.recursiveDelete(projectFolder); } File sshPrivateKey = new File(privateKeyPath); File sshPublicKey = new File(publicKeyPath); String remote = "origin"; assertThat(sshPrivateKey).exists(); assertThat(sshPublicKey).exists(); ProjectFileSystem.cloneRepo(projectFolder, cloneUrl, null, sshPrivateKey, sshPublicKey, remote); }
Example 7
Source File: Tests.java From updatebot with Apache License 2.0 | 5 votes |
/** * Copies the source test data files into a test data area so we can test on the files and modify them * * @return the directory of test files */ public static File copyPackageSources(Class<?> clazz) { String packagePath = getPackagePath(clazz); File basedir = Tests.getBasedir(); File testDir = getTestDataDir(clazz); File srcDir = new File(basedir, "src/test/resources/" + packagePath); assertThat(srcDir).describedAs("Source test files for test " + clazz.getName()).isDirectory(); if (testDir.exists()) { Files.recursiveDelete(testDir); } assertThat(testDir).describedAs("Test data dir").doesNotExist(); testDir.mkdirs(); try { Files.copy(srcDir, testDir); } catch (IOException e) { fail("Failed to copy " + srcDir + " to " + testDir + ". " + e, e); } assertThat(testDir).describedAs("Test data dir").isDirectory(); File[] childFiles = testDir.listFiles(); assertThat(childFiles).describedAs("Test data dir " + testDir).isNotEmpty(); return testDir; }
Example 8
Source File: Tests.java From updatebot with Apache License 2.0 | 5 votes |
public static String getCleanWorkDir(Class<?> clazz) { File testDataDir = getTestDataDir(clazz); System.out.println("Using workDir: " + testDataDir); String property = System.getProperty("updatebot.preserve.testdir", "false"); if (property.equals("true")) { LOG.info("Preserving contents of " + testDataDir + " to speed up test"); } else { Files.recursiveDelete(testDataDir); } return testDataDir.getPath(); }
Example 9
Source File: SpringBootFabric8SetupTest.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected void createNewProject(Furnace furnace) throws Exception { File projectsOutputFolder = new File(baseDir, "target/createdProjects"); Files.recursiveDelete(projectsOutputFolder); ProjectGenerator generator = new ProjectGenerator(furnace, projectsOutputFolder, localMavenRepo); generator.createNewSpringBootProject(); removeSnapshotFabric8Artifacts(); }
Example 10
Source File: PopulateMavenRepositoryTest.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected void createProjects(Furnace furnace) throws Exception { File projectsOutputFolder = new File(baseDir, "target/createdProjects"); Files.recursiveDelete(projectsOutputFolder); ProjectGenerator generator = new ProjectGenerator(furnace, projectsOutputFolder, localMavenRepo); File archetypeJar = generator.getArtifactJar("io.fabric8.archetypes", "archetypes-catalog", ProjectGenerator.FABRIC8_ARCHETYPE_VERSION); List<String> archetypes = getArchetypesFromJar(archetypeJar); assertThat(archetypes).describedAs("Archetypes to create").isNotEmpty(); String testArchetype = System.getProperty(TEST_ARCHETYPE_SYSTEM_PROPERTY, ""); if (Strings.isNotBlank(testArchetype)) { LOG.info("Due to system property: '" + TEST_ARCHETYPE_SYSTEM_PROPERTY + "' we will just run the test on archetype: " + testArchetype); generator.createProjectFromArchetype(testArchetype); } else { for (String archetype : archetypes) { // TODO fix failing archetypes... if (!archetype.startsWith("jboss-fuse-") && !archetype.startsWith("swarm")) { generator.createProjectFromArchetype(archetype); } } } removeSnapshotFabric8Artifacts(); List<File> failedFolders = generator.getFailedFolders(); if (failedFolders.size() > 0) { LOG.error("Failed to build all the projects!!!"); for (File failedFolder : failedFolders) { LOG.error("Failed to build project: " + failedFolder.getName()); } } }
Example 11
Source File: RepositoryResource.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected CommitInfo doRemove(Git git, String path) throws Exception { File file = getRelativeFile(path); if (file.exists()) { Files.recursiveDelete(file); String filePattern = getFilePattern(path); git.rm().addFilepattern(filePattern).call(); CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message); return createCommitInfo(commitThenPush(git, commit)); } else { return null; } }
Example 12
Source File: NewNodeXmlTest.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Test public void testCreateXmlNode() throws Exception { File basedir = getBaseDir(); String projectName = "example-camel-spring"; File projectDir = new File(basedir, "target/test-projects/" + projectName); File projectSourceDir = new File(basedir, "src/itests/" + projectName); Files.recursiveDelete(projectDir); io.fabric8.forge.addon.utils.Files.copy(projectSourceDir, projectDir); System.out.println("Copied project to " + projectDir); Resource<?> resource = resourceFactory.create(projectDir); assertNotNull("Should have found a resource", resource); Project project = projectFactory.findProject(resource); assertNotNull("Should have found a project", project); List<ContextDto> contexts = getRoutesXml(project); assertFalse("Should have loaded a camelContext", contexts.isEmpty()); // lets add a new route testAddRoute(project); // add endpoint to the route testAddEndpoint(project); // and then delete the route testDeleteRoute(project); }
Example 13
Source File: ArchetypeTest.java From ipaas-quickstarts with Apache License 2.0 | 5 votes |
@Test public void testGenerateQuickstartArchetypes() { try { Files.recursiveDelete(projectsOutputFolder); List<String> archetypes = getArchetypesFromJar(); assertThat(archetypes).describedAs("Archetypes to create").isNotEmpty(); String testArchetype = System.getProperty(TEST_ARCHETYPE_SYSTEM_PROPERTY, ""); if (Strings.isNotBlank(testArchetype)) { LOG.info("Due to system property: '" + TEST_ARCHETYPE_SYSTEM_PROPERTY + "' we will just run the test on archetype: " + testArchetype); assertArchetypeCreated(testArchetype); } else { LOG.info("Generating archetypes: " + archetypes); for (String archetype : archetypes) { if (ignoreArchetype(archetype)) { LOG.warn("Ignoring archetype: " + archetype); } else { assertArchetypeCreated(archetype); } } } removeSnapshotFabric8Artifacts(); } catch (Exception e) { fail("Failed to create archetypes: " + e, e); failed = true; } }