[Scons-users] replacing ant with java
William Blevins
wblevins001 at gmail.com
Wed Oct 19 13:00:20 EDT 2016
Pierre-Luc,
There are some factors to consider. SCons provides Java builders in the
default distribution, but the builders have a lot of restrictions, so I
have had difficulty in the past when porting from ANT -> SCons, but it is
doable; some of this is related to bugs in the Java toolchain which didn't
get appropriate community support.
Keeping this in mind, I recommend getting SCons working in parallel with
your ANT configuration first because you apparently have Java dependencies
that you are not accounting for (JNI stubs maybe?). This should be simpler,
and it will allow you to figure out your dependency tree before trying to
rewrite your Java build process.
In order to help you with debugging, look into the scons "--debug" options
or the dependency printers see "--tree" options.
When you get ready to convert your Java to SCons, I recommend reading the
User Guide Java section, and the scons tigris issues related to Java. This
will help you streamline your conversion. For example, items added to the
JAVACLASSPATH are not automatically added as dependencies. I would classify
this as a bug, but I can understand why this was not done historically.
V/R,
William
On Tue, Oct 18, 2016 at 9:29 PM, Pierre-Luc Boily <pierreluc.boily at gmail.com
> wrote:
> 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
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20161019/d8cfe280/attachment-0001.html>
More information about the Scons-users
mailing list