Domino Designer Plugin Ant class path - plugins

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.

Related

False Error Message in Eclipse for Ant Include Task

In my ant build I am including a second ant build file (build.xml):
<project name="Including" default="echoC" basedir=".">
<include file="build.xml" as="Included"/>
<target name="echoC" depends="Included.echoB">
<echo>C</echo>
</target>
</project>
build.xml is in the same directory as the including build file and everything is working fine actually. I can run the target echoC and also the target echoB from the included build file is executed first.
What is irritating however is that Eclipse is displaying the error message Target Included.echoB does not exist in this project in the Ant Editor. Does anybody know how to get rid of that?
Thanks a lot for your support!
This seems a bug in Eclipse according to https://bugs.eclipse.org/bugs/show_bug.cgi?id=412809. The comments suggest there is no support for the task in the editor.
Using the import task instead works fine.

Eclipse: Automatically run Ant scripts in sequent order

I am using Eclipse's Ant view to run my build files. I have to run a couple of files in a specific order and I wonder whether there is any possibility to automate this (I'm sure there is...). However, they need to run subsequently, i.e. script two may not start until script one finished successfully. Most of my Ant scripts trigger Maven commands.
Is there any Eclipse plugin or feature that can assist me in running my Ant files automatically? Maybe even shutdown and restart my Java EE server before and after building?
I'd like to double-click just once and have my toolchain work, while I... get myself another cup of coffee.
I can think of two options:
Write a wrapper Ant script/target that calls the others in the desired order. It's been a number of years since I wrote any Ant but I remember doing that, probably using the <ant> task. It might make sense to simply define a target that has dependencies/prerequisites in the right sequence (in conjunction with the <import> task to pull in the separate buildfiles). Here is a discussion about the difference between these two approaches.
Use Eclipse's External Tool feature to invoke a batch/shell script that calls each Ant target.
This is what I finally came up with:
<project default="all" basedir=".." name="Build all projects">
<property name="folder.project.a" value="MyProjectA" />
<property name="folder.project.b" value="MyOtherProjectB" />
<!-- Target to build all projects -->
<target name="all" depends="projectA, projectB" />
<target name="projectA">
<echo>Building project A.</echo>
<ant antfile="${folder.project.a}/my_build_file.xml" />
</target>
<target name="projectB">
<echo>Building project B.</echo>
<ant antfile="${folder.project.b}/my_other_build_file.xml" />
</target>
</project>

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.

Cleaning Deployment Assembly with Eclipse Plugin

When faced with the unenviable task of cleaning all generated project artefacts/resources in a stock-standard Java EE/Tomcat configuration, I generally do one (or all) of 3 things:
Project/Clean
Right-click my server, and delete any artefacts (can't remember the exact command)
Source/Clean
I'm now playing around with the Google Eclipse Plugin for Appengine, which uses an inbuilt Jetty server.
Firstly, the plugin doesn't have any options to clean out generated class files before redeploying (well, not that I can see anyway). And secondly, the sever is not available as a configuration option.
Are there any quick fixes available to clean all artefacts/resources in my war/WEB-INF directory?
You can easily make it about one click and not unenviable. Just use ant and pattern matching. Open the ant view in Eclipse and add your file and it's just a click away.
Before 1.7 when app size was more limited, I used to copy almost everything out so I could upload it and serve from the blobstore (GWT permutations galore!). I was doing this alot!!!
see these for details http://ant.apache.org/manual/Types/fileset.html and http://ant.apache.org/manual/Tasks/delete.html
Here's my simple code example:
<target name="moveXprojectGae">
<delete includeemptydirs="true">
<fileset dir="XprojectGae" includes="**/*"/>
</delete>
<move todir="XprojectGae">
<fileset dir="war/XprojectGae">
<exclude name="**.rpc"/>
<exclude name="**nocache.js"/>
</fileset>
</move>
</target>

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