compiling SQLJ with Ant - ant

How to compile SQLJ with ant?

I don't think there is a native sqlj Ant task. You can start an sqlj process with the Ant exec task as if you were executing it from a command prompt.
Edit:
Link to download sqlj: http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html

I haven't seen a proper task for compiling SQLj sources with Ant, however there is an old ant-user post where someone has submitted the source for an ant task.
I don't know how well it works, but it should at least point towards how it can be done.
From the Javadoc:
* Task to compile SQLj source files. This task can take the following
* arguments:
* <ul>
* <li>srcdir
* <li>destdir
* <li>compile
* <li>ser2class
* <li>user
* <li>url
* </ul>
* Of these arguments, the <b>srcdir</b> and <b>destdir</b> are required.
* <p>
* When this task executes, it will recursively scan the srcdir and dest
* destdir looking for sqlj files to compile. This task make its compile
* decision based on timestamp. Notice that the generated java files will
* be located at the same directory as the sqlj files, Only the binary files
* will be placed at the destdir directory.

Related

QMake / jom force extra MIDL compiler to run before RC

I'm converting an old OCX project to QMake (as it's getting the "new" standard in my company).
In my Button.pro file, I add the MIDL compiler by the means of
idl_c.output = $${DESTDIR}/${QMAKE_FILE_BASE}.tlb
idl_c.input = IDL
idl_c.commands = $${QMAKE_IDL} ${QMAKE_FILE_IN} $${IDLFLAGS} \
/tlb ${QMAKE_FILE_OUT}
idl_c.variable_out = GENERATED_FILES
idl_c.CONFIG += target_predeps
idl_c.name = MIDL
QMAKE_EXTRA_COMPILERS += idl_c
IDL += $$PWD/Button.odl
The .pro file also mentions that I have a RC file
RC_FILE += $$PWD/Button.rc
This RC file contains a TYPELIB for this tlb file, meaning that it has to be available before rc.exe runs
1 TYPELIB "Button.tlb"
I then generate a makefile through QMake and build my project using nmake. Everything runs fine: the console shows no error and the output OCX is generated (and works). I can clearly see that MIDL is executed first, the RC, then the rest.
If I try to build using jom, the order is not satisfied anymore. jom seems to try to execute MIDL and RC in parallel: Button.tlb is then not yet existing at the time RC.exe needs it and the build fails.
Is there a way to force jom to wait for midl to be done before starting rc?
I'm using QT 5.3.1 under MSVC2013.
QMake is nothing more than a makefile generator. And your issue is due to make (or jom) parallel job execution. To fix this you only have to induce a single dependency (w/o any recipe) in a Makefile between res/obj and tlb files. This could be done with:
dep_restlb.target = $(RES_FILE)
dep_restlb.depends = $${DESTDIR}/Button.tlb # QMAKE_FILE_BASE is not available here
QMAKE_EXTRA_TARGETS += dep_restlb

Custom Ant Task Not Working On Build Server

