How do increase memory for the Ant 'Javadoc' task? - eclipse

When creating an ant build script to generate Javadoc, Eclipse is receiving an OutOfMemoryError.
The ant build has the -Xmx512m and -Xms512m settings under the JRE tab in the run configuration.
This works great for compiling the application.
The only trouble is with the Javadoc portion of the build. Here is the build.xml file
<target name="JavaDoc" description="Create Javadocs">
<javadoc destdir="c:/javadoc" windowtitle="My API">
<classpath refid="application.classpath" />
<packageset dir="Source">
<include name="**" />
</packageset>
</javadoc>
</target>
When the build script runs I see a 2 step process,
Eclipse launches
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner
Visual VM shows that this process launches with the Heap memory arguments listed above.
This process then spawns the 2nd process "JavaDoc" and the VM arguments are not passed along with it.
In VisualVM it can be confirmed that the JavaDoc process has a default -Xms8m value and around a 64m Xmx value before the OOM error is thrown.
Under the Ant preferences in Eclipse I have attempted to add an 'ANT_OPTS' variable to pass the JVM args to JavaDoc.
The change did not work.
The build does work if I create a batch file and set the ANT_OPTS values.
set ANT_OPTS=-Xms512m -Xmx512m
ant -file C:\myApp\build.xml JavaDoc
But creating the batch file is defeating the purpose of allowing me to build everything directly in Eclipse.
I have also tried adding an to the build file, which would hardcode a heap size
<arg value="ANT_OPTS=-Xms512m -Xmx512m" />
Any idea how to set the value so my javadoc will spawn with more heap size?

The javadoc task has the attribute maxmemory for specifying this. Allows you to separately tune for this task.

It is worth noting that apparently you can get an OOME on javadoc for another reason: see that other question : Out of memory error in ant

Related

Domino Designer Plugin Ant class path

I've build an osgi plug-in to wrap a jar files. I've been following this guide.
In the last step, I can´t “Build all” to generate the update site because an error said that couldn't find the ant classpath
Any idea?
Thanks
The version that i'm using is Release 9.0.1FP9
Revision 20170815.0729-FP9 (Release 9.0.1FP9)
Try running Ant on the command line to see the full output. Here is a GitHub project showing specifically how to run Ant tasks for Domino.
Here also are some details about setting the Ant classpath for a given build in build.xml:
<!-- create our ant classpath using the fileset task -->
<path id="class.path">
<!-- include all jars in the lib directory and all sub-directories -->
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
I find that Eclipse plugins often just assemble and execute terminal commands, but when they fail they tend not to be great at making clear the cause. Often, running the equivalent commands in the terminal (be they ant, maven, etc.) is clearer when failures occur because you'll see the full error output. And it gives you the added benefit--sometimes--of having a clearer understanding of what's happening under the hood.

eclipse: Ant property not accessable when running in separate JRE

I have setup an Ant runtime property in Preferences -> Ant -> Runtime -> Properties. It is named build.tools and has value ${workspace_loc:/ivd-build}
I have a build.xml with the following
<project name="myProject">
<target name="test">
<echo>"${build.tools}"</echo>
</target>
</project>
If I choose "Run in same JRE as workspace" I get (1)
[echo] "C:\Users\myuser\ws\seqflow-ivd\trunk\ivd-build"
If I choose "Separate JRE" I get (2)
[echo] "${workspace_loc:/ivd-build}"
So in the latter case the property is not resolved properly.
I would prefer the behavior of (1) but running in a separate JRE and I get this behavior on another machine. So I think it is some kind of setting somewhere, I just cannot find it.
Any suggestions?
Windows 7
Issue both seen with eclipse mars and neon.
Java 1.8u66
I have found the cause of the problem.
Besides the build.tools property I also have another property (other.tools) which is rarely used. The cases where build.tools could not be resolved was caused by the fact that other.tools could not be resolved. When I corrected or removed other.tools, then build.tools resolved correctly (as (1)).
This means that if you want to use the "Separate JRE" setting for your Ant job, you need to ensure that all properties can be resolved even if you do not use them from your Ant script.

Eclipse: Why is it eating my log4j.properties file?

Windows 7 Professional
Eclipse 3.7.2
I am migrating over to Eclipse from another IDE. I am compiling my project with the same ANT build.xml file I was using before. I do it by
highlighting my project in the project view
expanding the tree node
finding my build.xml file there
right clicking my build.xml file
choosing Run as > Ant Build
Works great, but every few builds Eclpise eats my log4j.properties file located at:
C:\AllProjects\Workspace\acme\war\WEB-INF\classes\log4j.properties
Eclipse basically eats all files in WEB-INF\classes that are not *.class files.
What am I doing to make this happen and how can I stop it?
Thanks
Since you're using ant instead of Eclipse to build, you could try turning off the setting to build the project automatically.
Select your project, then in the menu bar at the top of the screen, select Project and uncheck the Build Automatically option.
Edit: Second opinion
I would add an ant task to copy the log4j property file into your WEB-INF/classes folder every time you do a build. One nice advantage of this is that you can have a different property file for different build types (debug, release, etc.) and not worry about manually making changes to it. Also, this should make it easier to manage if you're using version control.
Copy your log4j.properties file to your source directory and add something like this to your ant build file:
<target name="copy-log4j-property-file">
<copy file="src/log4j.properties" todir="WEB-INF/classes" />
</target>
<target name="build" depends="copy-log4j-property-file">
<!-- the rest of your build things here -->
</target>
After selecting in Project explorer:
Properties > Java Compiler > Building > Output Folder
Uncheck "Scrub output folders when cleaning projects"
It is a solution for me ( though maybe not everyone ) because I use a time test ANT build.xml to do my compiling, building and cleaning for me. I just leave Eclipse's auto builds on so I get those nice error notifications as a I type, before I compile.

