BlackBerry: create COD from JAR source file in Ant script - blackberry

How do I use Ant (bb-ant-tools) to compile a JAR file into a COD? i.e. with no other source files
Reason
Ultimately, I need a script that is going to run Jar Jar Links (jarjar) during the build, to get around the namespace issues of using our sdk in multiple apps. Jarjar takes a JAR file as input, and I presume it outputs a JAR file.
So to run jarjar in a bb-ant-tools build, I need to know how to compile that output JAR into a COD.
I am focusing on just this part of the issue to minimise other possible sources of error. I will attempt the jarjar step once I can master building a JAR into a COD.
Progress
1) I can build my project into a working COD, sign and run on device.
2) To include the sdk code, I currently add the source folders to the main project build. (In the future I would like to know how to include the library into the build as a JAR - BlackBerry - Ant script to include JAR in project without external dependancies)
3) Output of this step includes the usual files:
MyApp.cod (if I sign this, it runs perfectly on device)
MyApp.csl
MyApp.cso
MyApp.debug
MyApp.jad
MyApp.jar (I want to run jarjar on this)
MyApp.rapc
4) I tried to run a 2nd build, taking the above JAR file and using it as the only source file in the rapc call. I do this by pointing the src tag of rapc at a folder containing only my JAR file.
In the final part of the build, when rapc is adding the files, I get the error:
java.util.zip.ZipException: duplicate entry: MyApp-1.cod
(full details of error below in edited build output)
I can see that this is the 2nd time that rapc tries to add this file. I do not understand why, since there is only one copy of that file in the JAR.
Build Output (edited with ...etc to make it readable )
build:
[mkdir] Skipping C:\development\ant\new_test\MyApp\build because it already exists.
[copy] Copying 1 file to C:\development\ant\new_test\MyApp\build
[copy] Copying C:\development\ant\new_test\MyApp\icon.png to C:\development\ant\new_test\MyApp\build\icon.png
[rapc] Compiling 1 source files to MyApp.cod
[rapc] Executing 'C:\Java\jdk1.6.0_24\jre\bin\java.exe' with arguments:
[rapc] '-classpath'
[rapc] 'C:\Java\jdk1.6.0_24\lib\tools.jar;C:\development\tools\bb-jde\jde5.0\components\bin\rapc.jar'
[rapc] 'net.rim.tools.compiler.Compiler'
[rapc] '-verbose'
[rapc] 'import=C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar'
[rapc] 'codename=MyApp'
[rapc] 'MyApp.rapc'
[rapc] '#sources.txt'
[rapc]
[rapc] The ' characters around the executable and arguments are
[rapc] not part of the command.
[rapc] Setting environment variable: PATH=........etc
[rapc] Reading resource: MyApp.cod
...etc
[rapc] Parsing classfile: com/MyApp/ui/views/WelcomeBar.class
...etc
[rapc] Parsing import: C:\development\tools\bb-jde\jde5.0\components\lib\net_rim_api.jar(net_rim_amms.cod)
...etc
[rapc] Resolving
...etc
[rapc] Optimizing
[rapc] Utilities.java:449: Warning!: local variable(s) { finished } initialized but not used in: com.cobi.library.Utilities.split(String,String)
...etc
[rapc] Populating
[rapc] Invoking: jar -cfmv C:\development\ant\new_test\MyApp\build\MyApp.jar C:\Users\Richard\AppData\Local\Temp\rapc_598c0c5a.dir\META-INF\MANIFEST.MF MyApp.cod MyApp-1.cod MyApp-2.cod MyApp.csl MyApp.cso -C C:\Users\Richard\AppData\Local\Temp\rapc_598c2ad7.dir .
[rapc] added manifest
[rapc] adding: MyApp.cod(in = 63208) (out= 41042)(deflated 35%)
[rapc] adding: MyApp-1.cod(in = 75448) (out= 42559)(deflated 43%)
[rapc] adding: MyApp.csl(in = 91) (out= 69)(deflated 24%)
[rapc] adding: MyApp.cso(in = 157) (out= 93)(deflated 40%)
...etc - adding all files I can see in the JAR...
[rapc] adding: MyApp-1.cod
java.util.zip.ZipException: duplicate entry: MyApp-1.cod
[rapc] at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:175)
[rapc] at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:92)
[rapc] at sun.tools.jar.Main.addFile(Main.java:713)
[rapc] at sun.tools.jar.Main.create(Main.java:466)
[rapc] at sun.tools.jar.Main.run(Main.java:180)
[rapc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[rapc] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[rapc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[rapc] at java.lang.reflect.Method.invoke(Method.java:597)
[rapc] at net.rim.tools.compiler.c.e.if(Unknown Source)
[rapc] at net.rim.tools.compiler.c.e.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.compile(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.main(Unknown Source)
[rapc] java.io.IOException: jar command failed: jar -cfmv C:\development\ant\new_test\MyApp\build\MyApp.jar C:\Users\Richard\AppData\Local\Temp\rapc_598c0c5a.dir\META-INF\MANIFEST.MF MyApp.cod MyApp-1.cod MyApp-2.cod MyApp.csl MyApp.cso -C C:\Users\Richard\AppData\Local\Temp\rapc_598c2ad7.dir .
[rapc] at net.rim.tools.compiler.Compiler.a(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.a(Unknown Source)
[rapc] at net.rim.tools.I/O Error: jar command failed: jar -cfmv C:\development\ant\new_test\MyApp\build\MyApp.jar C:\Users\Richard\AppData\Local\Temp\rapc_598c0c5a.dir\META-INF\MANIFEST.MF MyApp.cod MyApp-1.cod MyApp-2.cocompiler.Compiler.compile(Unknown Source)
[rapc] at net.rim.tools.compiler.Compiler.main(Unknown Source)
[rapc] d MyApp.csl MyApp.cso -C C:\Users\Richard\AppData\Local\Temp\rapc_598c2ad7.dir .
BUILD FAILED
C:\development\ant\new_test\MyApp\build.xml:65: Java returned: -1
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:111)
at ca.slashdev.bb.tasks.RapcTask.executeRapc(RapcTask.java:583)
at ca.slashdev.bb.tasks.RapcTask.execute(RapcTask.java:401)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:809)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 9 seconds
C:\development\ant\new_test\MyApp>
Workaround
Esaj has a good answer below that runs the Ant replace task on the source code before doing the compile. This means that there is no need to run jarjar on any resulting JAR file to solve the namespace problems.
This will work for me, as I have the SDK source code. It will not work for my clients, because I distribute my SDK in JAR format. So I'm still hoping for an answer to this question as it stands.
Related
This is a duplicate of [ How to convert JAR FILE to COD file using Ant Build ] but that question has not been answered, and I have added more detail.
This is not a duplicate of:
[ Convert a .jar file into a .cod file using bb-ant ] - I have used the accepted answer, and my error is different.
[ BlackBerry - Ant script to include JAR in project without external dependancies ] - this question is about adding the library in as a JAR instead of using the source code as I do above. In a way, it is a precursor step, as its output would still need to be run through jarjar.

Copying this answer from BlackBerry - Ant script to include JAR in project without external dependancies as per #RichardLeMesurier's request:
I had a similar problem last year, I had created a "framework" that was used as a base for multiple BB-applications, but run into problems with multiple CODs (I don't remember exactly what, something like the device refused to install multiple applications that had same external cods, if the external CODs weren't installed separately first, and then the applications). As the applications could be installed separately (one person might install only app A, another might install only app B, and yet another might install both A and B), the whole framework needed to be included in all the apps using it. I cooked up this Ant-script using bb-ant-tools (hopefully I didn't break anything removing some stuff specific to our apps and obfuscating package names etc):
<?xml version="1.0" encoding="UTF-8"?>
<project name="${description}" default="build" basedir=".">
<taskdef resource="bb-ant-defs.xml" classpath="lib/bb-ant-tools.jar" />
<!-- rapc and sigtool require the jde.home property to be set -->
<!-- NOTE: You may need to copy the signature files from Eclipse\plugins\net.rim.ejde\vmTools to the components\bin -dir
if the keys were installed using the Eclipse-plugin -->
<property name="jdehome" value="C:\BB\Eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components" />
<!-- Framework source locations, these must be set correctly -->
<property name="frameworkRes.dir" value="C:\BB\workspace\BB_Framework\res" />
<property name="frameworkSrc.dir" value="C:\BB\workspace\BB_Framework\src\com\whatever\frame" />
<!-- Locations for simulator, binaries, jde home, don't touch these -->
<property name="simulator" value="${jdehome}\simulator" />
<property name="bin" value="${jdehome}\bin" />
<property name="jde.home" location="${jdehome}" />
<!-- directory of simulator to copy files to -->
<property name="simulator.home" location="${simulator}" />
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="temp.dir" location="C:\tempsrc" />
<!-- Project specific -->
<!-- Application title -->
<property name="app.title" value="Application Name" />
<property name="app.version" value="1.0.0" />
<!-- Value to prepend before frame-class packages -->
<property name="frame.prefix" value="appname" />
<!-- Name of the COD to produce -->
<property name="cod.name" value="Appname" />
<target name="build">
<mkdir dir="${build.dir}" />
<delete dir="${temp.dir}" />
<mkdir dir="${temp.dir}" />
<mkdir dir="${temp.dir}\${frame.prefix}" />
<copy toDir="${temp.dir}">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
</copy>
<copy toDir="${temp.dir}\${frame.prefix}">
<fileset dir="${frameworkSrc.dir}">
<include name="**/*.java" />
</fileset>
</copy>
<copy toDir="${temp.dir}\res">
<fileset dir="${frameworkRes.dir}">
<include name="**/*" />
</fileset>
</copy>
<copy toDir="${temp.dir}\res">
<fileset dir="res">
<include name="**/*" />
</fileset>
</copy>
<!-- This replaces the package names for classes copied from under
framework-directory to ${frame.prefix} -directory as well as changing any
imports using the classes in framework-package -->
<replace dir="${temp.dir}" value="${frame.prefix}">
<include name="**/*.java"/>
<replacetoken>com.whatever.frame</replacetoken>
</replace>
<rapc output="${cod.name}" srcdir="${temp.dir}" destdir="${build.dir}">
<jdp title="${app.title}"
version="${app.version}"
vendor="Your Company"
icon="../res/img/icon.png"
/>
</rapc>
</target>
<target name="sign">
<sigtool codfile="${build.dir}/${cod.name}.cod" />
</target>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="load-simulator" depends="build">
<copy todir="${simulator.home}">
<fileset dir="${build.dir}" includes="*.cod,*.cso,*.debug,*.jad,*.jar" />
</copy>
</target>
</project>
What this does, is copy all the java-files and resources from your current project and then from the framework-project to a temporary directory, replacing package names on the way for the frame-work files (as they're put into a separately named directory), this has to do with the fact that the devices also refused to install multiple applications that had same classes under same packages (namely, the framework classes, for your case this might not be necessary). After the copying and replacing is done, the application is built to target build-directory using rapc. There are separate tasks for signing, cleaning and loading the app to a simulator. Hope this helps.

From your console output, the command that is failing:
jar -cfmv C:\development\ant\new_test\MyApp\build\MyApp.jar C:\Users\Richard\AppData\Local\Temp\rapc_598c0c5a.dir\META-INF\MANIFEST.MF MyApp.cod MyApp-1.cod MyApp-2.cod MyApp.csl MyApp.cso -C C:\Users\Richard\AppData\Local\Temp\rapc_598c2ad7.dir .
Looking up those options in the jar tool documentation:
-C dir
Temporarily changes directories (cd dir) during execution of the jar command while processing the following inputfiles
argument. Its operation is intended to be similar to the -C option of
the UNIX tar utility.
Based on that, I think rapc is putting the unpacked cod file in C:\Users\Richard\AppData\Local\Temp\rapc_598c2ad7.dir and that is causing conflicts with the cod files specified on the command line. Is that directory still around? Look inside to see what's there.

To answer my own question with some details...
One must not call rapc multiple times - it will create too many COD files. That is why I was getting that error.
Following up from Michael's answer, the correct way to proceed is to build the final JAR file using the normal java tools (javac & jar) as well as RIM's preverify command.
Only use rapc for the last step - converting that JAR file into a COD.
A full ANT build framework to deal with this problem is too big to place here, but the steps needed to create it are listed below. Each of the steps can be easily researched on this site (or with some google). Each step is very simple, and can be debugged individually.
Steps:
javac the SDK to create CLASS files
preverify the CLASS files
jar the SDK
Copy the SDK JAR file into the project
javac the project - use the SDK JAR as the classpath
preverify the project CLASS files (again, use the SDK JAR in the classpath)
jar the project - add the SDK JAR as a zipfileset
jarjar this project JAR to refactor package names as required
Finally, run rapc on this JAR - it will find no duplicate COD files & should run fine.
Note: Steps 1-3 can be combined by just using rapc on the SDK (which is needed if you need to run preprocessor tags on the SDK code).
By breaking it down into simple steps like this, I learnt how the normal java tools link into RIM's toolchain (normally this is all hidden when you simply invoke rapc on a source folder).
Of course, you still need to sign the COD with the sigtool.
I do all of this in ANT. I use a different folder to store the output from each step as I go. This way I end up with 5 temp folders at the end, but it made it easy to debug the steps as I go.
I finally understand now why so few people were able to offer conclusive answers to my various BB ANT build script questions. The process is laborious and very long, and hard to explain.
A full ANT build framework to accomplish this can stretch over many different files (in my case I think I'm now using 8 including property files). And it requires a good working knowledge of ANT, normal java build tools, and RIM's rapc command.
I think I have documented each step of the process quite well in my questions about this, and picked up some great answers along the line. For more details, have a look at those other questions & answers. Each one contains useful links, and some good insight from the other developers in this community

Related

Converting ANT build for Java 8 non-modular project to Java 11 modular project with non-modular dependencies

Trying to convert a Java 8 project to use modules in Java 11.
We created the module.info file in Eclipse and everything is compiling fine within Eclipse. But we’re having problems setting up the build which uses ANT (v 1.10.12).
Our code being compiled will be in a module, but it depends on non-modular jar files so it needs to create automatic modules for those jars from my understanding.
But the build keeps failing.
The module.info file looks something like the following where it requires externalclient which should be an automatic module created from non-module jar externalclient.jar
`module project.ourmod {
exports com.projectname.client;
requires externalclient;
}`
Our source code resides in
productpath/src/main/java
And the externalclient.jar resides in
projectpath/lib/main/java
The .classpath that Eclipse creates (and compiles just fine) looks like
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="lib/main/java/externalclient.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
The ANT build target to compile uses javac which we tried to modify to handle building now as a module and looks like the following.
<path id="classpath.junit">
<pathelement location=“projectpath/lib/main/java/externalclient.jar"/>
</path>
<echo>Compiling project client code ...</echo>
<tpcr.javac
ldestdir="projectpath/bin"
srcdir=“projectpath/src/main/java"
modulepath="${classpath.junit}"
listfiles="${compiler.verbose}"
encoding="UTF-8"
optimize="${compiler.optimize}"
debug="${compiler.debug}"
debuglevel="${compiler.debuglevel}">
<include name="com/projectname/client/**”/>
<compilerarg line="--add-modules externalclient"/>
</tpcr.javac>
We tried using but it wasn’t finding the java files to compile. Using srcdir it does see the files however when it tries to compile them we get the following error.
[echo] Compiling project client code ...
[tpcr.javac] Compiling 278 source files to projectpath/bin
[tpcr.javac] projectpath/src/main/java/module-info.java:28: error: module not found: externalclient
[tpcr.javac] requires externalclient;
[tpcr.javac] ^
[tpcr.javac] error: cannot access module-info
[tpcr.javac] cannot resolve modules
[tpcr.javac] 1 errors
We thought that specifying the path holding the externaclient.jar file in would handle making it an automatic module, but doesn’t seem to be working. Seems like we’re still missing something.
NOTE: Renamed the files and directories…so might be some typos…just trying to get the main setup across.

ojdeploy - ant task compile application

I am trying to use ojdeploy to compile and build an ADF application through an AntTask.
The ojdeploy task works fine when I specify not to compile the project by adding the line
The ojdeploy task is unable to find several jars required to build the application which I have specified.
I can't find any documentation which describe the use of the ojdeploy to compile applications which makes me think that it does not work.
The ant task I have is below. My thoughts are that the ojdeploy task does not have the jars required to build the project on its classpath. I can't see a way to add these jars to the classpath however.
ojdeploy task:
<target name="deploy" description="Deploy JDeveloper profiles">
<property name="status" value="${env.WORKSPACE}/deploy/ojdeploy-statuslog.xml"/>
<taskdef name="ojdeploy"
classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask"
uri="oraclelib:OJDeployAntTask"
classpathref="classpath"/>
<ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask"
executable="${env.oracle.middleware}/jdeveloper/jdev/bin/ojdeploy.exe"
failonerror="true"
ora:buildscript="${env.WORKSPACE}/deploy/ojdeploy-build.xml"
ora:statuslog="C:/Oracle/Middleware/ojdeploy-statuslog.xml">
<ora:deploy>
<ora:parameter name="workspace"
value="${env.WORKSPACE}/JWS.jws"/>
<ora:parameter name="profile"
value="*"/>
<!--<ora:parameter name="nocompile" value="true"/>-->
<ora:parameter name="outputfile"
value="${env.WORKSPACE}/deploy/${deployment.profile.name}"/>
</ora:deploy>
</ora:ojdeploy>
</target>
Resolved.
ojdeploy uses the jws and jpr files to find the libraries required. The jpr file was missing several JDeveloper/ADF libraries which JDeveloper is able to resolve.
However for ojdeploy to work ALL the libraries and dependencies are required to be in the jws/jpr file accordingly using the libraries/classpath and dependencies options.

Cannot run program "C:\Program Files\Java\jdk1.6.0_24\jre\bin\java.exe": CreateProcess error=87, The parameter is incorrect

I am trying to build a web application using Ant.
I am using JUnit and Cobertura for code coverage. Junit is only for DAO testing.
When i run build it compiles everything and before my JUnit runs i am calling cobertura.instrument which calls cobertura-instrument.
I am getting following error
[cobertura-instrument] The jvmargs attribute is deprecated. Please use nested jvmarg elements.
[cobertura-instrument] java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.6.0_24\jre\bin\java.exe": CreateProcess error=87, The parameter is incorrect
[cobertura-instrument] at org.apache.tools.ant.taskdefs.Java.fork(Java.java:798)
[cobertura-instrument] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:214)
[cobertura-instrument] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[cobertura-instrument] at net.sourceforge.cobertura.ant.InstrumentTask.execute(InstrumentTask.java:199)
[cobertura-instrument] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[cobertura-instrument] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[cobertura-instrument] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[cobertura-instrument] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[cobertura-instrument] at java.lang.reflect.Method.invoke(Method.java:597)
I googled and found out it says
The maximum command line length for the CreateProcess function is 32767 characters. This limitation comes from the UNICODE_STRING structure
My Ant code for cobertura-instrument
<target name="coverage.instrument" depends="coverage.init,ztest.copy">
<delete file="${basedir}/cobertura.ser"/>
<cobertura-instrument todir="${coverage.instrument.dir}" maxmemory="1024M" datafile="${basedir}/cobertura.ser">
<fileset dir="${model.output.dir}">
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
</target>
I dont see any way that i can solve this.
Anyone help me in this issue ?
As an alternative to specifying each and every class file, which will be the result of a <fileset>, try using <instrumentationClasspath> as documented here: http://cobertura.sourceforge.net/anttaskreference.html. This would reduce the command line length considerably.

Suddenly can't run TestNG tests from ant ([testng] Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException)

I am using ant and TestNG 6.1.1, and I had my tests working just fine yesterday. Today when I try to run the tests I get a NoClassDefFoundError involving com/beust/jcommander/ParamException. Here is the output:
[copy] Copying 1 file to /Users/djohnson/src/webapp/components/build/tmp
[testng] Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
[testng] Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException
[testng] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[testng] at java.security.AccessController.doPrivileged(Native Method)
[testng] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[testng] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[testng] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[testng] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[testng] The tests failed.
Here is the .xml file I'm using:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Single Method Suite">
<test name="Single Method Test">
<classes>
<class name="DhcpTest">
<methods>
<exclude name=".*" />
<include name="setGetEnabledTest" />
</methods>
</class>
</classes>
</test>
</suite>
I've also specified the complete path for the class with no luck. I've checked the classpath and everything seems fine, does anyone have any ideas on this?
If you're using ant, JCommander should be inside testng.jar, so I'm thinking your testng.jar file might be corrupt.
If your using Maven try adding this to your pom.xml
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.30</version>
</dependency>
jcommander.jar (e.g. jcommander-1.29.jar) should be present on fileset directory which is mentioned at build.xml
You can download it from: http://mvnrepository.com/artifact/com.beust/jcommander/1.27
OR,
JCommander should be inside testng.jar during using ant. Your testng.jar file might be corrupted, so please replace old testng.jar by new one.
May be testng.jar is not in classpath.
I had this same problem with a non-Maven project. I retrieved the testng jar from Maven Central, but it didn't contain all of TestNG's dependencies. Downloading the jar directly from the TestNG site resolved the issue, as it contains the dependencies.
I should have paid more attention to the directions on TestNG's download page...
The latest version of TestNG can be downloaded from Maven Central or here for ant users.
The problem here is that certain versions of the testNG jar do not have the jcommander jar code inside of them. As a result, you have to add the classpath to the Jcommander jar separately.
Adding the Jcommander jar to your classpath when you run it will fix the problem, hopefully
My ant start working when I have downloaded jcommandar jar from
Maven repository and added it in my jar file
But This problem
Starts coming with testng 6.8.5 version

Flex 4 swc size smaller compiled by FlashBuilder than using ANT

I'm trying to figure out why when I compile my Flex 4 Library swc using a simple ANT tasks, it compiles to about three times the size of the swc that's compiled by FlashBuilder.
Here is my ANT script to compile my swc
<target name="compileSWC" description="compiles the Library">
<echo>Compiling Library SWC To Deploy SWC Folder</echo>
<compc debug="false
output="${bin.dir}/${Library.name}-${timeVersion}.swc"
incremental="true"
optimize="true"
headless-server="true"
verbose-stacktraces="true"
default-frame-rate="24">
<source-path path-element="${src.dir}" />
<include-sources dir="${src.dir}" includes="*"/>
<source-path path-element="${src.dir}" />
<compiler.library-path dir="${basedir}/" append="true">
<include name="${library.dir}" />
</compiler.library-path>
</compc>
<echo>Compiled Library SWC To Deploy SWC Folder</echo>
</target>
This yields a swc that is 1,980 KB. This library file has custom components, some skins and images, so I was ok with the file size. But when I use the FlashBuilder to link my Library project to other Flex projects, the compiled swc is only 532 KB.
I am able to move the FlashBuilder compiled swc to any project and it works just fine.
So I'm wondering what is FlashBuilder doing different than my ANT build script to get that file size down? I tried adding 'static-link-runtime-shared-libraries="true"' to my ANT script, but I had the same results.
Thanks.
Have you tried spitting out the config from the FB compile and using that in the ant task? You can use the compiler option
-dump-config fb_config.xml
And then use the load-config tag to pull it into your ant task.
Here's a KB article that runs through it: http://kb2.adobe.com/cps/404/kb404341.html
Hope that helps,
Ruprict
Don't know why but after loading my configuration the compiler is whining about the compiler.extensions, it says is an unknown configuration variable, here's the stack:
Buildfile: C:\Users\cgascons\Documents\workspace\TCGEngine\build.xml
generateAssets:
[echo] Target::generateAssets
compile:
[echo] Target::compile
[mxmlc] Unknown:compiler.extensions
[mxmlc] Loading configuration: C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml
[mxmlc] C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml:8
[mxmlc] Warning: 'compiler.accessible' is not fully supported.
[mxmlc] <accessible>false</accessible>
[mxmlc] C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml:49
[mxmlc] Error: unknown configuration variable 'compiler.extensions'.
[mxmlc] C:\Users\cgascons\Documents\workspace\TCGEngine\ant_config.xml (line: 49)
[mxmlc] <extensions>
BUILD FAILED
C:\Users\cgascons\Documents\workspace\TCGEngine\build.xml:18: mxmlc task failed
Does anybody know what could be happening here?

Resources