Tuesday, May 18, 2010

JUnits in Ant

I have no problems running JUnits in Eclipse provided in the Ant baseline and there are plenty of JUnits, so I would not be setting precedent by creating a new one or adding to an existing one.

Antunit Script to Plug into JUnit Runner

I pulled down the Antunit source code and was unable to find anything that looked like a tool I could plug into JUnit Runner, although, I am not sure what such a tool would look like.

Searching in the Antunit site did not turn up much either.

Not able to hit breakpoint in Eclipse

When I put a breakpoint in the execute method of Replace, however, Eclipse did not hit my breakpoint.

I looked over the post from the developer group and I noticed that Gles did not suggest that I use an Eclipse plugin for antunit, but a tool in the antunit trunk to plug antunit into Eclipse's JUnit runner.

Antunit and antdotnet

From http://ant.apache.org/antlibs/bindownload.cgi
I downloaded apache-ant-dotnet-1.0-bin.zip and apache-ant-antunit-1.1-bin.zip, found the .jar file in each and added them to my installation of ant.

This seemed to clear up problems I had with "ant test", although it ran for a while and just hung up.

After doing this, I was able to run one of the ant scripts which used antunit.
I ran src/test/antunit/taskdefs/replace-test.xml
And it ran successfully in Eclipse.

Monday, May 17, 2010

Zero errors!

Clean build in Eclipse (in Windows)

Project name: ant-core

Source Folders
ant-core/src
ant-core/src/main
ant-core/src/tests/junit

Libraries
C:\Documents and Settings\c744873\.maven\repository\groovy\jars\groovy-all-1.0.jar
/ant-core/lib/optional/activation-1.1.jar
/ant-core/lib/optional/antlr-2.7.7.jar
/ant-core/lib/optional/asm-2.2.3.jar
/ant-core/lib/optional/asm-commons-2.2.3.jar
/ant-core/lib/optional/asm-tree-2.2.3.jar
/ant-core/lib/optional/bcel-5.1.jar
/ant-core/lib/optional/bsf-2.4.0.jar
/ant-core/lib/optional/bsh-2.0b4.jar
/ant-core/lib/optional/bsh-core-2.0b4.jar
/ant-core/lib/optional/commons-logging-1.0.4.jar
/ant-core/lib/optional/commons-logging-api-1.1.jar
/ant-core/lib/optional/commons-net-1.4.1.jar
/ant-core/lib/optional/jai_codec.jar
/ant-core/lib/optional/jai_core.jar
/ant-core/lib/optional/jasper-compiler-4.1.36.jar
/ant-core/lib/optional/jasper-runtime-4.1.36.jar
/ant-core/lib/optional/jdepend-2.9.1.jar
/ant-core/lib/optional/jruby-0.9.8.jar
/ant-core/lib/optional/js-1.6R7.jar
/ant-core/lib/optional/log4j-1.2.14.jar
/ant-core/lib/optional/mail-1.4.jar
/ant-core/lib/optional/maven-artifact-ant-2.0.4-dep.jar
/ant-core/lib/optional/NetRexxC.jar
/ant-core/lib/optional/oro-2.0.8.jar
/ant-core/lib/optional/regexp-1.3.jar
/ant-core/lib/optional/serializer-2.7.1.jar
/ant-core/lib/optional/servlet-api-2.3.jar
/ant-core/lib/optional/which-1.0.jar
/ant-core/lib/optional/xalan-2.7.1.jar
/ant-core/lib/optional/xml-apis-1.3.04.jar
/ant-core/lib/optional/xml-resolver-1.2.jar
/ant-core/lib/optional/jsch-0.1.42.jar

Sunday, May 16, 2010

Message looks like an error after tests complete

All the tests complete just fine from both the command-line and in Eclipse. It ran 1678 unit tests in about 12 1/2 minutes. I get the message below, however, about problems with the antunit task. I still cannot explain this one. But for what I need to do, I can probably run individual antunits rather than run the full unit test suite for my development.

antunit-tests:
[mkdir] Created dir: /home/chyjm/workspace/ant-core/build/antunit/xml

BUILD FAILED
/home/chyjm/workspace/ant-core/build.xml:1817: Problem: failed to create task or type antlib:org.apache.ant.antunit:antunit
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:
-/usr/local/apache-ant-1.8.1/lib
-/home/chyjm/.ant/lib
-a directory added on the command line with the -lib argument


