My Goal
I am trying to replace ant
by scons
to build java files and create jar files.
Problem
- Expected Result : The following piece of code
env.Java(target = 'classes', source = 'src')
shall generate all.class
files, then, when a clean build is launched (no changes are made), scons should tell be that my tartet is up-to-date - Actual Result : Because
package-info.java
file is empty,scons
java builder is NOT generating the .class file. The side effect is everytime I launch a build, scons tell me that he needs to generatepackage-info.class
, then, the build is relaunch everytime. The target is never considered up to date.
What I have tried so far:
This question has been asked a long time ago. But, the solution is not working anymore, and what it tries to do is to remove package-info.class from target :
tgts = env.Java(target = 'classes', source = 'src')
for f in tgts:
if f.path.endswith('package-info.class'):
tgts.remove(f)
jar = env.Jar(target = 'dds-interface.jar', source = tgts)
Default(jar)
This generates the error
AttributeError: <class 'SCons.Node.FS.File'> object has no attribute 'upper':
File "C:\SVN\products\faa_mx\vs2017.install2\SConstruct", line 31:
sc_manager.build()
File "C:\SVN\products\faa_mx\vs2017.install2\cm\env\scons\utilities\sconscriptManager.py", line 43:
cache = SCons.Script.SConscript(str(script).strip(), exports='envService parentEnv vcxprojList', variant_dir=utils.createVariantDir(envService, script), duplicate=0)
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Script\SConscript.py", line 614:
return method(*args, **kw)
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Script\SConscript.py", line 551:
return _SConscript(self.fs, *files, **subst_kw)
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Script\SConscript.py", line 256:
call_stack[-1].globals)
File "C:\SVN\products\faa_mx\vs2017.install2\fwk\network\dds\simd\java\api\java_api.sc", line 51:
source = tgts)
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Tool\jar.py", line 169:
target_classes.extend(file_to_class(s))
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Tool\jar.py", line 143:
if(str(_my_normcase(s)).endswith(java_suffix)):
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Node\FS.py", line 366:
return x.upper()
File "c:\python\python35\lib\site-packages\scons-3.0.1\SCons\Node\FS.py", line 632:
(self.__class__, attr))
From what I read into the doc, Jar only accept java file or 'classes' as source.
Questions:
- Is it possible to tell scons to force the generation of
package-info.class
file (like withant
)? - Would it be possible to just remove
package-info.java
file from the project instead, without breaking everything? I don`t think documentation is important for our project.
EDIT
I have found the solution, I should pass -Xpkginfo:always
to scons JAVACFLAGS
. Unfortunately, my version of javac (1.7.0_25) is crashing when I am passing this argument.