Index: settings/build-properties.xml =================================================================== --- settings/build-properties.xml (revision 29007) +++ settings/build-properties.xml (working copy) @@ -31,4 +31,7 @@ + + + Index: src/org/kepler/build/CompileModules.java =================================================================== --- src/org/kepler/build/CompileModules.java (revision 29007) +++ src/org/kepler/build/CompileModules.java (working copy) @@ -26,6 +26,8 @@ package org.kepler.build; import org.apache.tools.ant.taskdefs.Javac; +import org.apache.tools.ant.taskdefs.optional.depend.Depend; +import org.apache.tools.ant.types.Path; import org.kepler.build.modules.Module; import org.kepler.build.modules.ModulesTask; import org.kepler.build.project.CompileClasspath; @@ -51,6 +53,9 @@ protected String moduleName = "undefined"; protected String compilerArgs = "undefined"; protected boolean debug = false; + protected boolean depend = false; + protected boolean dependClasspath = false; + protected boolean dependClosure = false; protected List exclude = new ArrayList(); protected List include = new ArrayList(); @@ -85,6 +90,36 @@ } /** + * set whether to use java dependencies to delete out of date files + * + * @param depend + */ + public void setDepend(boolean depend) + { + this.depend = depend; + } + + /** + * set whether Depend should use the classpath + * + * @param dependClasspath + */ + public void setDependClasspath(boolean dependClasspath) + { + this.dependClasspath = dependClasspath; + } + + /** + * set whether Depend should use closure + * + * @param dependClosure + */ + public void setDependClosure(boolean dependClosure) + { + this.dependClosure = dependClosure; + } + + /** * set any includes * * @param include @@ -230,18 +265,76 @@ javac.setFork(true); javac.setMemoryMaximumSize("512m"); javac.setFailonerror(true); + + // Depend helps Javac by deleting out of date class files by + // determining dependencies rather than just timestamps. + Depend dep = null; + if (this.depend) { + dep = new Depend(); + dep.bindToOwner(this); + dep.setSrcdir(module.getSrcPath()); + + if (this.dependClasspath) { + // Ant assumes that anything in the path that's not a directory + // is a jar. Kepler adds a lot of non-jar files to the + // classpath including *.htm and *.in. If you don't filter them + // out of the classpath for Depend, it will throw an exception. + Path cleanClasspath = new Path(classpath.getProject()); + for (String s : classpath.list()) { + if (s.toLowerCase().endsWith(".jar") || new File(s).isDirectory()) { + cleanClasspath.setPath(s); + } + } + } else { + dep.createClasspath(); + } + + Path path = new Path(module.getSrcPath().getProject(), classes.getAbsolutePath()); + dep.setDestDir(path); + dep.setWarnOnRmiStubs(true); + + if (this.dependClosure) { + dep.setClosure(false); + } + } + if (osDependentExcludes) { javac.setExcludesfile(new File(basedir, "build-area/settings/os-dependent-excludes")); + + if (this.depend) { + dep.setExcludesfile(new File(basedir, "build-area/settings/os-dependent-excludes")); + } } if (mn.equals(Module.PTOLEMY) || mn.matches(Module.PTOLEMY+"-\\d+\\.\\d+") || mn.matches(Module.PTOLEMY_KEPLER+"-\\d+\\.\\d+")) { javac.setIncludesfile(new File(basedir, "build-area/settings/ptolemy-includes")); + if (this.depend) { + dep.setIncludesfile(new File(basedir, "build-area/settings/ptolemy-includes")); + } + javac.setExcludesfile(new File(basedir, "build-area/settings/ptolemy-excludes")); + if (this.depend) { + dep.setExcludesfile(new File(basedir, "build-area/settings/ptolemy-excludes")); + } } + if (this.depend) { + File baseCache = new File("./depcache"); + if (! baseCache.exists()) { + baseCache.mkdirs(); + } + + // Depend uses this path. In practice, it will create + // ./depcache//dependencies.txt + File modDep = new File(baseCache, module.toString()); + dep.setCache(modDep); + + dep.execute(); + } + if (!compilerArgs.equals("undefined")) { String[] args = compilerArgs.split(","); Index: build.xml =================================================================== --- build.xml (revision 29007) +++ build.xml (working copy) @@ -45,7 +45,7 @@ Note that you may need to run "ant force-ptolemy compile" to compile ptolemy. - +