Total time: 12 minutes 38 seconds

Update Ant from 1.6.5 to 1.7.1 in Fedora

I have not yet figured out how to install a newer version of Ant across the board yet on my Linux based system. Fedora's repository did not indicate any available packages. I added the JPackage repository and then I was able to see an update for Ant to 1.7.1 which is at least a helpful update over 1.6.5. Yum and Package Manager, however, are both bombing out when I try to install the 1.7.1 version with this error: Missing Dependency: /usr/bin/rebuild-security-providers is needed by package java-1.5.0-gcj
Missing Dependency: lucene = 1.4.3-1jpp.18 is needed by package lucene-devel

Maybe an Eclipse Bug - using a different version of Ant than the default

I decided to run 1.8.1 version of Ant outside of Eclipse and moved all the jars from lib/optional to lib as in my last post. I changed the version of Ant referenced by Eclipse but I still had Problems appearing Eclipse with replace-test.xml, replace-tokens-test.xml and propertyhelper-test.xml.

This was driving me crazy.

Running "ant test" from the command-line worked fine.

On a hunch, I tried running the test task in build.xml in Eclipse anyway. What do you know? It worked fine. I'm still seeing these errors, but it does not appear to harm anything.

My default version of Ant on my system is 1.6.5, but I think I need features only available in later releases to run these tests. I believe that Eclipse may simply have a problem starting up with one version of Ant, but being told to use a different one inside the application. Perhaps I could find a start-up switch for Eclipse to indicate a different version of Ant than the default.

Severity and Description Path Resource Location Creation Time Id
Default target antunit does not exist in this project ant-core/src/tests/antunit/filters replacetokens-test.xml line 18 1274075735070 137405
Default target antunit does not exist in this project ant-core/src/tests/antunit/taskdefs propertyhelper-test.xml line 18 1274075518365 137397
Default target antunit does not exist in this project ant-core/src/tests/antunit/taskdefs replace-test.xml line 18 1274073866514 135951
Target antunit-base.tearDown does not exist in this project ant-core/src/tests/antunit/filters replacetokens-test.xml line 23 1274075735070 137406
Target antunit-base.tearDown does not exist in this project ant-core/src/tests/antunit/taskdefs replace-test.xml line 23 1274073866514 135952
Target ph.defineHelpers does not exist in this project ant-core/src/tests/antunit/filters replacetokens-test.xml line 34 1274075735070 137407
Target ph.defineHelpers does not exist in this project ant-core/src/tests/antunit/taskdefs replace-test.xml line 91 1274073866514 135953

lib/optional vs. lib directories

I tried running "ant test" and every test failed. For some reason it would not find junit-3.8.5.jar in the path even though "ant -Ddest=optional -buildfile fetch.xml" automatically put it in my lib/optional directory.

I moved junit-3.8.5.jar from lib/optional to lib and started seeing successful tests.

Not all tests passed though. The ones which depended upon other optional jar files still failed, such as the ones using the JAI jars.

What I found was that fetch.xml needs to put ALL of the optional jar files in the lib directory, not lib/optional.

Once I moved them all, all tests passed.

Down to 4 errors

Downloaded Netrexx from http://www-01.ibm.com/software/awdtools/netrexx/download.html

Download the package
Find NetRexxC.jar in the zip file
Save it in the lib directory
Refresh, add NetRexxC.jar to the path.

Down to 4 errors

The rest are XML errors.
3 in replace-test.xml
1 in propertyhelper-test.xml

Down to 7 errors

Downloaded jai-1_1_3-lib.zip from https://jai.dev.java.net/binary-builds.html
Extracted jai-core.jar and jai-codec.jar to my lib directory.
Refreshed the Eclipse project, added these two to my classpath.
Now I am down to 7 errors.

Down to 79 compile errors in Eclipse

ant -Ddest=optional -buildfile fetch.xml

Copied the dependency jar files to the lib directory.
Refreshed the workspace in Eclipse.
Added all the jars to the library.

Woohoo! Down to only 79 compile errors in Eclipse.

fetch.xml - pulls down dependent jars

This looks promising.

ant -Ddest=optional -buildfile fetch.xml

