List of usage examples for org.apache.commons.io FileUtils copyFileToDirectory
public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws IOException
From source file:de.jwi.jfm.Folder.java
private String pasteClipboard(HttpSession session) throws OutOfSyncException, IOException { ClipBoardContent clipBoardContent = (ClipBoardContent) session.getAttribute("clipBoardContent"); if (clipBoardContent == null) { return "nothing in clipboard"; }//from w w w. j a v a2s .c o m for (int i = 0; i < clipBoardContent.selectedfiles.length; i++) { File f = clipBoardContent.selectedfiles[i]; File f1 = f.getParentFile(); if (myFile.getCanonicalFile().equals(f1.getCanonicalFile())) { return "same folder"; } } for (int i = 0; i < clipBoardContent.selectedfiles.length; i++) { File f = clipBoardContent.selectedfiles[i]; if (clipBoardContent.contentType == ClipBoardContent.COPY_CONTENT) { if (f.isDirectory()) { FileUtils.copyDirectoryToDirectory(f, myFile); } else { FileUtils.copyFileToDirectory(f, myFile, true); } } if (clipBoardContent.contentType == ClipBoardContent.CUT_CONTENT) { if (f.isDirectory()) { FileUtils.moveDirectoryToDirectory(f, myFile, false); } else { FileUtils.moveFileToDirectory(f, myFile, false); } } if (clipBoardContent.contentType == ClipBoardContent.CUT_CONTENT) { session.removeAttribute("clipBoardContent"); } } return ""; }
From source file:ch.vorburger.webdriver.reporting.TestCaseReportWriter.java
public void infoWithFlagAndScreenshot(String message, File screenshot) { if (screenshot != null) { try {// w w w . j av a2 s . co m FileUtils.copyFileToDirectory(screenshot, screenshotsDirFile, true); } catch (IOException e) { throw new RuntimeException("Oups, WebDriver Report could't copy screenshot file?!", e); } message = message + "^" + screenshot.getName(); } infoWithFlag(message); }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Updater.java
private static void backupLog(String dirName, ArrayList<File> fileToBackup) { boolean result; File backupdir = new File(logBackupPath); setSeparator();/* w ww . j av a 2s . c om*/ if (!backupdir.exists()) { result = backupdir.mkdir(); if (result) System.out.println("DIR " + backupdir + " created"); else System.out.println("DIR " + backupdir + " not created"); } File logDir = new File(logBackupPath + SEPARATOR + dirName); if (!logDir.exists()) { result = logDir.mkdir(); if (result) System.out.println("DIR " + logDir + " created"); else System.out.println("DIR " + logDir + " not created"); } File dirToCopy = new File(logBackupPath + SEPARATOR + dirName); if (dirToCopy.exists()) { for (File file : fileToBackup) { try { if (file.exists()) FileUtils.copyFileToDirectory(file, dirToCopy, true); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
From source file:kr.co.leem.system.FileSystemUtils.java
/** * ? ./*from www . j a v a2 s. c om*/ * * @param srcFile ? ? . * @param destFile ? . * @param preserveFileDate . * @see FileUtils#copyFileToDirectory(File, File, boolean) */ public static void copyFileToDirectory(final String srcFile, final String destDir, final boolean preserveFileDate) { processIO(new IOCallback<Object>() { public Object doInProcessIO() throws IOException, NullPointerException { FileUtils.copyFileToDirectory(new File(srcFile), new File(destDir), preserveFileDate); return null; } }); }
From source file:com.taobao.android.TPatchTool.java
/** * ?patch/*from w w w . j a v a 2s.co m*/ * * @param outPatchDir ?patch * @param createPatchJson * @param outPatchJson * @param createHistoryPatch * @param patchHistoryUrl * @param productName * @return ?patch? */ public File doPatch(File outPatchDir, boolean createPatchJson, File outPatchJson, boolean createHistoryPatch, String patchHistoryUrl, String productName) throws Exception { isTpatch = true; pName = productName; final File diffTxtFile = new File(outPatchDir, "diff.json"); final File patchInfoFile = new File(outPatchDir, "patchInfo.json"); final File patchTmpDir = new File(outPatchDir, "tpatch-tmp"); File mainDiffFolder = new File(patchTmpDir, mainBundleName); // FileUtils.cleanDirectory(outPatchDir); patchTmpDir.mkdirs(); FileUtils.cleanDirectory(patchTmpDir); mainDiffFolder.mkdirs(); File lastPatchFile = null; lastPatchFile = getLastPatchFile(baseApkBO.getVersionName(), productName, outPatchDir); PatchUtils.getTpatchClassDef(lastPatchFile, bundleClassMap); // apk File unzipFolder = unzipApk(outPatchDir); final File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME); final File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME); // bundledex diff File mianDiffDestDex = new File(mainDiffFolder, DEX_NAME); File tmpDexFile = new File(patchTmpDir, mainBundleName + "-dex"); createBundleDexPatch(newApkUnzipFolder, baseApkUnzipFolder, mianDiffDestDex, tmpDexFile, true); // ??bundle? if (isRetainMainBundleRes()) { copyMainBundleResources(newApkUnzipFolder, baseApkUnzipFolder, new File(patchTmpDir, mainBundleName)); } ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(); String taskName = "diffBundleTask"; // bundlesoawb? Collection<File> soFiles = FileUtils.listFiles(newApkUnzipFolder, new String[] { "so" }, true); if (splitDiffBundle != null) { for (Pair<BundleBO, BundleBO> bundle : splitDiffBundle) { processBundleFiles(bundle.getSecond().getBundleFile(), bundle.getFirst().getBundleFile(), patchTmpDir); } } for (final File soFile : soFiles) { final String relativePath = PathUtils.toRelative(newApkUnzipFolder, soFile.getAbsolutePath()); if (null != notIncludeFiles && pathMatcher.match(notIncludeFiles, relativePath)) { continue; } executorServicesHelper.submitTask(taskName, new Callable<Boolean>() { @Override public Boolean call() throws Exception { File baseSoFile = new File(baseApkUnzipFolder, relativePath); if (PatchUtils.isBundleFile(soFile)) { // bundle processBundleFiles(soFile, baseSoFile, patchTmpDir); } else { File destFile = new File(patchTmpDir, mainBundleName + "/" + relativePath); if (isFileModify(soFile, baseSoFile)) { FileUtils.copyFile(soFile, destFile); } } return true; } }); } executorServicesHelper.waitTaskCompleted(taskName); executorServicesHelper.stop(); // patchtpatch File patchFile = createTPatchFile(outPatchDir, patchTmpDir); PatchInfo curPatchInfo = createBasePatchInfo(patchFile); BuildPatchInfos buildPatchInfos = new BuildPatchInfos(); // ?tpatch if (createHistoryPatch && patchHistoryUrl != null) { buildPatchInfos = createIncrementPatchFiles(productName, patchFile, outPatchDir, newApkUnzipFolder, curPatchInfo, patchHistoryUrl); } buildPatchInfos.getPatches().add(curPatchInfo); buildPatchInfos.setBaseVersion(baseApkBO.getVersionName()); buildPatchInfos.setDiffBundleDex(diffBundleDex); if (createPatchJson) { FileUtils.writeStringToFile(outPatchJson, JSON.toJSONString(buildPatchInfos)); } // FileUtils.deleteDirectory(patchTmpDir); apkDiff.setBaseApkVersion(baseApkBO.getVersionName()); apkDiff.setNewApkVersion(newApkBO.getVersionName()); apkDiff.setBundleDiffResults(bundleDiffResults); apkDiff.setNewApkMd5(MD5Util.getFileMD5String(newApkBO.getApkFile())); apkDiff.setFileName(newApkBO.getApkName()); apkPatchInfos.setBaseApkVersion(baseApkBO.getVersionName()); apkPatchInfos.setNewApkVersion(newApkBO.getVersionName()); apkPatchInfos.setBundleDiffResults(patchInfos); apkPatchInfos.setFileName(patchFile.getName()); apkPatchInfos.setNewApkMd5(MD5Util.getFileMD5String(patchFile)); FileUtils.writeStringToFile(diffTxtFile, JSON.toJSONString(apkDiff)); FileUtils.writeStringToFile(patchInfoFile, JSON.toJSONString(apkPatchInfos)); FileUtils.copyFileToDirectory(diffTxtFile, outPatchDir.getParentFile(), true); FileUtils.copyFileToDirectory(newApkBO.getApkFile(), outPatchDir.getParentFile(), true); // FileUtils.deleteDirectory(unzipFolder); return patchFile; }
From source file:it.feio.android.omninotes.async.DataBackupIntentService.java
/** * Import attachments from backup folder *//*w w w . j a va 2 s .c om*/ private boolean importAttachments(File backupDir) { File attachmentsDir = StorageHelper.getAttachmentDir(this); // Moving back File backupAttachmentsDir = new File(backupDir, attachmentsDir.getName()); if (!backupAttachmentsDir.exists()) return true; boolean result = true; Collection list = FileUtils.listFiles(backupAttachmentsDir, FileFilterUtils.trueFileFilter(), TrueFileFilter.INSTANCE); Iterator i = list.iterator(); int imported = 0; File file = null; while (i.hasNext()) { try { file = (File) i.next(); FileUtils.copyFileToDirectory(file, attachmentsDir, true); mNotificationsHelper.setMessage(TextHelper.capitalize(getString(R.string.attachment)) + " " + imported++ + "/" + list.size()).show(); } catch (IOException e) { result = false; Log.e(Constants.TAG, "Error importing the attachment " + file.getName()); } } return result; }
From source file:com.dycody.android.idealnote.async.DataBackupIntentService.java
/** * Import attachments from backup folder *//*from w w w . ja v a 2s .c om*/ private boolean importAttachments(File backupDir) { File attachmentsDir = StorageHelper.getAttachmentDir(this); // Moving back File backupAttachmentsDir = new File(backupDir, attachmentsDir.getName()); if (!backupAttachmentsDir.exists()) return true; boolean result = true; Collection list = FileUtils.listFiles(backupAttachmentsDir, FileFilterUtils.trueFileFilter(), TrueFileFilter.INSTANCE); Iterator i = list.iterator(); int imported = 0; File file = null; while (i.hasNext()) { try { file = (File) i.next(); FileUtils.copyFileToDirectory(file, attachmentsDir, true); mNotificationsHelper.setMessage( TextHelper.capitalize(getString(com.dycody.android.idealnote.R.string.attachment)) + " " + imported++ + "/" + list.size()) .show(); } catch (IOException e) { result = false; Log.e(Constants.TAG, "Error importing the attachment " + file.getName()); } } return result; }
From source file:com.ehsy.solr.util.SimplePostTool.java
/** * Opens the file and posts it's contents to the solrUrl, * writes to response to output. /*from w w w .j av a 2s .c o m*/ */ public void postFile(File file, OutputStream output, String type) { InputStream is = null; try { URL url = solrUrl; if (auto) { if (type == null) { type = guessType(file); } if (type != null) { if (type.equals("text/xml") || type.equals("text/csv") || type.equals("application/json")) { // Default handler } else { // SolrCell String urlStr = appendUrlPath(solrUrl, "/extract").toString(); if (urlStr.indexOf("resource.name") == -1) urlStr = appendParam(urlStr, "resource.name=" + URLEncoder.encode(file.getAbsolutePath(), "UTF-8")); if (urlStr.indexOf("literal.id") == -1) urlStr = appendParam(urlStr, "literal.id=" + URLEncoder.encode(file.getAbsolutePath(), "UTF-8")); url = new URL(urlStr); } } else { warn("Skipping " + file.getName() + ". Unsupported file type for auto mode."); return; } } else { if (type == null) type = DEFAULT_CONTENT_TYPE; } info("POSTing file " + file.getName() + (auto ? " (" + type + ")" : "")); is = new FileInputStream(file); postData(is, (int) file.length(), output, type, url); } catch (IOException e) { e.printStackTrace(); warn("Can't open/read file: " + file); } finally { try { if (is != null) is.close(); //move update file to ../backup added by niko 2014-10-16 if (file.exists() && file.canWrite()) { FileUtils.copyFileToDirectory(file, new File(file.getParentFile().getParent() + File.separator + "backup"), false); boolean del = file.delete(); info("delete file " + file.getName() + "\t" + del); } } catch (IOException e) { fatal("IOException while closing file: " + e); } } }
From source file:com.taobao.android.tools.TPatchTool.java
@Override public PatchFile doPatch() throws Exception { TpatchInput tpatchInput = (TpatchInput) input; TpatchFile tpatchFile = new TpatchFile(); File hisPatchJsonFile = new File(tpatchInput.outPutJson.getParentFile(), "patchs-" + input.newApkBo.getVersionName() + ".json"); hisTpatchFolder = new File( tpatchInput.outPatchDir.getParentFile().getParentFile().getParentFile().getParentFile(), "hisTpatch"); tpatchFile.diffJson = new File(((TpatchInput) input).outPatchDir, "diff.json"); tpatchFile.patchInfo = new File(((TpatchInput) input).outPatchDir, "patchInfo.json"); final File patchTmpDir = new File(((TpatchInput) input).outPatchDir, "tpatch-tmp"); final File mainDiffFolder = new File(patchTmpDir, ((TpatchInput) input).mainBundleName); patchTmpDir.mkdirs();/*from ww w. ja v a2 s. c o m*/ FileUtils.cleanDirectory(patchTmpDir); mainDiffFolder.mkdirs(); File lastPatchFile = null; readWhiteList(((TpatchInput) input).bundleWhiteList); lastPatchFile = getLastPatchFile(input.baseApkBo.getVersionName(), ((TpatchInput) input).productName, ((TpatchInput) input).outPatchDir); PatchUtils.getTpatchClassDef(lastPatchFile, bundleClassMap); Profiler.release(); Profiler.enter("unzip apks"); // unzip apk File unzipFolder = unzipApk(((TpatchInput) input).outPatchDir); final File newApkUnzipFolder = new File(unzipFolder, NEW_APK_UNZIP_NAME); final File baseApkUnzipFolder = new File(unzipFolder, BASE_APK_UNZIP_NAME); Profiler.release(); ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(); String taskName = "diffBundleTask"; // Collection<File> soFiles = FileUtils.listFiles(newApkUnzipFolder, new String[] { "so" }, true); //process remote bumdle if ((((TpatchInput) input).splitDiffBundle != null)) { for (final Pair<BundleBO, BundleBO> bundle : ((TpatchInput) input).splitDiffBundle) { if (bundle.getFirst() == null || bundle.getSecond() == null) { logger.warning("remote bundle is not set to splitDiffBundles"); continue; } executorServicesHelper.submitTask(taskName, new Callable<Boolean>() { @Override public Boolean call() throws Exception { TPatchTool.this.processBundleFiles(bundle.getSecond().getBundleFile(), bundle.getFirst().getBundleFile(), patchTmpDir); return true; } }); } } Profiler.enter("awbspatch"); Collection<File> retainFiles = FileUtils.listFiles(newApkUnzipFolder, new IOFileFilter() { @Override public boolean accept(File file) { String relativePath = PathUtils.toRelative(newApkUnzipFolder, file.getAbsolutePath()); if (pathMatcher.match(DEFAULT_NOT_INCLUDE_RESOURCES, relativePath)) { return false; } if (null != ((TpatchInput) (input)).notIncludeFiles && pathMatcher.match(((TpatchInput) (input)).notIncludeFiles, relativePath)) { return false; } return true; } @Override public boolean accept(File file, String s) { return accept(new File(file, s)); } }, TrueFileFilter.INSTANCE); executorServicesHelper.submitTask(taskName, new Callable<Boolean>() { @Override public Boolean call() throws Exception { // bundledex diff // File mianDiffDestDex = new File(mainDiffFolder, DEX_NAME); // File tmpDexFolder = new File(patchTmpDir, ((TpatchInput)input).mainBundleName + "-dex"); createBundleDexPatch(newApkUnzipFolder, baseApkUnzipFolder, mainDiffFolder, // tmpDexFolder, true); // ??bundle? if (isRetainMainBundleRes()) { copyMainBundleResources(newApkUnzipFolder, baseApkUnzipFolder, new File(patchTmpDir, ((TpatchInput) input).mainBundleName), retainFiles); } return true; } }); for (final File soFile : soFiles) { System.out.println("do patch:" + soFile.getAbsolutePath()); final String relativePath = PathUtils.toRelative(newApkUnzipFolder, soFile.getAbsolutePath()); if (null != ((TpatchInput) input).notIncludeFiles && pathMatcher.match(((TpatchInput) input).notIncludeFiles, relativePath)) { continue; } executorServicesHelper.submitTask(taskName, new Callable<Boolean>() { @Override public Boolean call() throws Exception { File destFile = new File(patchTmpDir, ((TpatchInput) input).mainBundleName + "/" + relativePath); File baseSoFile = new File(baseApkUnzipFolder, relativePath); if (isBundleFile(soFile)) { processBundleFiles(soFile, baseSoFile, patchTmpDir); } else if (isFileModify(soFile, baseSoFile)) { if (destFile.exists()) { FileUtils.deleteQuietly(destFile); } if (!baseSoFile.exists() || !((TpatchInput) input).diffNativeSo) { // FileUtils.copyFile(soFile, destFile); } else { destFile = new File(destFile.getParentFile(), destFile.getName() + ".patch"); SoDiffUtils.diffSo(patchTmpDir, baseSoFile, soFile, destFile); soFileDefs.add(new SoFileDef(baseSoFile, soFile, destFile, relativePath)); } } return true; } }); } executorServicesHelper.waitTaskCompleted(taskName); executorServicesHelper.stop(); Profiler.release(); Profiler.enter("ziptpatchfile"); // zip file File patchFile = createTPatchFile(((TpatchInput) input).outPatchDir, patchTmpDir); tpatchFile.patchFile = patchFile; PatchInfo curPatchInfo = createBasePatchInfo(patchFile); Profiler.release(); Profiler.enter("createhistpatch"); BuildPatchInfos buildPatchInfos = createIncrementPatchFiles(((TpatchInput) input).productName, patchFile, ((TpatchInput) input).outPatchDir, newApkUnzipFolder, curPatchInfo, ((TpatchInput) input).hisPatchUrl); Profiler.release(); Profiler.enter("writejson"); buildPatchInfos.getPatches().add(curPatchInfo); buildPatchInfos.setBaseVersion(input.baseApkBo.getVersionName()); buildPatchInfos.setDiffBundleDex(input.diffBundleDex); FileUtils.writeStringToFile(((TpatchInput) input).outPutJson, JSON.toJSONString(buildPatchInfos)); BuildPatchInfos testForBuildPatchInfos = new BuildPatchInfos(); testForBuildPatchInfos.setBaseVersion(buildPatchInfos.getBaseVersion()); List<PatchInfo> patchInfos = new ArrayList<>(); testForBuildPatchInfos.setPatches(patchInfos); testForBuildPatchInfos.setDiffBundleDex(buildPatchInfos.isDiffBundleDex()); for (PatchInfo patchInfo : buildPatchInfos.getPatches()) { if (patchInfo.getTargetVersion().equals(buildPatchInfos.getBaseVersion())) { patchInfos.add(patchInfo); } } FileUtils.writeStringToFile(hisPatchJsonFile, JSON.toJSONString(testForBuildPatchInfos)); tpatchFile.updateJsons = new ArrayList<File>(); Map<String, List<String>> map = new HashMap<>(); for (PatchInfo patchInfo : buildPatchInfos.getPatches()) { UpdateInfo updateInfo = new UpdateInfo(patchInfo, buildPatchInfos.getBaseVersion()); // System.out.println("start to check:"+patchInfo.getTargetVersion()+"......"); // List<PatchChecker.ReasonMsg> msgs = new PatchChecker(updateInfo,bundleInfos.get(patchInfo.getTargetVersion()),new File(((TpatchInput) input).outPatchDir,patchInfo.getFileName())).check(); // map.put(patchInfo.getFileName(),msgToString(msgs)); File updateJson = new File(((TpatchInput) input).outPatchDir, "update-" + patchInfo.getTargetVersion() + ".json"); FileUtils.writeStringToFile(updateJson, JSON.toJSONString(updateInfo, true)); tpatchFile.updateJsons.add(updateJson); } // tpatchFile.patchChecker = new File(((TpatchInput) input).outPatchDir,"patch-check.json"); // FileUtils.writeStringToFile(tpatchFile.patchChecker, JSON.toJSONString(map, true)); // FileUtils.deleteDirectory(patchTmpDir); apkDiff.setBaseApkVersion(input.baseApkBo.getVersionName()); apkDiff.setNewApkVersion(input.newApkBo.getVersionName()); apkDiff.setBundleDiffResults(bundleDiffResults); boolean newApkFileExist = input.newApkBo.getApkFile().exists() && input.newApkBo.getApkFile().isFile(); if (newApkFileExist) { apkDiff.setNewApkMd5(MD5Util.getFileMD5String(input.newApkBo.getApkFile())); } apkDiff.setFileName(input.newApkBo.getApkName()); apkPatchInfos.setBaseApkVersion(input.baseApkBo.getVersionName()); apkPatchInfos.setNewApkVersion(input.newApkBo.getVersionName()); apkPatchInfos.setBundleDiffResults(diffPatchInfos); apkPatchInfos.setFileName(patchFile.getName()); apkPatchInfos.setNewApkMd5(MD5Util.getFileMD5String(patchFile)); FileUtils.writeStringToFile(tpatchFile.diffJson, JSON.toJSONString(apkDiff)); FileUtils.writeStringToFile(tpatchFile.patchInfo, JSON.toJSONString(apkPatchInfos)); FileUtils.copyFileToDirectory(tpatchFile.diffJson, ((TpatchInput) input).outPatchDir.getParentFile(), true); if (newApkFileExist) { FileUtils.copyFileToDirectory(input.newApkBo.getApkFile(), ((TpatchInput) input).outPatchDir.getParentFile(), true); } Profiler.release(); logger.warning(Profiler.dump()); return tpatchFile; }
From source file:com.photon.phresco.framework.impl.SCMManagerImpl.java
private void splitSrcContents(ApplicationInfo appInfo, File tempSrcFile, RepoInfo repoInfo, String phrescoRepoUrl, String srcRepoUrl, String testRepoUrl, String srcWorkspaceName, String phrWorkspaceName, String testWorkspaceName) throws PhrescoException { try {//from www .j av a 2 s . c om File pomDest = null; String appDirName = appInfo.getAppDirName(); String appHome = Utility.getProjectHome() + appDirName + File.separator; List<ModuleInfo> modules = appInfo.getModules(); if (CollectionUtils.isNotEmpty(modules)) { for (ModuleInfo module : modules) { File srcDest = new File(tempSrcFile, module.getCode()); File srcDir = new File(appHome, module.getCode()); FileUtils.copyDirectory(srcDir, srcDest, false); String moduleAppInfoPath = appHome + module.getCode() + File.separator + Constants.DOT_PHRESCO_FOLDER + File.separator + PROJECT_INFO; ApplicationInfo moduleAppInfo = getApplicationInfo(moduleAppInfoPath); if (StringUtils.isNotEmpty(moduleAppInfo.getPhrescoPomFile())) { pomDest = new File(srcDest, moduleAppInfo.getPhrescoPomFile()); if (pomDest.exists()) { updatePomProperties(appInfo, moduleAppInfo.getAppDirName(), pomDest, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } } else { pomDest = new File(srcDest, moduleAppInfo.getPomFile()); PomProcessor sourceProcessor = new PomProcessor(pomDest); String andSrcDir = sourceProcessor.getProperty("source.dir"); if (StringUtils.isNotEmpty(andSrcDir)) { File androidSourcePom = new File(pomDest.getParent() + File.separator + andSrcDir + File.separator + Constants.POM_NAME); updatePomProperties(appInfo, moduleAppInfo.getAppDirName(), androidSourcePom, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } updatePomProperties(appInfo, moduleAppInfo.getAppDirName(), pomDest, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } if (repoInfo.isSplitPhresco()) { FileUtils.deleteDirectory(new File(srcDest, Constants.DOT_PHRESCO_FOLDER)); if (StringUtils.isNotEmpty(moduleAppInfo.getPhrescoPomFile())) { File phrescoPomFile = new File(srcDest, moduleAppInfo.getPhrescoPomFile()); FileUtil.delete(phrescoPomFile); } } if (repoInfo.isSplitTest()) { String pomFile = moduleAppInfo.getPomFile(); if (StringUtils.isNotEmpty(moduleAppInfo.getPhrescoPomFile())) { pomFile = moduleAppInfo.getPhrescoPomFile(); } PomProcessor pomProcessor = new PomProcessor( new File(appHome + module.getCode() + File.separator + pomFile)); String testDir = pomProcessor.getProperty(Constants.POM_PROP_KEY_TEST_DIR); if (StringUtils.isNotEmpty(testDir)) { FileUtils.deleteDirectory(new File(srcDest, testDir)); } } } if (!repoInfo.isSplitPhresco()) { File srcDir = new File(appHome, Constants.DOT_PHRESCO_FOLDER); File srcDotPhresco = new File(tempSrcFile, Constants.DOT_PHRESCO_FOLDER); FileUtils.copyDirectory(srcDir, srcDotPhresco, false); if (StringUtils.isNotEmpty(appInfo.getPhrescoPomFile())) { File phrescoPomFile = new File(appHome, appInfo.getPhrescoPomFile()); FileUtils.copyFileToDirectory(phrescoPomFile, tempSrcFile, false); } if (StringUtils.isNotEmpty(appInfo.getPomFile())) { File pomFile = new File(appHome, appInfo.getPomFile()); FileUtils.copyFileToDirectory(pomFile, tempSrcFile, false); } String pomFileName = appInfo.getPomFile(); if (StringUtils.isNotEmpty(appInfo.getPhrescoPomFile())) { pomFileName = appInfo.getPhrescoPomFile(); } pomDest = new File(tempSrcFile, pomFileName); updatePomProperties(appInfo, "", pomDest, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } } else { tempSrcFile.mkdirs(); File srcDir = new File(Utility.getProjectHome() + appDirName); FileUtils.copyDirectory(srcDir, tempSrcFile, false); if (StringUtils.isNotEmpty(appInfo.getPhrescoPomFile())) { pomDest = new File(tempSrcFile, appInfo.getPhrescoPomFile()); if (pomDest.exists()) { updatePomProperties(appInfo, "", pomDest, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } } else { pomDest = new File(tempSrcFile, appInfo.getPomFile()); PomProcessor sourceProcessor = new PomProcessor(pomDest); String andSrcDir = sourceProcessor.getProperty("source.dir"); if (StringUtils.isNotEmpty(andSrcDir)) { File androidSourcePom = new File(pomDest.getParent() + File.separator + andSrcDir + File.separator + Constants.POM_NAME); updatePomProperties(appInfo, "", androidSourcePom, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } updatePomProperties(appInfo, "", pomDest, phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } if (repoInfo.isSplitPhresco()) { FileUtils.deleteDirectory(new File(tempSrcFile, Constants.DOT_PHRESCO_FOLDER)); if (StringUtils.isNotEmpty(appInfo.getPhrescoPomFile())) { File phrescoPomFile = new File(tempSrcFile, appInfo.getPhrescoPomFile()); FileUtil.delete(phrescoPomFile); } } if (repoInfo.isSplitTest()) { String pomFile = appInfo.getPomFile(); if (StringUtils.isNotEmpty(appInfo.getPhrescoPomFile())) { pomFile = appInfo.getPhrescoPomFile(); } PomProcessor pomProcessor = new PomProcessor(new File(appHome, pomFile)); String testDir = pomProcessor.getProperty(Constants.POM_PROP_KEY_TEST_DIR); FileUtils.deleteDirectory(new File(tempSrcFile, testDir)); } } if (StringUtils.isNotEmpty(appInfo.getPomFile())) { File phrescoPomSrc = new File(appHome + appInfo.getPomFile()); FileUtils.copyFileToDirectory(phrescoPomSrc, tempSrcFile); if (StringUtils.isEmpty(appInfo.getPhrescoPomFile())) { updatePomProperties(appInfo, "", new File(tempSrcFile, appInfo.getPomFile()), phrescoRepoUrl, srcRepoUrl, testRepoUrl, srcWorkspaceName, phrWorkspaceName, testWorkspaceName); } } } catch (Exception e) { throw new PhrescoException(e); } }