Error! The first argument to the non-static Java function 'replace' is not a valid object reference

I am trying to get ANT to create an HTML report of a JUNIT test in Eclipse but after I created the ANT build I get the following errors when I run it:
[junitreport] Processing C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml to C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\null785926900
[junitreport] Loading stylesheet jar:file:/C:/ANT/apache-ant-1.8.3/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
[junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
[junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process C:\Documents and Settings\Administrator\workspace\Home\junit\TESTS-TestSuites.xml
What do I need to do to fix this?
Here are the sections of my Build.xml I am trying to run:
<target name="Home">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="Home" todir="${junit.output.dir}"/>
<classpath refid="Home.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
When I got this error I had to right click on my build.xml file in Eclipse, choose the "Run as Ant build..." option (3rd one in the menu) then click the JRE tab and select the "Run in the same JRE as the workspace" option and then proceeded to run the script. For some reason this fixed the problem. I honestly don't know why.
The Eclipse Bug is clearly documented Bug 384757. The analysis suggests that Oracle introduced the bug. I need Java version 7 but JunitReport needs Java version 5 and early versions of Java version 6. The obvious way is to add the "bootclasspath" argument to the Ant junitreport task while the Java problem is fixed by Oracle in a future release. Unfortunately Ant task junitreport does not support the bootclasspath option. Is this something the people supporting Ant could do?
I met this situation while running my java program on Ubuntu 12.04 with *java 1.7.0_51* on Eclipse SDK Juno. I take Bhagyaraj's suggestion which is using apache-ant-1.9.2 instead.
(p.s. The default ant version of Eclipse Juno is *org.apache.ant_1.8.3*, and I use apache-ant-1.9.3)
You may following my steps to setup.
Download apache-ant-1.9.3-bin.zip and extract to a place where you want.
Open your eclipse and choose Window --> Preferences
You can see the Preferences window. On the left hand side please choose ant --> runtime
Now focus on right hand-site of the window. Make sure you are now on Classpath tab and choose Ant Home Entries(Default).The buttons on the right which is Ant Home... is now click-able.
No doubt, click on Ant Home... button and choose the folder where your ant-1.9.3 is. In this step, if you choose wrong folder, Eclipse may show the error message something like Specified Ant home does not contain a "lib" directory. If you choose the right directory, Ant Home Entries(Default) will become **Ant Home Entries()
Don't forget to click apply.
After change those, while you right click on build.xml file and choose Run --> 1 Ant Build, the error message won't show because your ant is now 1.9.3.
I also download apache-ant-1.8.4 to run my build file, but the error can't be solved.
I used the jdk1.6.45 and latest apache-ant-1.9.2-bin\
Problem solved.
As per note on MikeBach
This is bug#,
please read:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757
Fixed in Ant.
Regards,
Bhagyaraj
If you are using Eclipse/JUnit report with JDK 1.7, please use JDK 1.6. There is a bug in JDK 1.7 with Eclipse/JUnit report similar to what you describe. This may be a similar report: https://netbeans.org/bugzilla/show_bug.cgi?id=201022
I've tried using a few different JRE/JDK settings (all 1.6 and 1.7) with various problems (this or lack of access to XSL file in jar) for each.
It's not a perfect solution obviously but I don't seem to run into these issues if the JUnit report is "raw" in the buildfile -- not wrapped in a target.
Poor workaround obviously in that targets are an important aspect of Ant but sometimes for reporting build targets/dependencies aren't so mission critical. It's not so much of an issue for me yet because I'm running these reports in kindof a one-off fashion rather than as part of a build.
The Bug was introduced in Java 7u5 according to this comment.
Another comment explains how to workaround it, changing the bootclasspath. (DISCLAIMER: I didn't try and test this.)
This solution, however, worked fine for me:
Download ant-1.9.4
Eclipse>>Preferences>>Ant>>Runtime>>AntHomeEntries
Remove all 1.8.x classpath entries
Add all libs from 1.9.4 instead
According to Ant Changes, this has been fixed since 1.9.1

Specify memory for ant maven deploy task

I am using ant maven deploy task to upload the zip file created by the ant script to our repository, but the problem is the file is too big and it fails with
java.lang.OutOfMemoryError: Java heap space. Following is the task
<deploy uniqueversion="false">
<remoterepository url="${repository}" id="${repositoryId}"/>
<remotesnapshotrepository url="${snapshotRepository}" id="${snapshotRepositoryId}"/>
<attach file="target/${qname}-dist.zip" type="zip"/>
<pom file="pom.xml" groupid="com.my.company" artifactid="test" packaging="zip" version="${version}" />
</deploy>
How do I specify memory heap size here, I don't seem to find anything in deploy task or some of its children task.
Maven doesn't fork on the deploy task so to increase the memory, you have to increase the heap size for the maven executable itself. You can just set your MAVEN_OPTS environment variable to include the -Xmx setting: MAVEN_OPTS=”-Xmx512m”