[Scons-users] Java dependencies with auto-generated Java files

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Oct 5 12:28:33 EDT 2018


Hi,

I have a multi-language project that includes a Java component, and
recently I discovered that the Java builder somehow isn't returning the
correct list of Nodes. The affected Nodes appear to be related to a few
Java source files that are auto-generated by code-generating tools.
Here's a simplified view of my Java directory:

	src
	src/com
	src/com/example/
	src/com/example/app/
	src/com/example/app/Main.java
	src/com/example/app/AutoGenerated1.java	(*)
	src/com/example/app/AutoGenerated2.java	(*)

The files marked (*) are generated as part of the build, and do not
exist in a clean workspace.

Here's my invocation of the Java builder:

	classfiles = env.Java(target = 'obj', source = 'src', JAVAVERSION = '1.7')

Printing out the nodes in `classfiles` with `print [ f.path for f in
classfiles` gives me:

	obj/com/example/app/Main.class
	obj/AutoGenerated1.class
	obj/AutoGenerated2.class

rather than the expected:

	obj/com/example/app/Main.class
	obj/com/example/app/AutoGenerated1.class
	obj/com/example/app/AutoGenerated2.class

Strangely enough, running scons with --tree shows nodes that correspond
with the correct class files for the auto-generated sources. However,
because the Java builder didn't return the correct list of nodes, it
causes a later packaging stage in the build to fail to depend on these
class files, and as a result sometimes changes to the auto-generated
sources are not picked up by the packaging Command because SCons doesn't
think it needs updating.

Based on the documentation, it appears the the Java builder scans .java
files during SCons' initialization stage and picks up dependencies that
way; but since the auto-generated .java files may not exist yet, it
seems this approach would not reliably pick up the dependencies.

Any ideas how I could solve this problem?  I suppose I could hard-code
the dependencies on the .class files, but if there were inner classes in
the auto-generated code this wouldn't work so well either.


T

-- 
People tell me that I'm paranoid, but they're just out to get me.


More information about the Scons-users mailing list