List of usage examples for org.apache.commons.io FileUtils copyDirectory
public static void copyDirectory(File srcDir, File destDir) throws IOException
From source file:com.flipkart.flux.examples.WorkflowExecutionDemo.java
/** * Does necessary actions to run an example/user's workflow. * @param moduleName name of user module in which workflow code is present * @param workflowClassFQN fully qualified name of main class which triggers user workflow execution at client side. * @see com.flipkart.flux.examples.concurrent.RunEmailMarketingWorkflow for example. * @param configFileName "flux_config.yml" which contains workflow related configuration. * @see flux/examples/src/main/resources/flux_config.yml for example. * @throws Exception/* ww w. ja v a2 s . co m*/ */ private static void runExample(String moduleName, String workflowClassFQN, String configFileName, String mavenPath) throws Exception { //copy dependencies to module's target directory executeCommand(mavenPath + " -pl " + moduleName + " -q package dependency:copy-dependencies -DincludeScope=runtime -DskipTests"); //get deployment path from configuration.yml FileReader reader = new FileReader( WorkflowExecutionDemo.class.getResource("/packaged/configuration.yml").getFile()); String deploymentUnitsPath = (String) ((Map) new Yaml().load(reader)).get("deploymentUnitsPath"); if (!deploymentUnitsPath.endsWith("/")) { deploymentUnitsPath = deploymentUnitsPath + "/"; } reader.close(); //create deployment structure String deploymentUnitName = "DU1/1"; String mainDirPath = deploymentUnitsPath + deploymentUnitName + "/main"; String libDirPath = deploymentUnitsPath + deploymentUnitName + "/lib"; executeCommand("mkdir -p " + mainDirPath); executeCommand("mkdir -p " + libDirPath); //copy dependencies to deployment unit FileUtils.copyFile( new File(moduleName + "/target/") .listFiles((FilenameFilter) new WildcardFileFilter(moduleName + "*.jar"))[0], new File(mainDirPath + "/" + moduleName + ".jar")); FileUtils.copyDirectory(new File(moduleName + "/target/dependency"), new File(libDirPath)); FileUtils.copyFile(new File(moduleName + "/src/main/resources/" + configFileName), new File(deploymentUnitsPath + deploymentUnitName + "/flux_config.yml")); //start flux runtime FluxInitializer.main(new String[] {}); //Invoke workflow in separate process, the below system out prints this process's output in blue color System.out.println((char) 27 + "[34m" + executeCommand( "java -cp " + moduleName + "/target/*:" + moduleName + "/target/dependency/* " + workflowClassFQN) + (char) 27 + "[0m"); }
From source file:com.goodformobile.build.mobile.AbstractRIMMojoTest.java
protected File setupCleanCopyOfProject(File projectDirectory) throws IOException { File workProjectDirectory = new File(getBasedir(), "target/temp/project"); if (workProjectDirectory.exists()) { FileUtils.cleanDirectory(workProjectDirectory); }/*w w w .j ava 2s . com*/ FileUtils.copyDirectory(projectDirectory, workProjectDirectory); return workProjectDirectory; }
From source file:com.blackducksoftware.integration.hub.detect.workflow.diagnostic.RelevantFileTracker.java
private boolean registerRelevantFile(final File file, final String directoryName) { try {/*from ww w. j a v a 2 s .c o m*/ if (file == null) { return false; } if (isChildOfTrackedFolder(file)) { logger.debug("Asked to track file '" + file.getPath() + "' but it is already being tracked."); return false; } if (file.isFile()) { final File dest = findNextAvailableRelevant(directoryName, file.getName()); FileUtils.copyFile(file, dest); } else if (file.isDirectory()) { final File dest = findNextAvailableRelevant(directoryName, file.getName()); FileUtils.copyDirectory(file, dest); } return true; } catch (final Exception e) { logger.trace("Failed to copy file to relevant directory:" + file.toString()); return false; } }
From source file:de.brendamour.jpasskit.signing.PKSigningUtil.java
public static byte[] createSignedAndZippedPkPassArchive(final PKPass pass, final String pathToTemplateDirectory, final PKSigningInformation signingInformation) throws Exception { File tempPassDir = Files.createTempDir(); FileUtils.copyDirectory(new File(pathToTemplateDirectory), tempPassDir); ObjectMapper jsonObjectMapper = new ObjectMapper(); jsonObjectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); jsonObjectMapper.setDateFormat(new ISO8601DateFormat()); createPassJSONFile(pass, tempPassDir, jsonObjectMapper); File manifestJSONFile = createManifestJSONFile(tempPassDir, jsonObjectMapper); signManifestFile(tempPassDir, manifestJSONFile, signingInformation); byte[] zippedPass = createZippedPassAndReturnAsByteArray(tempPassDir); FileUtils.deleteDirectory(tempPassDir); return zippedPass; }
From source file:com.diffplug.gradle.GradleIntegrationTest.java
/** Copies the test to some directory for external debugging. */ protected void copyTo(String path) throws IOException { File destination = new File(path); FileUtils.copyDirectory(folder.getRoot(), destination); }
From source file:com.coprtools.util.SourceManipulator.java
/** * Copy a folder with all subfolders and files into another folder. * * @param sourceFolder// ww w .j a v a 2s .c o m * - the source folder * @param destinationFolder * - the destination folder * @throws IOException */ @Override public void copyFolder(File sourceFolder, File destinationFolder) throws IOException { FileUtils.copyDirectory(sourceFolder, destinationFolder); }
From source file:de.ingrid.interfaces.csw.domain.OperationTestBase.java
@Override @Before// w w w . ja v a 2s .c o m public void setUp() throws Exception { // setup searcher FileUtils.deleteDirectory(new File(LIVE_INDEX_PATH)); FileUtils.copyDirectory(new File("src/test/resources/index"), new File(LIVE_INDEX_PATH)); FileUtils.deleteDirectory(new File(CSW_CACHE_PATH)); FileUtils.copyDirectory(new File("src/test/resources/cache"), new File(CSW_CACHE_PATH)); CSWRecordCache cache = new CSWRecordCache(); cache.setCachePath(new File(CSW_CACHE_PATH)); this.searcher = new LuceneSearcher(); this.searcher.setIndexPath(new File(LIVE_INDEX_PATH)); this.searcher.setFilterParser(new LuceneFilterParser()); this.searcher.setRecordRepository(cache); this.searcher.setLuceneTools(new LuceneTools()); this.searcher.start(); this.manager = new TestManager(); // create servlet GenericServer server = new GenericServer(); server.setSearcher(this.searcher); server.setManager(manager); ServerFacade serverFacade = new ServerFacade(); serverFacade.setCswServerImpl(server); this.servlet = new CSWServlet(); this.servlet.setServerFacade(serverFacade); // create cswt servlet GenericServerCSWT serverCSWT = new GenericServerCSWT(); serverCSWT.setSearcher(this.searcher); serverCSWT.setManager(manager); ServerFacadeCSWT serverFacadeCSWT = new ServerFacadeCSWT(); serverFacadeCSWT.setCswServerImpl(serverCSWT); this.servletCSWT = new CSWTServlet(); this.servletCSWT.setServerFacade(serverFacadeCSWT); }
From source file:com.vmware.photon.controller.deployer.configuration.ServiceConfigurator.java
public void copyDirectory(String srcDir, String destDir) throws IOException { FileUtils.copyDirectory(new File(srcDir), new File(destDir)); }
From source file:jp.co.tis.gsp.tools.dba.dialect.Dialect.java
protected void exportSchemaGeneral(ExportParams params) throws MojoExecutionException { // CSV// ww w.j a v a 2s .c o m try { File dataDir = new File(params.getOutputDirectory(), DATA_DIR_NAME); FileUtils.forceMkdir(dataDir); CsvExporter exporter = new CsvExporter(url, driver, params.getSchema(), params.getAdminUser(), params.getAdminPassword(), dataDir, UTF8); exporter.execute(); } catch (Exception e1) { throw new MojoExecutionException("CSV???????:", e1); } // DDL & extraDDL?? try { File ddlDir = params.getDdlDirectory(); File extraDdlDir = params.getExtraDdlDirectory(); // ???? ddlDirectory??? if (ddlDir != null && ddlDir.exists()) { FileUtils.copyDirectory(params.getDdlDirectory(), new File(params.getOutputDirectory(), DDL_DIR_NAME)); } else { throw new MojoExecutionException("DDL???????"); } // ???? if (extraDdlDir != null) { if (!extraDdlDir.exists()) throw new MojoExecutionException("extraDDL???????"); FileUtils.copyDirectory(params.getExtraDdlDirectory(), new File(params.getOutputDirectory(), EXTRADDL_DIR_NAME)); } } catch (IOException e) { throw new MojoExecutionException("DDL???????:", e); } }
From source file:com.jayway.maven.plugins.android.standalonemojos.UnpackMojo.java
private File unpackClasses() throws MojoExecutionException { File outputDirectory = new File(targetDirectory, "android-classes"); if (lazyLibraryUnpack && outputDirectory.exists()) { getLog().info("skip library unpacking due to lazyLibraryUnpack policy"); } else {/*from w w w.j a v a2s. c o m*/ outputDirectory.mkdirs(); for (Artifact artifact : getRelevantCompileArtifacts()) { if (artifact.getFile().isDirectory()) { try { FileUtils.copyDirectory(artifact.getFile(), outputDirectory); } catch (IOException e) { throw new MojoExecutionException( "IOException while copying " + artifact.getFile().getAbsolutePath() + " into " + outputDirectory.getAbsolutePath(), e); } } else { try { JarHelper.unjar(new JarFile(artifact.getFile()), outputDirectory, new JarHelper.UnjarListener() { @Override public boolean include(JarEntry jarEntry) { return isIncluded(jarEntry); } }); } catch (IOException e) { throw new MojoExecutionException( "IOException while unjarring " + artifact.getFile().getAbsolutePath() + " into " + outputDirectory.getAbsolutePath(), e); } } } } try { FileUtils.copyDirectory(projectOutputDirectory, outputDirectory); } catch (IOException e) { throw new MojoExecutionException("IOException while copying " + sourceDirectory.getAbsolutePath() + " into " + outputDirectory.getAbsolutePath(), e); } return outputDirectory; }