Joe Vahabzadeh

Ranch Hand
+ Follow
since Jan 05, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joe Vahabzadeh

D'oh! I couldn't see the forest for the trees...

I don't know what the "code" task is - but I assume you just meant to have another target in the build file that creates the structure that I wanted to exist in the zip file. I'm going to go with that method, it seems cleaner.

Seems way simpler now that I'm not trying to hammer a square peg into a round hole!

(it doesn't help that I actually was also screwing up my directory name property values . . having a name/location pair is great for setting up absolute directory paths, but using relative paths with the same name, I had to use name/value - forgot that little tidbit and drove myself batty in the process)
10 years ago

I've been driving myself insane trying to figure this one out - and going nuts with web searches. All to no avail.

First off, I am using ANT version 1.8.2, so I don't have the 1.6.2 issues with zip and empty folders.

I am trying to create a zip file, and my script so far is as follows:

So, what this does is take the jar file that exists in {dist} and add it to the zip file, so that when it's unzipped, the jar file comes out directly, and does NOT maintain the hierarchy (ie: doesn't create a {dist} directory and put the jar file inside it). This is the behavior I want so far.

HOWEVER, I would like to know how to do the following:
- include a {config} directory and ALL the files within it except for one called "test-config.xml"
- include two separate empty directories - say {subdir1} and {subdir2}. They may or may not have files in them, but I do NOT want ANY files in those directories when they get zipped.

For that second part with the empty directories, I'm perfectly content having the zip task create those in the zip itself without necessarily creating them on the local file system. In fact, the ideal would be if they'd be in the zip file and NOT be on the local file system - but I'll take whatever method I can get that works.

So, my local file system will look like so:

subdir1/ (may or may not exist and may or may not have files in it)
subdir2/ (may or may not exist and may or may not have files in it)

I want the ZIP file, when unzipped, to result in:

How do I accomplish this? I've tried variants of fileset, dirset, zipfileset, and am failing at every attempt.

Thanks in advance...
10 years ago
Thank you again for your help - I had "almost" discovered that same issue - that it was a namespace problem, but was still working it out.... going to change my code now to account for this.
Alright, so let's say I have the following XML fragment as part of a SOAP message:

Now, I have the following code:

The inputBody is in effect the MbElement representing the SOAP node.

Now, I can do the following:

and I will wind up with firstDetail being an MbElement that represents the first DETAILS element - whose value is "M5-100"

However, if I do this:

I would EXPECT that details is a List<MbElement> with a size of 3, with each one being a DETAILS element. However, it comes back as an empty list.

Oddly, I CAN do this:

and it will work - I get a List<MbElement> of size 1, and that one item is the Body MbElement. But any deeper in the hierarchy, and it just gives me an empty list.

So, why is that? What am I doing wrong that I am not getting a 3-element List<MbElement> back?

Paul Clapham wrote:Yuck. In XML an attribute is not an element. Neither is it a child of the element it belongs to.

But anyway you've got some code that works, no?


Yes I do - I don't like the code, but it works.

And, yes, I had some choice words less polite than "yuck" about non-elements being treated like elements . . . it's... unpleasant.

g tsuji: That looks good - I JUST started looking into the XPath part of the library, and may give that a shot - thanks!
That was the notation I'd tried first . . but it didn't work.

However, I'm with you on the oddness of the API - no way to directly get the attribute I think . . but I know when you create an MbElement as a child of another, given the type parameter, you create an MbElement that is either a real child of the original, or it can be an attribute, or even a namespace, of the original.

It's weird. I guess they had their reasons for doing it that way. Hence why getFirstElementByPath("category") in the second line of code-fragment 2 actually works. It's an MbElement . . but not the same type of MbElement.
Alright, I wasn't 100% sure that this question belonged here, or elsewhere, but here's what I'm running into:

I have code that needs to get the value of nodes, or the value of attributes, or possibly both.

So, let's say I have the following tree fragment of XML:

Now, I know I can easily get the value of the DETAILS node as follows, assuming xmlBody is an MbElement object representing the entire structure above:
code-fragment 1:

