Increasing maxHeap arg for Findbugs in Jenkins - ant

I am running Findbugs with Ant with the <findbugs> task. I am running the Ant build.xml from Jenkins.
My build is stuck on low heap size : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space.
I have read that I need to run Findbugs with -maxHeap n where n is the size (defaults to 256).
Since I am running Findbugs with Ant and running Ant from Jenkins, I don't really know where to pass this parameter. My options are :
Java Options in Jenkins Ant build step where I usually put parameters like -Xmx1024m -Xms512m etc...
As a jvmargs attribute to <findbugs> task in build.xml file.
I'm not exactly sure how to pass this parameter.

-maxHeap n is a parameter of the findbugs command line wrapper script and can only be used there.
To set the heap size from an ant script use the jvmargs attribute. So your second option should work. For example:
<findbugs output="xml" outputFile="..." jvmargs="-Xmx256m">
...
</findbugs>

Related

How to override user.home property of ant from Jenkins server?

Hi I need some help in overriding the user.home property of ant from Jenkins. I created a simple job on jenkins that runs a build script on a slave machine of the master. One of the tasks of the scripts is to use the user.home property of ant and access certain files. The problem is that when I try to echo this property from the command line of the slave machine, I see C:\Users\Administrator but when I run the exact the same script from the Jenkins server I see C:\ . This difference is causing the build to fail on Jenkins. Can anyone please tell me what is the reason for this difference? Is there any way I can override this?
I tried having a property called user.home in the config file of my job but it doesn't seem to pick it up. Another interesting point is that when I changed the user.home value to some gibberish in the config file and run ant from command line on the slave, it still picks it up as C:\Users\Administrator
I am using ant 1.7.1 and Jenkins 1.598
You likely have jenkins running as a different ID than Administrator. Which is a good thing.
Properties in ant are immutable so you can specify those properties from the ant plugin in jenkins and they'll override any other values. (click advanced under the invoke ant buildstep to see the properties text box).
I'd recommend you not override user.home but rather refactor your ant so there is a config.location property that defaults to user.home but can be overidden to whatever you want from jenkins. It just seems unnatural to ovrride user.home

Increasing permgen space for Cobertura ant task running from Gradle

I'm getting the following trying to run Cobertura as part of my Gradle build.
:cobertura
Instrumenting classes for Cobertura
Exception in thread "Test worker" java.lang.OutOfMemoryError: PermGen space
java.lang.OutOfMemoryError: PermGen space
I've tried bumping up DEFAULT_JVM_OPTS/-XX:MaxPermSize in my gradle wrapper script, to no effect. Is there a more direct (and effective) way to do this?
The only thing that worked for me was changing the .bashrc on my Linux box to have export _JAVA_OPTIONS='-XX:MaxPermSize=512m'
Proof that this got detected by gradle when I built was shown with this message:
Picked up _JAVA_OPTIONS: -XX:MaxPermSize=512m
Try to set a GRADLE_OPTS environment variable, or a org.gradle.jvmargs property in gradle.properties.

Ant java task NoClassDefFoundError

I want to make a simple ant build hibernate test project.
There is no error during the compilation and the build (jar).
But when I run it I get this:
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration ...
I have found an advise, what said : jars should be added to classpath in the command line, (classpath is ignored when the jar run from ant ... ehh), ok I tried the following:
java -jar dist/student.jar -cp /home/myname/workspace/basic_ant1/lib/hibernate/hibernate-core-4.2.8.Final.jar
But still have the some error :NoClassDefFoundError ...
What did I wrong ?
Thanks for the replies in advance.
(org.hibernate.cfg is in hibernate-core-4.2.8.Final.jar)
Cs.
-jar and -cp are mutually exclusive.
If you want to use java -jar then your main JAR file needs a Class-Path entry in its manifest that points to all the other jars its Main-Class requires (the manifestclasspath task is a handy way to generate this value).
If you use java -cp then you have to give the main class name on the command line, the Main-Class from the manifest is ignored.

ivy ignores ANT_OPTS and -D variables when running from intellij idea

I set environment variable in ANT_OPTS in Windows:
-Duser.home=C:/Projects;-Divy.default.ivy.user.dir=C:/Projects/ivy
and specified two ant variables in Ant properties window in Intellij Idea
user.home C:/Projects
ivy.default.ivy.user.dir C:/Projects/ivy
But when I run ant tasks that works with ivy they use my profile home dir (at network dist) as a home dir for ivy repo and all settings are ignored.
In intellij's output I see that it passes
-Duser.home=C:/Projects/ -Divy.default.ivy.user.dir=C:/Projects/ivy
to ant.
Is it possible to fix it?
Thanks!

groovy ant task

I'm using the groovy ant task to compile my groovy files, but it seems like groovy locks the jar file so it can't be moved, deleted, signed, etc. Has anyone run into this bug before and have a workaround? Seems weird that if I run the groovy ant task and compile to a jar file that groovy doesn't release that jar file.
thanks,
Jeff
Does the file get released once the ant build is complete? If this is the case try setting fork="true" on the groovy task so that another JVM is created, rather than Groovy sharing Ant's JVM. This means once Groovy is complete the forked JVM will be disposed and the lock should be freed.
If the lock persists after the Ant build completes, could you provide a bit more detail on what you're doing with Groovy?

Resources