This seems to have downloaded most of the dependent jars for me.
Although I could not get one . . . because my hard drive ran out of space. Oops!

Discarded response to the group

After reviewing the "Ask Smart Questions" article. I have abandoned the following response I had mocked up for the group. I realized the entire post would assume that everyone is interested in working hard to get me up to speed rather than showing that I am willing to get myself up to speed. Since 15149 is so old and is not mentioned in either the user or developer group, I am going to assume that 15149 is simply not relevant.

The use of Ant unit appears to be the key to debugging in Eclipse. I am not sure what versions of jars I need in my class path to do this, but I believe that I have simply not taken the time yet to get them all.

Thank you Martin.

I am not sure I understand the part about production quality jars for Class Not Found Exceptions.

I have not contributed to open source before and am interested in trying to start doing so now.

I am not interested in creating a new ant task for personal use; I am interested in helping fix bugs in Ant's existing tasks identified in BugZilla.

I have identified some bugzilla issues to tackle and I have tried to focus on bug 15149 "Dealing with the Replace Task". This one has been around for a while and is a feature request and not really a bug, but I think I can kinda see what is requested.

Do the steps you provided apply to changes to the existing tasks as well as the addition of new tasks?

I dislike bothering the development mailing list for such newbie questions. I have become very familiar with using Eclipse for Java development and I am curious whether others are using it as well for actual development of the Ant project.

Is 15149 still a relevant issue to fix? Would this one be too big to tackle?

"Smart Questions" Essay

The "Smart Questions" essay in my last post seems to really indicate that the OSS developers sometimes get overwhelmed by "stupid" questions by people who have not taken the time to try to answer their own questions through information published by the project or the sourcecode before posting to the group. I think this entire essay is fairly applicable to all software development, although a bit disheartening. The essay may or may not be accurate, but it sounds like OSS developers are not necessarily willing to take a newbie under his/her wing to mentor them in the process of fixing a bug for the project. It makes sense though, since many of the developers are doing this in their spare time.

Second Response from the mailing list

Second Response from the mailing list. Not sure about the antunit plugin. Looks like I need to get all the dependencies to use Eclipse.

I'm not sure that directly answer your question, but in the trunk of
antunit, there is a tool to plug antunit script into the eclipse (or any
other IDE) Junit runner. That way, you can use your favorite java debugger
to debug antunit script.

But still, your project need to have all the ant dependencies configured.

Gilles Scokart

Saturday, May 15, 2010

Asking Smart Questions

The Ant project recommends that people read through this essay about asking smat questions before posting to the group.
How to Ask Questions the Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html

we are not a help desk for your project!

First (so far only ) response from the Ant Mailing List

First (so far only ) response from the Ant Mailing List

