/** * Returns the workspace-dir path relative to buildfile-dir. * * @return the relative path for the workspace-dir */ protected String getWorkspaceRelativeDir() { String result; if (fBuildfileDir.startsWith(fWorkspaceDir + File.separator)) { int lastSlash= fWorkspaceDir.length(); result= "${dir.buildfile}" + File.separator + ".."; //$NON-NLS-1$ //$NON-NLS-2$ lastSlash= fBuildfileDir.indexOf(File.separator, lastSlash + 1); while (lastSlash != -1) { result+= File.separator + ".."; //$NON-NLS-1$ lastSlash= fBuildfileDir.indexOf(File.separator, lastSlash + 1); } } else { result= new PathSubstituter() .addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE) .substitute(fWorkspaceDir); } result= result.replace(File.separatorChar, '/'); return result; }
fAbsJarfile= jarLocation; fAntScriptLocation= antScriptLocation; pathSubstituter= new PathSubstituter(); try { fBuildfileDir= antScriptLocation.toFile().getParentFile().getCanonicalPath(); pathSubstituter.addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE); } catch (Exception e) { JavaPlugin.log(e); pathSubstituter.addSubstitution(fJarfileDir, ANT_PROPERTY_DIR_JARFILE); } catch (Exception e) { JavaPlugin.log(e); pathSubstituter.addSubstitution(fWorkspaceDir, ANT_PROPERTY_DIR_WORKSPACE); } catch (Exception e) { JavaPlugin.log(e);
fAbsJarfile= jarLocation; fAntScriptLocation= antScriptLocation; pathSubstituter= new PathSubstituter(); try { fBuildfileDir= antScriptLocation.toFile().getParentFile().getCanonicalPath(); pathSubstituter.addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE); } catch (Exception e) { JavaPlugin.log(e); pathSubstituter.addSubstitution(fJarfileDir, ANT_PROPERTY_DIR_JARFILE); } catch (Exception e) { JavaPlugin.log(e); pathSubstituter.addSubstitution(fWorkspaceDir, ANT_PROPERTY_DIR_WORKSPACE); } catch (Exception e) { JavaPlugin.log(e);
/** * Converts the given filename relative to any of the ant-property-dirs: * <ul> * <li>buidfile-dir (where the ant script is)</li> * <li>workspace-dir (eclipse workspace dir)</li> * <li>jarfile-dir (where the jar is written to)</li> * </ul> * * @param absFilename filename whose base dir is substituted * @return either the original filename or a relative path from one of the base-dirs */ protected String substituteBaseDirs(String absFilename) { String canonicleFilename; try { canonicleFilename= new File(absFilename).getCanonicalPath(); } catch (IOException e) { e.printStackTrace(); return absFilename; } String result= pathSubstituter.substitute(canonicleFilename); result= result.replace(File.separatorChar, '/'); return result; }
/** * Returns the workspace-dir path relative to buildfile-dir. * * @return the relative path for the workspace-dir */ protected String getWorkspaceRelativeDir() { String result; if (fBuildfileDir.startsWith(fWorkspaceDir + File.separator)) { int lastSlash= fWorkspaceDir.length(); result= "${dir.buildfile}" + File.separator + ".."; //$NON-NLS-1$ //$NON-NLS-2$ lastSlash= fBuildfileDir.indexOf(File.separator, lastSlash + 1); while (lastSlash != -1) { result+= File.separator + ".."; //$NON-NLS-1$ lastSlash= fBuildfileDir.indexOf(File.separator, lastSlash + 1); } } else { result= new PathSubstituter() .addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE) .substitute(fWorkspaceDir); } result= result.replace(File.separatorChar, '/'); return result; }
/** * Converts the given filename relative to any of the ant-property-dirs: * <ul> * <li>buidfile-dir (where the ant script is)</li> * <li>workspace-dir (eclipse workspace dir)</li> * <li>jarfile-dir (where the jar is written to)</li> * </ul> * * @param absFilename filename whose base dir is substituted * @return either the original filename or a relative path from one of the base-dirs */ protected String substituteBaseDirs(String absFilename) { String canonicleFilename; try { canonicleFilename= new File(absFilename).getCanonicalPath(); } catch (IOException e) { e.printStackTrace(); return absFilename; } String result= pathSubstituter.substitute(canonicleFilename); result= result.replace(File.separatorChar, '/'); return result; }
/** * Returns jarfile-dir path relative to buildfile-dir or workspace-dir. * * @return the relative path for the jarfile-dir */ protected String getJarfileRelativeDir() { String result= new PathSubstituter() .addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE) .addSubstitution(fWorkspaceDir, ANT_PROPERTY_DIR_WORKSPACE) .substitute(fJarfileDir); result= result.replace(File.separatorChar, '/'); return result; }
/** * Returns jarfile-dir path relative to buildfile-dir or workspace-dir. * * @return the relative path for the jarfile-dir */ protected String getJarfileRelativeDir() { String result= new PathSubstituter() .addSubstitution(fBuildfileDir, ANT_PROPERTY_DIR_BUILDFILE) .addSubstitution(fWorkspaceDir, ANT_PROPERTY_DIR_WORKSPACE) .substitute(fJarfileDir); result= result.replace(File.separatorChar, '/'); return result; }