libDirs[i] = project.getProperty(libDirNames[i]);
}
if (null != libDirs[i]) {
- libDirs[i] += File.separator + "lib";
- result = new Path(project, libDirs[i] + File.separator + name);
+ libDirs[i] = Util.path(libDirs[i], "lib");
+ result = new Path(project, Util.path(libDirs[i], name));
String path = result.toString();
if (new File(path).canRead()) {
return result;
private static String getProductInstallResourcesSrc(BuildSpec buildSpec) {
final String resourcesName = "installer-resources"; // XXXFileLiteral
File dir = buildSpec.productDir.getParentFile();
-// String result = null;
if (null == dir) {
- return "../../" + resourcesName;
+ return Util.path(new String[] {"..", "..", resourcesName});
}
dir = dir.getParentFile();
if (null == dir) {
- return "../" + resourcesName;
+ return Util.path("..", resourcesName);
} else {
dir = new File(dir, resourcesName);
return dir.getPath();
// copy binaries associated with module flag files
for (int i = 0; i < productModules.length; i++) {
ProductModule product = productModules[i];
- String targPath = targDirPath + "/" + product.relativePath;
+ String targPath = Util.path(targDirPath, product.relativePath);
File jarFile = (product.assembleAll
? product.module.getAssembledJar()
: product.module.getModuleJar() );
FILTER_OFF)) {
return false;
}
-
+ // duplicate code?
// copy binaries associated with module flag files
for (int i = 0; i < productModules.length; i++) {
ProductModule product = productModules[i];
- String targPath = targDirPath + "/" + product.relativePath;
+ String targPath = Util.path(targDirPath, product.relativePath);
File jarFile =
(product.assembleAll
? product.module.getAssembledJar()
}
}
-// /** XXX gack explicitly skip Ant, sun tools.jar except for testing... modules */
-// private static boolean skipLibraryJarAntecedant(Module module, File libJar) {
-// if (null == libJar) {
-// return true;
-// }
-// if (!module.name.startsWith("testing")) {
-// String path = libJar.getPath().replace('\\', '/');
-// path = path.replace(File.separatorChar, '/');
-// if (-1 != path.indexOf("/lib/ant/lib/")) {
-// return true;
-// } else if (-1 != path.indexOf("/tools.jar")) {
-// return true;
-// }
-// }
-// return false;
-// }
-//
-// /** XXX gack explicitly skip runtime */
-// private static boolean skipModuleJarAntecedant(File requiredJar) {
-// if (null == requiredJar) {
-// return true;
-// } else {
-// //return "runtime.jar".equals(requiredJar.getName());
-// return false;
-// }
-// }
-
/**@return true if this is a source file */
private static boolean isSourceFile(File file) {
String path = file.getPath();
String line;
XMLEntry entry = new XMLEntry("classpathentry", ATTS);
-// String lastKind = null;
while (null != (line = reader.readLine())) {
// we assume no internal spaces...
entry.acceptTokens(line);
path = path.substring(JAVA_HOME.length());
String home = System.getProperty("java.home");
if (null != home) {
- libPath = home + File.separator + path;
+ libPath = Util.path(home, path);
File f = new File(libPath);
if (!f.exists() && home.endsWith("jre")) {
f = new File(home).getParentFile();
- libPath = f.getPath() + File.separator + path;
+ libPath = Util.path(f.getPath(), path);
}
}
}
return (null != dir) && dir.canWrite() && dir.isDirectory();
}
+ public static String path(String first, String second) {
+ return first + File.separator + second;
+ }
+
+ public static String path(String[] segments) {
+ StringBuffer sb = new StringBuffer();
+ if ((null != segments)) {
+ for (int i = 0; i < segments.length; i++) {
+ if (0 < i) {
+ sb.append(File.separator);
+ }
+ sb.append(segments[i]);
+ }
+ }
+ return sb.toString();
+ }
+
/** @return true if dir is a readable directory */
public static boolean canReadDir(File dir) {
return (null != dir) && dir.canRead() && dir.isDirectory();
import org.aspectj.internal.tools.ant.taskdefs.Checklics;
import org.aspectj.internal.tools.build.Builder;
+import org.aspectj.internal.tools.build.Util;
import org.aspectj.internal.build.BuildModuleTest;
import org.aspectj.internal.build.ModulesTest;
/** replace commented out below - if any replace failed, halt all */
private static boolean replaceFailed = false;
- private static final String BASE_DIR = "../";
+ private static final String BASE_DIR = ".." + File.separator;
private static final String[] JDT_SOURCE_DIRS = new String[] {};
public static Test suite() {
}
public void testLicense_org_eclipse_jdt_core() {
final String mod = "org.eclipse.jdt.core";
- final String pre = BASE_DIR + mod + "/";
+ final String pre = BASE_DIR + mod + File.separator;
for (int i = 0; i < JDT_SOURCE_DIRS.length; i++) {
checkSourceDirectory(new File(pre + JDT_SOURCE_DIRS[i]), mod);
}
}
public void testLicense_weaver() {
String module = "weaver";
- checkSourceDirectory(new File("../" + module + "/src"), module);
- checkSourceDirectory(new File("../" + module + "/testsrc/org"), module);
+ checkSourceDirectory(new File(Util.path(new String[] {"..", module, "src"})), module);
+ checkSourceDirectory(new File(Util.path(new String[] {"..", module, "testsrc", "org"})), module);
}
void checkLicense(String module) {
- File moduleDir = new File(".." + File.separator + module);
+ File moduleDir = new File(Util.path("..", module));
File[] srcDirs = findSourceRoots(moduleDir);
for (int i = 0; i < srcDirs.length; i++) {
checkSourceDirectory(srcDirs[i], module);
File jarDir = getJarDir();
assertTrue(jarDir.canWrite() || jarDir.mkdirs());
tempFiles.add(jarDir);
- File moduleDir = new File("../" + module);
+ File moduleDir = new File(Util.path("..", module));
assertTrue(moduleDir.canRead());
task.setModuledir(new Path(project, moduleDir.getAbsolutePath()));
task.setJardir(new Path(project, jarDir.getAbsolutePath()));
import org.aspectj.internal.tools.build.Messager;
import org.aspectj.internal.tools.build.Module;
import org.aspectj.internal.tools.build.Modules;
+import org.aspectj.internal.tools.build.Util;
/**
*
*/
File buildDir = new File(modulesDir, "aj-build");
File distDir = new File(buildDir, "dist");
File jarDir = new File(buildDir, "jars");
- File productDir = new File(modulesDir, "build/products/" + productName);
+ File productDir = new File(modulesDir,
+ Util.path(new String[] {"build", "products", productName}));
jarDir.mkdirs();
distDir.mkdirs();