I've got a custom Ant task that I'm using successfully from gradle on my local machine:
task fetchRelMod {
doLast {
println 'Fetching the RelMod'
ant.taskdef(name:'relmod',
classpath:'retrievePBSInfo.jar:hsjt400-4-9.jar',
classname:"com.myco.ant.tasks.RetrievePBSRelModString")
ant.relmod(user:project.ext.props.getProperty('fetchrelmod.username'),
password:project.ext.props.getProperty('fetchrelmod.password'),
prodCode:project.ext.props.getProperty('profile.pbs.product.code'),
branch:project.ext.props.getProperty('profile.pbs.branch'),
state:project.ext.props.getProperty('profile.pbs.relmod.selector'))
project.ext.set('iseries_relmod',ant.relmodStub)
project.ext.set('iseries_relmodAndDate', ant.relmod)
}
}
I've got the jar files sitting next to build.gradle for now, out of simplicity... they exist in the same location on the build server. Works great locally. When I run my build from my build server (either through Jenkins or going on the box and running Gradle directly), I get the following:
sudo /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/gradle214/bin/gradle all -DisQUABuild=true
Building My App
Loading Properties files...
QUA Build. Using build-qua.props
:fetchRelMod
Fetching the RelMod
:fetchRelMod FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/MyApp/build.gradle' line: 141
* What went wrong:
Execution failed for task ':fetchRelMod'.
> taskdef class com.myco.ant.tasks.RetrievePBSRelModString cannot be found
using the classloader AntClassLoader[/var/lib/jenkins/workspace/myApp/hsjt400-4-9.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.104 secs
What concerns me is that there are two jar files in the classpath and it only mentions one in the error. Does anyone have any ideas as to what might be going on?

Need help after instrumenting the jar in EMMA

I am new to Code Coverage and EMMA tool.
I am trying to:
1. Write a simple java program "testClass1.java". Compile it, and a got a "testClass1.class" file.
2. I package this as a jar. "myJar.jar"
3. Instrument this jar using this emma command and got a coverage.em file
C:\Users\emahaboo\Desktop>java -cp emma-2.0.5312.jar emma instr -m overwrite -cp myJar.jar
EMMA: processing instrumentation path ...
EMMA: instrumentation path processed in 156 ms
EMMA: [1 class(es) instrumented, 0 resource(s) copied]
EMMA: metadata merged into [C:\Users\emahaboo\Desktop\coverage.em] {in 7 ms}he emma command.
Now I want to execute this "myJar.jar" file.
I am not sure, what should I do exactly here, because I get the below error:
C:\Users\emahaboo\Desktop>java -cp myJar.jar:emma-2.0.5312.jar myJar
Error: Could not find or load main class myJar
C:\Users\emahaboo\Desktop>java -cp myJar.jar:emma-2.0.5312.jar testClass1
Error: Could not find or load main class testClass1
Can someone help me to proceed. I want to successfully run this program and get the emma code coverage report.
On Windows, items on the classpath need to be separated with semicolons. I would put the whole parameter in quotes:
-cp "myJar.jar;emma-2.0.5312.jar"
If you want to execute a jar file, there must be a main class as the entrance. For the error "Error: Could not find or load main class...", it just means that it can't find the main class. I think the root cause for this is due to your second step: "I package this as a jar. "myJar.jar"". when you packaged it, you need to set the testClass1 as the main class for this jar file. Hope this helps.

Ant: failed to create task or type runtarget

I am running into the following error when trying to run ant:
Problem: failed to create task or type runtarget
I am building on a mac 10.8.3.
Prior research has suggested that I add ant-contrib-0.3.jar to my ANT_HOME installation directory, which I have done (that had actually gotten rid of another 'failed to create task or type' error)
I used ant-contrib-0.3.jar because research suggested that this jar is mapped to the line:
< taskdef resource="net/sf/antcontrib/antcontrib.properties" />
which is in the build.xml file I am using.
The project builds on windows machines ( I even got it to build using https://code.google.com/p/winant/ ) but am trying to get it built on a mac. I am thus not looking to change the build.xml file.
An example of the run target line is:
<target name="setPASProps" depends="" description="setup the properties">
<property name="systemname" value="PAS"/>
<runtarget target="setSystemProps"/>
</target>
Here is some info from running ant -diagnostics
-------------------------------------------
ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.8.2 compiled on June 20 2012
ant.java.version: 1.7
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: /usr/share/ant/lib/ant.jar
ant.home: /usr/share/ant
-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/ant
ant-antlr.jar (5756 bytes)
ant-contrib-0.3.jar (17708 bytes)
ant-jmf.jar (6745 bytes)
ant-junit.jar (102350 bytes)
ant-junit4.jar (7126 bytes)
ant-launcher.jar (12321 bytes)
ant-swing.jar (7563 bytes)
ant-testutil.jar (15198 bytes)
ant.jar (1937098 bytes)
Thanks !
It would be helpful if you posted your build.xml too.
You usually get this error if Ant sees a task, but there's a problem with the definition.
Here's my recommendation:
In your project create a directory antlib/ant-contrib.
Download this zip file. Ant-contrib is a wee bit strange is that there is a separate jar for C compiling and for all of the other Ant tasks. The latest version is 1.0b3. When you unzip this zip file, you will see ant-contrib-1.0b3.jar inside this folder.
Put that ant-contrib-1.0b3.jar inside the antlib/ant-contrib folder.
Now, in your build.xml, use the following <taskdef/>:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<fileset dir="${basedir}/antlib/ant-contrib"/>
</classpath>
</taskdef>
Make sure this is not inside a target. You want this to be executed before any targets are executed.
I like doing the definition this way because the Ant Contrib jar file becomes part of my project, and anyone who needs to run my project will not have to manually install the Ant Contrib jar before they can use my project.
Take a look at your build.xml and see where that <Runtarget> task is being used. I've never used it, and the documentation for this task is so clear and helpful. Actually, I'm not even sure if it works. If you are still having problems, you try to see if you can remove the defined <target/> that contains this task, and see if that gets rid of the issue.
Removed ant-contrib-0.3.jar and added ant-contrib-1.0b3.jar and ant-contrib.jar to my ANT_HOME directory since these are the jars installed with https://code.google.com/p/winant/ (and it was working on windows machines).
This did the trick.

scons: source directory does not get copied into build directory

Part of my build process is to create a tar file of an input directory, located at src/bundle/bundle. In src/bundle/SConscript:
Import('*')
bundleDir = Dir("bundle")
jsontar = Command("bundle.tar", bundleDir,
"/home/dbender/bin/mkvgconf $SOURCE $TARGET")
in my SConstruct:
SConscript(Split('src/bundle/SConscript'),
exports='bin_env lib_env', build_dir='tmp/bundle')
When attempting to build:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
/home/dbender/bin/mkvgconf tmp/bundle/bundle tmp/bundle/bundle.tar
Input directory tmp/bundle/bundle not found!
scons: *** [tmp/bundle/bundle.tar] Error 1
scons: building terminated because of errors.
Clearly scons is not copying the src/bundle/bundle to tmp/bundle/bundle, but I am stumped as to why.
Footnotes:
Using absolute pathname for mkvgconf is bad practice but just intermediate until I have this problem solved.
SCons doesn't know anything about the contents of your input src/bundle/bundle - only the program mkvgconf knows what it does with that directory.
One solution is to add an explicit dependency in the SConscript:
import os
Depends('bundle.tar', Glob(str(bundleDir) + os.path.sep + '*'))
That also means that when you update the contents of the bundle directory, the mkvgconf script will be rerun.
PS. you might want to change the build_dir argument name to variant_dir, as the former is deprecated in favor of the latter in recent SCons releases.

Resources