[Scons-users] replacing ant with java
Pierre-Luc Boily
pierreluc.boily at gmail.com
Tue Oct 18 21:29:52 EDT 2016
Hello,
We are in a process to move our Make system / Ant to scons. So far, we
succeeded to :
1. Replace *make *by *scons *to compile C++
2. Create *Custom Builders* that compile successfully grammars (we are
in speech project)
3. Grammars & C++ code compile in parallel
4. Make *scons * invoke our ant system to compile multiple Java jar
(single threaded)
What failed :
1. Our java code, compiled with python *call* function (invoking ant)
failed in parallel. *(Actually, I am not sure to understand yet why this
failed. Our java dependencies are well written in build.xml..)*
To resolve my problem above, I see two solutions :
1. Compile our project single threaded
2. Or remove ant and replace with scons to compile java.
I am here because I want to be able to do solution two. Compiling multi
threaded is really powerful. So, before putting too much effort, I have
couple question regarding compiling java with scons. I want to be sure
that what we I want to do is feasible.
*Question 1:*
Code below is our main *build.xml* file. As you can see, the xml has been
written with dependencies. So, when *ant *is invoke, he knows that he has
to build *subprojects *first. I am wondering if scons can automagically
manage this? My guess is I will probably need a Custom Builder to
accomplish a task like this.
<!-- Create executable jar -->
<target name="create_run_jar" depends="clean, build-subprojects,
build-project, copy-lib">
<echo message="[${ant.project.name}] localroot = ${env.LOCALROOT}"/>
<echo message="[${ant.project.name}] dist = ${dist_dir_output}"/>
<echo message="[${ant.project.name}] Creating ${ant.project.name} jar
to ${dist_dir_output}"/>
<manifestclasspath property="jar.classpath"
jarfile="${dist_dir_output}/RulesEngine.jar">
<classpath refid="manifest.classpath"/>
</manifestclasspath>
<jar destfile="${dist_dir_output}/RulesEngine.jar">
<manifest>
<attribute name="Main-Class" value="rules_engine.Main"/>
<attribute name="Class-Path" value=". ${jar.classpath}"/>
</manifest>
<fileset dir="bin"/>
</jar>
</target>
<target depends="init" name="build-project">
<echo message="[${ant.project.name}] Compiling ${ant.project.name}:
${ant.file}"/>
<javac
debug="true"
classpathref="compile.classpath"
srcdir="src"
destdir="bin"
debuglevel="${debuglevel}"
source="${source}"
target="${target}"
includeantruntime="false"
nowarn="on" deprecation="true" listfiles="true"
verbose="false">
<compilerarg value="-Xlint"/>
</javac>
</target>
<target name="build-subprojects">
<echo message="[${ant.project.name}] Building related projects"/>
<ant antfile="build.xml" dir="${DroolsGenericModel.location}"
inheritAll="false" target="jar"/>
<ant antfile="build.xml" dir="${DroolsATCModel.location}"
inheritAll="false" target="jar"/>
<ant antfile="build.xml" dir="${DroolsUtils.location}" inheritAll="false"
target="jar"/>
<ant antfile="build.xml" dir="${FaaModel.location}"
inheritAll="false" target="jar"/>
<ant antfile="build.xml" dir="${VacModel.location}" inheritAll="false"
target="jar"/>
<ant antfile="build.xml" dir="${DroolsClient.location}" inheritAll="false"
target="jar"/>
<ant antfile="build.xml" dir="${DroolsFaaUtils.location}"
inheritAll="false" target="jar"/>
</target>
So, do you think it is feasible to accomplish what is above with scons? (
I don't want the solution, just tell me Custom Builder needed, or an
alternative etc etc...)
*Question 2:*
One of the subproject above, (FaaModel), has a build.xml that generates a
java file (Commands.java). One of our java project needs that file. This
dependency is written as follow :
<target name="genCmdIdClass">
<echo message="[${ant.project.name}] Generating ${enumPath}"/>
<delete file="${enumPath}"/>
<exec dir="${basedir}" executable="perl" output="${enumPath}">
<arg line="${RulesEngine.location}/../common/header2java.pl"/>
<arg line="../../../../../fwk/systemInterface/simnet/src/pbs_api.h"/>
<arg line="adacel.model.atc.simulation.faa"/>
<arg line="VoiceRecognitionMsgType_en"/>
<arg line="${enumName}"/>
</exec>
<sleep seconds="2"/>
<echo message="[${ant.project.name}] ${enumName} generated"/>
</target>
<target depends="init, genCmdIdClass" name="build-project">
<echo message="[${ant.project.name}] Compiling ${ant.project.name}:
${ant.file}"/>
<javac debug="true" nowarn="off" deprecation="true"
listfiles="true" debuglevel="${debuglevel}" destdir="bin"
source="${source}" target="${target}" includeantruntime="false">
<src path="src"/>
<classpath refid="DroolsModel.classpath"/>
<compilerarg value="-Xlint"/>
</javac>
</target>
As you can see, we are expressing a dependency to a file generated by a
perl script. Then again, is is possible to accomplish this with scons? I
see only one alternatives :
1. In my SConscript file.
1. With scons *Command*, call perl script that generates
Commands.java file
2. Put as *source *Commands.java when invoking scons *Java*
Is it the way I should accomplish this, or there is another alternative?
*Question 3:*
Our build.xml file copy jar files. See :
<!-- Copy all required libraries to run the jar -->
<target name="copy-lib">
<echo message="Copying required libraries to ${lib.dir}"/>
<delete dir="${lib.dir}"/>
<mkdir dir="${lib.dir}"/>
<copy file="${common.io.lib}/commons-io-2.4.jar"
todir="${lib.dir}"/>
<copy file="${common.lang.lib}/commons-lang3-3.1.jar"
todir="${lib.dir}"/>
<copy file="${common.collection.lib}/commons-collections4-4.0.jar"
todir="${lib.dir}"/>
<copy file="${common.cli.lib}/commons-cli-1.2.jar" todir="${lib.dir}"/>
<copy file="${junit.lib}/junit-4.8.2.jar" todir="${lib.dir}"/>
<copy todir="${lib.dir}">
<fileset dir="${drools.lib}">
<include name="*.jar"/>
</fileset>
</copy>
<copy file="${dds.lib}/dcpssaj.jar" todir="${lib.dir}"/>
<copy file="${jars.lib}/dds-interface.jar" todir="${lib.dir}"/>
<move file="${DroolsGenericModel.location}/DroolsGenericModel.jar"
todir="${lib.dir}"/>
<move file="${DroolsATCModel.location}/DroolsATCModel.jar"
todir="${lib.dir}"/>
<move file="${DroolsUtils.location}/DroolsUtils.jar"
todir="${lib.dir}"/>
<move file="${DroolsClient.location}/DroolsClient.jar" todir="${lib.dir}"/>
<copy file="resources/droolsConfig.properties" todir="${config_dir_output}"
overwrite="true"/>
</target>
I guess I will do this with *Install*?
*Questions 4:*
Devs here would like to know if there is an integration with Netbeans or
Eclipse? I found documentation about visual studio in scons page, but
nothing about Eclipse and/or java.
----------
Thank you very much
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20161018/5abf5cee/attachment-0001.html>
More information about the Scons-users
mailing list