Project

General

Profile

javac_depend.diff

dhogan dhogan, 11/28/2011 02:58 PM

View differences:

settings/build-properties.xml (working copy)
31 31
    <property name="run-module-manager" value="false"/>
32 32
    <property name="url" value="undefined"/>
33 33
    <property name="number" value="undefined"/>
34
    <property name="depend" value="false" />
35
    <property name="depend-classpath" value="false" />
36
    <property name="depend-closure" value="false" />
34 37
</project>
src/org/kepler/build/CompileModules.java (working copy)
26 26
package org.kepler.build;
27 27

  
28 28
import org.apache.tools.ant.taskdefs.Javac;
29
import org.apache.tools.ant.taskdefs.optional.depend.Depend;
30
import org.apache.tools.ant.types.Path;
29 31
import org.kepler.build.modules.Module;
30 32
import org.kepler.build.modules.ModulesTask;
31 33
import org.kepler.build.project.CompileClasspath;
......
51 53
    protected String moduleName = "undefined";
52 54
    protected String compilerArgs = "undefined";
53 55
    protected boolean debug = false;
56
    protected boolean depend = false;
57
    protected boolean dependClasspath = false;
58
    protected boolean dependClosure = false;
54 59
    protected List<String> exclude = new ArrayList<String>();
55 60
    protected List<String> include = new ArrayList<String>();
56 61

  
......
85 90
    }
86 91

  
87 92
    /**
93
     * set whether to use java dependencies to delete out of date files
94
     *
95
     * @param depend
96
     */
97
    public void setDepend(boolean depend)
98
    {
99
        this.depend = depend;
100
    }
101

  
102
    /**
103
     * set whether Depend should use the classpath
104
     *
105
     * @param dependClasspath
106
     */
107
    public void setDependClasspath(boolean dependClasspath)
108
    {
109
        this.dependClasspath = dependClasspath;
110
    }
111

  
112
    /**
113
     * set whether Depend should use closure
114
     *
115
     * @param dependClosure
116
     */
117
    public void setDependClosure(boolean dependClosure)
118
    {
119
        this.dependClosure = dependClosure;
120
    }
121

  
122
    /**
88 123
     * set any includes
89 124
     *
90 125
     * @param include
......
230 265
        javac.setFork(true);
231 266
        javac.setMemoryMaximumSize("512m");
232 267
        javac.setFailonerror(true);
268

  
269
        // Depend helps Javac by deleting out of date class files by
270
        // determining dependencies rather than just timestamps.
271
        Depend dep = null;
272
        if (this.depend) {
273
            dep = new Depend();
274
            dep.bindToOwner(this);
275
            dep.setSrcdir(module.getSrcPath());
276

  
277
            if (this.dependClasspath) {
278
                // Ant assumes that anything in the path that's not a directory
279
                // is a jar.  Kepler adds a lot of non-jar files to the
280
                // classpath including *.htm and *.in.  If you don't filter them
281
                // out of the classpath for Depend, it will throw an exception.
282
                Path cleanClasspath = new Path(classpath.getProject());
283
                for (String s : classpath.list()) {
284
                    if (s.toLowerCase().endsWith(".jar") || new File(s).isDirectory()) {
285
                        cleanClasspath.setPath(s);
286
                    }
287
                }
288
            } else {
289
                dep.createClasspath();
290
            }
291

  
292
            Path path = new Path(module.getSrcPath().getProject(), classes.getAbsolutePath());
293
            dep.setDestDir(path);
294
            dep.setWarnOnRmiStubs(true);
295
    
296
            if (this.dependClosure) {
297
                dep.setClosure(false);
298
            }
299
        }
300

  
233 301
        if (osDependentExcludes)
234 302
        {
235 303
            javac.setExcludesfile(new File(basedir, "build-area/settings/os-dependent-excludes"));
304

  
305
            if (this.depend) {
306
                dep.setExcludesfile(new File(basedir, "build-area/settings/os-dependent-excludes"));
307
            }
236 308
        }
237 309

  
238 310
        if (mn.equals(Module.PTOLEMY) || mn.matches(Module.PTOLEMY+"-\\d+\\.\\d+") || 
239 311
        		mn.matches(Module.PTOLEMY_KEPLER+"-\\d+\\.\\d+"))
240 312
        {
241 313
            javac.setIncludesfile(new File(basedir, "build-area/settings/ptolemy-includes"));
314
            if (this.depend) {
315
                dep.setIncludesfile(new File(basedir, "build-area/settings/ptolemy-includes"));
316
            }
317

  
242 318
            javac.setExcludesfile(new File(basedir, "build-area/settings/ptolemy-excludes"));
319
            if (this.depend) {
320
                dep.setExcludesfile(new File(basedir, "build-area/settings/ptolemy-excludes"));
321
            }
243 322
        }
244 323

  
324
        if (this.depend) {
325
            File baseCache = new File("./depcache");
326
            if (! baseCache.exists()) {
327
                baseCache.mkdirs();
328
            }
329
    
330
            // Depend uses this path.  In practice, it will create
331
            // ./depcache/<modulename>/dependencies.txt
332
            File modDep = new File(baseCache, module.toString());
333
            dep.setCache(modDep);
334
    
335
            dep.execute();
336
        }
337

  
245 338
        if (!compilerArgs.equals("undefined"))
246 339
        {
247 340
            String[] args = compilerArgs.split(",");
build.xml (working copy)
45 45

  
46 46
	<target name="compile" description="Compile all the modules in modules.txt.">
47 47
	        <echo>Note that you may need to run "ant force-ptolemy compile" to compile ptolemy.</echo>
48
		<compile module="${module}" compilerArgs="${compiler-args}" debug="${debug}" include="${include}" exclude="${exclude}" skip="${skip}" />
48
		<compile module="${module}" compilerArgs="${compiler-args}" debug="${debug}" include="${include}" exclude="${exclude}" skip="${skip}" depend="${depend}" dependClasspath="${depend-classpath}" dependClosure="${depend-closure}" />
49 49
	</target>
50 50

  
51 51
	<target name="run" depends="compile" description="Compile, then run Kepler along with the modules in modules.txt.  Use -Dworkflow=model.xml to run a model.">