Therefore, value will be equal to "M5-100"

However, how do I get the value of the attribute "category"? The only solution I have so far is:
code-fragment 2:

Is there a way to indicate the attribute name within the original assignment of element? ie: is there a way that I can do:
code-fragment 3:

and thus have value be equal to "50"? Or do I HAVE to do the two-step process as I showed in code-fragment 2?

Thanks in advance.
Ok, so, this is where I'm trying to put things together conveniently.....

In another thread, I got my build targets to work, with their slightly different classpath requirements, by doing the following (and of course, in this case, Project-1 MUST be compiled before Project-2):

All well and good. However, what I'd ideally like to do is something like this:

Note the commented out stuff - all the somehow do somethings... Is it possible to do what I want without this being an enormous mess? Or is it just easier to do the classpath as I've done in the first example, and not bother with the antcall stuff in this case.
10 years ago
That works for Project-1, where the classpath has to refer only to directories that contain .jar files.

For Project-2, one of the directories will contain classfiles from Project-1. That seems to give it fits....

Here's a sample of what I'm trying to do, without all that semi-clever antcall stuff... Note that the lib references are written as lib/**/* because I may have sub-directories with their own .jar files in there in the future.

EDIT: I'm an idiot... if I replace:


then it works.

NOW I've got to try to figure a way to be clever and put that in with an antcall sort of setup...
10 years ago
I absolutely MUST be out of practice, because I don't recall having these problems before.

Keep in mind the structure is the same as mentioned in my other thread about deleting directories.

Here's the snipped of build.xml in the workspace/Project-Common directory.

So, basically, Project-1 requires the .jar files (there are 2 of them) in Project-Common. Project-2 requires those same .jar files, plus a .jar file in Project-2/lib, plus the classes from Project-1.

What is causing this to fail? The compilation errors happen with Project-1, and they suggest that the system is acting as if the classpath reference is simply not there.
10 years ago
But, I must clearly be doing something wrong.

I have the following snippet from my build.xml:

This build.xml exists in:

which is an Eclipse project, and thus in Eclipse the project name is Project-Common.

The other projects are, obviously, Project-1, and Project-2, and exist in:

Now, the snippet I have works, but I'm trying to figure out how to get a single line to delete all directories inside a project's directory, but NOT files that are directly inside the project directory - and I'd also like to exclude the .settings directory from being deleted.

I've tried a few variants, but they're either too aggressive (delete everything, including the files, the .settings directory, the .project file, etc), or even delete the Project-1 and Project-2 folders themselves as well... or they delete the contents of the subdirectories, but leave the directories intact - ie Project-1/bin still exists, but everything below it is gone, etc.

So . . uh, how do I do this? I get the feeling I'm missing something incredibly simple here...

Thanks in advance.
10 years ago
Ah, got it! Ok, so I WAS remembering it incorrectly.

Of course, in my sudden indignation, I furiously asked "Well, why the hell isn't the signature V get(K key) instead of V get(Object key)???"

Though I can actually see arguments for both . . . so my indignation ran out of steam real quick, and has settled down into mere irritable grumbling.
The version I'm using, according to About Eclipse, is:

Ok, so, I found out that if I have an object (say a Map) with the Key type and Value type defined, but then do a get with the wrong object type, Eclipse doesn't complain.

That is, here's the sample code:

Why doesn't the last line give me a warning or error? I could've sworn that, when I used to use Eclipse for Java SE, that it would complain about that. Am I remembering this wrong? Is there some preference or setting that I have to use?
Ok, I probably should clarify what I'm doing.

I have a single SQL Query Worksheet open, and I have on that sheet something like the following:

Now, I'd like to, instead of having that first select statement copy/pasted a zillion times, assign it to a variable or a reference of some sort, so that I can have the query itself only in one place - thus any debugging or modifications of the query only have to be done once.

Is this possible? If so, how do I do it?

11 years ago
Ah, got it! Thanks for the clarifications, that helps a lot.