@@ -587,8 +587,8 @@ public class AntBuilder extends Builder { | |||
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; | |||
@@ -705,13 +705,12 @@ class ProductBuilder extends AntBuilder { | |||
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(); | |||
@@ -842,7 +841,7 @@ class ProductBuilder extends AntBuilder { | |||
// 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() ); |
@@ -466,11 +466,11 @@ public abstract class Builder { | |||
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() |
@@ -113,33 +113,6 @@ public class Module { | |||
} | |||
} | |||
// /** 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(); | |||
@@ -376,7 +349,6 @@ public class Module { | |||
String line; | |||
XMLEntry entry = new XMLEntry("classpathentry", ATTS); | |||
// String lastKind = null; | |||
while (null != (line = reader.readLine())) { | |||
// we assume no internal spaces... | |||
entry.acceptTokens(line); | |||
@@ -429,11 +401,11 @@ public class Module { | |||
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); | |||
} | |||
} | |||
} |
@@ -136,6 +136,23 @@ public class Util { | |||
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(); |
@@ -16,6 +16,7 @@ | |||
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; | |||
@@ -42,7 +43,7 @@ public class BuildModuleTests extends TestCase { | |||
/** 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() { | |||
@@ -111,7 +112,7 @@ public class BuildModuleTests extends TestCase { | |||
} | |||
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); | |||
} | |||
@@ -140,12 +141,12 @@ public class BuildModuleTests extends TestCase { | |||
} | |||
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); |
@@ -200,7 +200,7 @@ public class BuildModuleTest extends TestCase { | |||
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())); |
@@ -31,6 +31,7 @@ import org.aspectj.internal.tools.ant.taskdefs.BuildModule; | |||
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; | |||
/** | |||
* | |||
*/ | |||
@@ -183,7 +184,8 @@ public class ModulesTest extends TestCase { | |||
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(); |