private static final String BASE_DIR = "../";
private static final String[] JDT_SOURCE_DIRS = new String[] {};
- // sources moved to shadow/ directory
-// {"antadapter", "batch", "codeassist", "compiler",
-// "dom", "eval", "formatter", "model", "search" };
public static Test suite() {
TestSuite suite = new TestSuite("Build module tests");
/** @return String tag of license if not default */
public static String getLicense(String module) {
- if ("org.eclipse.jdt.core".equals(module)) {
- return Checklics.CPL_IBM_PARC_TAG;
- }
- return null;
+ return null; // use permissive default
}
public BuildModuleTests(String name) { super(name); }
public void testLicense_org_aspectj_ajdt_core() {
checkLicense("org.aspectj.ajdt.core");
}
+ public void testLicense_org_aspectj_lib() {
+ checkLicense("org.aspectj.lib");
+ }
public void testLicense_org_eclipse_jdt_core() {
final String mod = "org.eclipse.jdt.core";
final String pre = BASE_DIR + mod + "/";
// assertTrue(!replaceFailed);
// license = Checklics.CPL_IBM_PARC_XEROX_TAG;
// }
- int fails = Checklics.runDirect(moduleDir.getPath(), license);
+ int fails = Checklics.runDirect(moduleDir.getPath(), license, true);
if (0 != fails) {
if (replacing) {
BuildModuleTests.replaceFailed = true;
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 2002 Palo Alto Research Center, Incorporated (PARC),
+ * 2005 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
*/
public class BuildModuleTest extends TestCase {
+ private static boolean printedMessage;
private static final String SKIP_MESSAGE =
"Define \"run.build.tests\" as a system property to run tests to build ";
private static final String BUILD_CONFIG;
}
public void testAspectjtools() {
- if (!building) {
- System.err.println(SKIP_MESSAGE + "aspectjtools");
+ if (!shouldBuild("aspectjtools")) {
return;
}
File baseDir = new File("..");
}
void checkBuildProduct(File productDir, File baseDir, File distDir, File jarDir) {
- if (!building) {
- System.err.println(SKIP_MESSAGE + "product " + productDir);
+ if (!shouldBuild(productDir.getPath())) {
return;
}
assertTrue(null != productDir);
String[] args) {
checkBuild(module, classname, args, false);
}
-
+
+ boolean shouldBuild(String target) {
+ if (!building && !printedMessage) {
+ System.err.println(SKIP_MESSAGE + target + " (this is the only warning)");
+ printedMessage = true;
+ }
+ return building;
+ }
void checkBuild(String module,
String classname,
String[] args,
boolean addAnt) {
- if (!building) {
- System.err.println(SKIP_MESSAGE + "module " + module);
+ if (!shouldBuild(module)) {
return;
}
assertTrue(null != module);
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 2002 Palo Alto Research Center, Incorporated (PARC),
+ * 2005 Contributors.
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
*
* Contributors:
* Xerox/PARC initial implementation
+ * Wes Isberg build tests
* ******************************************************************/
package org.aspectj.internal.build;
import junit.framework.TestCase;
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;
import org.aspectj.internal.tools.ant.taskdefs.AntBuilder;
+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;
public void testAllModulesCreation() {
File baseDir = new File("..");
- File[] files = baseDir.listFiles();
+ String[] knowns = {"runtime", "util", "weaver" };
+ File[] files = new File[knowns.length];
for (int i = 0; i < files.length; i++) {
+ files[i] = new File(knowns[i]);
if (files[i].isDirectory()) {
File classpath = new File(files[i], ".classpath");
if (classpath.exists()) {
assertTrue(classpath.toString(), false);
}
}
-
+
+
+ /*********************************************************************
+ * The following tests/code enable you to run the entire build in JUnit
+ * to debug directly from Eclipse. To compile using Javac, you will
+ * need to add tools.jar to the run classpath.
+ */
+ public void skip_testBuildingAspectJModule() {
+ final String moduleName = "org.aspectj.lib";
+
+ File modulesDir = new File("..").getAbsoluteFile();
+ File buildDir = new File(modulesDir, "aj-build");
+ File distDir = new File(buildDir, "dist");
+ File jarDir = new File(buildDir, "jars");
+ File moduleDir = new File(modulesDir, moduleName);
+ File jar = new File(jarDir, "org.aspectj.lib.jar");
+ jarDir.mkdirs();
+ distDir.mkdirs();
+ if (jar.canRead()) {
+ assertTrue(jar.delete());
+ }
+ Project project = new Project();
+ project.setBaseDir(modulesDir);
+ project.setName("testAspectjbuild");
+
+ BuildModule bm = new BuildModule();
+ bm.setProject(project);
+ bm.setAssembleall(true);
+ bm.setBuildConfig("");
+ bm.setModule(moduleName);
+ bm.setBasedir(new Path(project, modulesDir.getPath()));
+ bm.setDistdir(new Path(project, buildDir.getPath()));
+ bm.setJardir(new Path(project, jarDir.getPath()));
+ bm.setModuledir(new Path(project, moduleDir.getPath()));
+ bm.setTrimtesting(true);
+ bm.setBuildConfig("");
+ bm.setVersion("1.2");
+ bm.setVerbose(true);
+ bm.setFailonerror(true);
+
+ bm.execute();
+
+ assertTrue(jar.canRead());
+ }
+
+ public void skip_testBuildingProduct() {
+ final String productName = "tools";
+ File modulesDir = new File("..").getAbsoluteFile();
+ 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);
+
+ jarDir.mkdirs();
+ distDir.mkdirs();
+
+ Project project = new Project();
+ project.setBaseDir(modulesDir);
+ project.setName("testAspectjToolsbuild");
+ project.addBuildListener(new EventBuildListener(Project.MSG_WARN));
+
+ BuildModule bm = new BuildModule();
+ bm.setProject(project);
+ bm.setAssembleall(true);
+ bm.setBuildConfig("");
+ bm.setProductdir(new Path(project, productDir.getPath()));
+ bm.setBasedir(new Path(project, modulesDir.getPath()));
+ bm.setDistdir(new Path(project, distDir.getPath()));
+ bm.setJardir(new Path(project, jarDir.getPath()));
+ bm.setTrimtesting(true);
+ bm.setBuildConfig("");
+ bm.setVersion("1.2");
+ bm.setFailonerror(true);
+ bm.execute();
+
+ File libDir = new File(distDir, "tools/lib");
+ String[] jars = { "tools", "rt", "weaver", "lib"};
+ for (int i = 0; i < jars.length; i++) {
+ File jar = new File(libDir, "aspectj" + jars[i] + ".jar");
+ assertTrue(jar.getPath(), jar.canRead());
+ if (10 > jar.length()) {
+ assertTrue(jar + " too small", false);
+ }
+ }
+ }
+ /**
+ * Show messages from the task.
+ * (normally shown by Ant's default listener)
+ */
+ static class EventBuildListener implements BuildListener {
+ final int min;
+ EventBuildListener(int min) {
+ this.min = min;
+ }
+ public void buildFinished(BuildEvent event) {}
+ public void buildStarted(BuildEvent event) { }
+ public void messageLogged(BuildEvent event) {
+ if (min <= event.getPriority()) {
+ Task t = event.getTask();
+ String src = (null == t ? "project" : t.getTaskName());
+ System.out.println(src + ": " + event.getMessage());
+ }
+ }
+ public void targetFinished(BuildEvent event) { }
+ public void targetStarted(BuildEvent event) { }
+ public void taskFinished(BuildEvent event) { }
+ public void taskStarted(BuildEvent event) { }
+
+ }
}