A quick note of clarification
Eclipse is an IDE (Integrated Development Environment) NOT a build environment
you will need to export your eclipse project tasks and targets to your ant build.xml
the CNFEs (Class Not Found Exception)s produced by missing eclipse-plugins will need to be replaced with production quality jars in your classpath assuming you created the main ant build.xml just follow the Eclipse instructions for adding tasks and ant types
Adding new Ant tasks and typesAdding new Ant tasks and types
Add new Ant tasks and types through the Ant preferences page. These tasks and
types will be available for buildfiles running in the Workbench without, having
to use taskdef or typedef in the script declaration (For more on taskdef or
typedef see the Ant documentation in http://ant.apache.org).

To add a new task or type:
Open the Ant >
Runtime preference page.
Click the Tasks tab or the Types tab.
Click Add Task or Add Type.
Provide a name and class for the task or type.
Select the library where the task or type is declared. If the library is not present on the list, you must add it to the Ant classpath (see the Related task link below).

Ant Support

Builds

External tools
Running external tools
Modifying the Ant classpath
Using a different version of Ant
once all of your build.xml tasks and targets are created you can compile, package, deploy ant targets from command line
ant -f NameofBuild.xml

Martin Gainty

Requested information from the developer mailing list for Eclipse

Sent the following to the developer mailing list:

All,

I have had a hard time finding information on running ant locally in Eclipse so I can use the debugger to debug core ant code.

Do the developers on the project typically use Eclipse for development?
If so, what class path works in Eclipse to do this?
Is there a set of commands to get all the dependent jars?
Can I debug org.apache.tools.ant.launch.Launcher directly?
If so, where should the build.xml be that it runs?

Below are the steps I have completed get this going.
I have checked out http://svn.apache.org/repos/asf/ant/core/trunk from subversion to a directory called ant-core.

I got up to revision 944382 which is 1.8.2alpha.
I created a new Java Project against this code.
The default output folder is ant-core/bin.
The default Libraries are ant-antunit-1.1.jar, junit-3.8.2.jar and the JRE (I'm currently using jdk1.6.0_14)
Eclipse detects the default source directories as the following:

ant-core/src
ant-core/src/etc/testcases/core/containerssrc
ant-core/src/etc/testcases/core/loaderref/src
ant-core/src/etc/testcases/taskdefs/apt
ant-core/src/etc/testcases/taskdefs/fixcrlf/expected
ant-core/src/etc/testcases/taskdefs/fixcrlf/input
ant-core/src/etc/testcases/taskdefs/manifestclasspath
ant-core/src/etc/testcases/taskdefs/optional/depend/src1
ant-core/src/etc/testcases/taskdefs/optional/depend/src2
ant-core/src/etc/testcases/taskdefs/optional/depend/src3
ant-core/src/etc/testcases/taskdefs/optional/depend/src4
ant-core/src/etc/testcases/taskdefs/optional/depend/src5
ant-core/src/etc/testcases/taskdefs/optional/javah/input
ant-core/src/etc/testcases/taskdefs/rmic/src
ant-core/src/etc/testcases/taskdefs/types/assertions
ant-core/src/main
ant-core/src/etc/tests/antunit/core/location/src
ant-core/src/etc/tests/antunit/taskdefs/javac-dir/bad-src
ant-core/src/etc/tests/antunit/taskdefs/javac-dir/good-src
ant-core/src/etc/tests/antunit/taskdefs/optional/junit/src
ant-core/src/test/junit
This results in approximately 862 errors.

I was able to build.bat and it built the project into dist.
But, I would like to be able to use Eclipse's debugger.
The main launch point appears to be org.apache.tools.ant.launch.Launcher.
I can right-click on this file and select Debug Java application and hit breakpoints I set, but I would need a clean build to do this.

15149 Full content

In the manual page about replace task, it mentioned we can use a property file


to store token/value pairs.

---------

replacefilterfile: valid property file. Each property will be treated as a

replacefilter where token is the name of the property and value is the

properties value.

---------



There's room to improve this feature: we can add one more option to override

property values defined in this file. This file just house default values, the

customized values will be stored in USER_HOME/.ant.properties or elsewhere, so

that in a team project, developers don't have to adjust values in the

replacefilterfile.



I would be very interested in this feature because after first read I thought I

can use the replace task this way and later found it can not be done in the

current 1.5.1 release.



Thanks.

Nothing on 15149 on the user list either.

http://news.gmane.org/gmane.comp.jakarta.ant.user/
Search: 15149
No documents match your query
Silly me. There is a search option at the bottom of the gmane screen for the project.

http://news.gmane.org/gmane.comp.jakarta.ant.user/
There is a search option at the bottom.

No results on bugzilla issue 15149 in GMANE

It looks like the developer list is not going to help much with 15149. A search in GMANE returned no results.

I wonder if the user list would help any.

How to search Ant mailing list archives

Go to GMANE - http://www.gmane.org/
Click on Searching
Enter your search criteria in "Search for words"
Enter "gmane.com.jakarta.ant.devel" in the "In group" field.
Click on "Search >>"
You can then look through the results.
It's not bad, but I would like to see more of the subject and body of the messages from the result list. I cannot tell if the message pertains to what I am doing because both the subject and body get truncated.

Got here from http://ant.apache.com/, "Mailing Lists", under Archives, "Ant Developer List on gmane"

This shows the most recent messages.

The URL here is
http://news.gmane.org/gmane.comp.jakarta.ant.devel/

In the "-Action-" drop down, select Help.
This shows the main GMANE screen.
From here, click on "Searching"

I pullect the group from the URL above.

Mailing list archives

Digging through the mailing list archives regarding the replace task and using Eclipse for project setup and debugging.
http://mail-archives.apache.org/mod_mbox/ant-dev/

(Found this at http://ant.apache.org/, "Mailing Lists", under Archives select "List Index on mail-archives.apache.org ")

Trying to figure out how to post to the mailing list

After subscribing to the mailing list (dev-subscribe@ant.apache.org) several messages had the following at the bottom of the emails.

To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org

I went back to http://ant.apache.org , clicked on mailing lists to see more information about the dev-help option. I saw this:
"To subscribe to a mailinglist use the links below. In your first email you will get some information about working with the list manager EZMLM."
EZMLM had a link, but it did not seem to be much help. It talked about how the email bot worked in general, but not specifically for the Ant project.

Seemed like an interesting idea to use their email bot to get information about the mailing list.

The response was pretty quick (a few minutes) and in summary, this is what I got:
"This is a generic help message. The message I received wasn't sent to any of my command addresses."

There was the unsubscribe email address from above, and a subscribe email address.
There was also one for information and one for FAQ:
dev-info@ant.apache.org
dev-faq@ant.apache.org

There were also instructions for subscribing to and unsubscribing from a digest version.
Also interesting were "commands" to get groups of messages from the archive by "message number".

To get messages 123 through 145 (a maximum of 100 per request), mail:
dev-get.123_145@ant.apache.org
To get an index with subject and author for messages 123-456 , mail:
dev-index.123_456@ant.apache.org
They are always returned as sets of 100, max 2000 per request, so you'll actually get 100-499.
To receive all messages with the same subject as message 12345, send a short message to:
dev-thread.12345@ant.apache.org

The messages should contain one line or word of text to avoid being treated as sp@m, but I will ignore their content. Only the ADDRESS you send to is important.

An email to dev-info returned the same general message but with the following :
No information has been provided for this list.

An email to dev-faq returned the same general message but with the following:
FAQ - Frequently asked questions of the dev@ant.apache.org.
None available yet.

Tuesday, May 11, 2010

Using Eclipse debugger in Ant project

I was really hoping I could run the Ant code locally in Eclipse through the debugger. I think I am close, I think the main driving class is Launcher, but I am not sure how to set it up properly to run it.

ACM 24x7 Ant Book

On ACM, I found one Ant book in their 24x7 books:
http://acm.books24x7.com/viewer.asp?bookid=3166&chunkid=0506148908
The title of the book is
Java Tools for Extreme Programming—Mastering Open Source Tools Including Ant, JUnit, and Cactus

Replace Task

I was hoping to understand the replace task so I can tackle "15149 dealing with the replace task"
I think I'm going to have to mock up some sample data. The override concept is an interesting one.  There are a list of files with tokens in them representing other values. This is kinda like mail merge. The replace task can take a properties file (a list of entries like name=value) and replace the tokens which match name with the corresponding value. For 15149, the submitter suggested that there could be a large master file of properties, the user could reference, but also use a smaller file to override a small subset of entries with custom entries. I could see this two ways. The first method would be to have a master file and an override file. The other method would be to allow the user to set up a hierarchy of property files. I have a similar issue at work and a hierarchical structure would work nicely.

Wednesday, May 5, 2010

Ant 1.8.1

It looks like Ant 1.8.1 was released today. I took an update from subversion and found changes indicating the 1.8.1 version update.
I built it from the code again and set up Eclipse to use this version rather than the version built into Eclipse for builds.

I played around with it a while working on a build script for some sample CS550 code. Created an execute task for bison, another for flex, and one for cc. It seemed to work as well as a makefile. I tried it with my default version of ant (1.6.5) and the compiled 1.8.1 version.

Bug submission process

I found some information regarding how to submit a bug fix:
http://ant.apache.org/manual/tutorial-tasks-filesets-properties.html#contribute

Navigation to this was not easy
Main site http://ant.apache.org/
Click on "Manual" under "Documentation"
Click on "Developing with Ant"
Click on Tasks using Properties, Filesets & Paths
Click on Contribute the new task

This seems to coincide with the comments I saw on some of the bugs in bugzilla. The submitter puts a "delta" file directly into the bug rather than checking the change into subversion. Seems pretty awkward. If someone else makes a change to an overlapping portion of the code before the submitter's fix is applied, then whoever accepts the bug would have a difficult merge on their hands.

Saturday, May 1, 2010

Ant Candidate voting

It never occurred to me that an open source project would post a vote for a release candidate. One Ant member created a place to vote on version 1.8.1.