details: https://code.openbravo.com/erp/devel/pi/rev/988d6933a2bd changeset: 27030:988d6933a2bd user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Thu Jun 25 12:38:04 2015 +0200 summary: Fixes 30135: On windows the ant setup tool writes incorrect source.path
The ant setup tool was writing an incorrect source.path because the user.dir property obtained under Windows contains backslashes as file separator in the path. Now this case is controlled, and in case we are under a Windows operative system, the backslashes are replaced with a slash. The slash can be safely used in all platforms because Java internally can handle it and do the translation into platform-specific paths diffstat: src/org/openbravo/configuration/ConfigurationApp.java | 26 ++++++++++++++---- 1 files changed, 20 insertions(+), 6 deletions(-) diffs (83 lines): diff -r dbdd3e64a7d1 -r 988d6933a2bd src/org/openbravo/configuration/ConfigurationApp.java --- a/src/org/openbravo/configuration/ConfigurationApp.java Tue Jun 23 18:35:47 2015 +0200 +++ b/src/org/openbravo/configuration/ConfigurationApp.java Thu Jun 25 12:38:04 2015 +0200 @@ -32,6 +32,7 @@ import java.util.Scanner; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.SystemUtils; import org.apache.tools.ant.Project; /** @@ -48,7 +49,7 @@ private static List<ConfigureOption> optionForOpenbravo = new ArrayList<ConfigureOption>(); private static Map<String, String> replaceProperties = new HashMap<String, String>(); - private final static String BASEDIR = System.getProperty("user.dir"); + private final static String BASEDIR = getUserDir(); private final static String BASEDIR_CONFIG = BASEDIR + "/config/"; private final static String SUFFIX_AUX = ".aux"; private final static String OPENBRAVO_PROPERTIES = BASEDIR_CONFIG + "Openbravo.properties"; @@ -781,7 +782,7 @@ replaceProperties.put(PREFIX_CONTEXT_URL, optionFirstForReplace.getChosenOption()); } } - replaceProperties.put(PREFIX_SOURCE_PATH, System.getProperty("user.dir")); + replaceProperties.put(PREFIX_SOURCE_PATH, getUserDir()); if (dateFormat.substring(0, 1).equals("D")) { replaceProperties.put(PREFIX_DATE_FORMAT_JAVA, "dd" + dateSeparator + "MM" + dateSeparator @@ -943,7 +944,7 @@ /** * This method delete a File:filePath and rename File:fileAuxPath to File:filePath - * + * * @param filePath * file to delete * @param fileAuxPath @@ -963,7 +964,7 @@ /** * This method replace a value changeOption in addressFilePath. FileR is used to check that exists * searchOption with different value. - * + * * @param fileR * old file to read * @param addressFilePath @@ -1007,14 +1008,14 @@ * This method replaceGeneralProperty(...) replaces in addressFilePath the value in any option * searchOption with value changeOption. Concatenated searchOption+changeOption. For example: * "bbdd.user=" + "admin". - * + * * @param addressFilePath * Replace in this file * @param searchOption * Prefix to search * @param changeOption * Value to write in addressFilePath - * + * */ private static void replaceGeneralProperty(String addressFilePath, String searchOption, String changeOption, Project p) { @@ -1511,4 +1512,17 @@ } } } + + /** + * This function returns the user.dir directory replacing backslashes for the case of Windows + * operative systems. + * + */ + private static String getUserDir() { + String userDir = System.getProperty("user.dir"); + if (SystemUtils.IS_OS_WINDOWS) { + userDir = userDir.replace("\\", "/"); + } + return userDir; + } } \ No newline at end of file ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits