Author Topic: 'Best Practices' for tagging third-party JARs for my Java project?  (Read 6164 times)

sacharya

  • Community Member
  • Posts: 7
  • Hero Points: 1

Hi,

I'm curious on what the suggested method is for tagging third-party libraries that I may require for a given Java project.  My code is structured something like the following:

project_root/
   lib/
     lib1.jar
     lib2.jar
     ...
   src/
     ...

Basically, I don't want to add lib/lib1.jar, lib/lib2.jar, etc. to my project (more on this in a second), because they are really just (third-party) dependencies for my project.  But, I want to be able to have all the tagging info for those libraries available.  Additionally, I don't want to pollute the global java.vtg tag file with lots of these third-party libraries.  One reason for this, for instance, is that I might choose to use v1.0 of lib1.jar in one project, but I might need to use a newer version (v1.1) of that same lib1.jar in a different project.  I wouldn't want there to be symbol conflicts between the tags generated against different versions of the library.

So - the question is - what is the "right" way of doing this that satisfies both situations above?  Surely I'm being naive and missing something simple in the UI...???

BTW - the reason I don't want to add the JARs to my project directly is because I have a Slick-C macro that iterates each file in my project to generate a SLOC count for the entire project.  Naturally, this won't work too well if I've got JARs added to my project!

(Of course, the correct answer might just be that I need to fix my macro ... and if that's the answer, then so be it, but hopefully there's a better way  ;))

PlanetPratt

  • Senior Community Member
  • Posts: 145
  • Hero Points: 6
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #1 on: October 17, 2006, 09:46:13 pm »
You can use Tools->Tag Files...  Then hit the "Add Tag File..." button, Select "Java" from the list and hit "OK", then pick a new name for each of your tagfiles (like jdom1.vtg or struts135.vtg).  In the "Add Tree" dialog, go find the base of the source tree (You'll usually want Recursive checked) and hit OK.  You've now added a new vtg file that specifically has the information about the version of the source you tagged.
  (*Chris*)

sacharya

  • Community Member
  • Posts: 7
  • Hero Points: 1
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #2 on: October 17, 2006, 10:55:04 pm »

Quote
You can use Tools->Tag Files...  Then hit the "Add Tag File..." button, Select "Java" from the list and hit "OK", then pick a new name for each of your tagfiles (like jdom1.vtg or struts135.vtg).  In the "Add Tree" dialog, go find the base of the source tree (You'll usually want Recursive checked) and hit OK.  You've now added a new vtg file that specifically has the information about the version of the source you tagged.

I should have mentioned - I tried this, but the problem is that the new tag file does not associate with the workspace that I'm working on.  I'm assuming that this means that the tag file would then be used globally for all Java source files.  This would still cause the problem I described with symbol clashes from tags generated between different library versions - wouldn't it?

Here's an example that describes the problem:

If I've got a library foo1.0.jar, with some class com.foo.bar.MyFoo that only has a default constructor, but version 1.1 of the library (foo1.1.jar) has a MyFoo constructor that takes some number of arguments, and I've generated both a foo1.0.vtg *and* a foo1.1.vtg - what happens when I try to do autocompletion against the constructor?  Will I get the 1.0 version or the 1.1 version?  How do I control which set of tags is used?

If I had a way of attaching the newly-generated tag file for *just* the workspace, that would be ideal and would work just the way I would like.  But I can't see a way to do this...

hs2

  • Senior Community Member
  • Posts: 2736
  • Hero Points: 285
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #3 on: October 17, 2006, 11:55:28 pm »
You may add more 'Workspace' tagfiles or create 'Auto updated tagfiles' which are also workspace associated but have to be managed manually.
I use them for my 3rd party stuff (cross compiler env. etc).

HS2

sacharya

  • Community Member
  • Posts: 7
  • Hero Points: 1
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #4 on: October 18, 2006, 04:59:18 pm »
You may add more 'Workspace' tagfiles or create 'Auto updated tagfiles' which are also workspace associated but have to be managed manually.
I use them for my 3rd party stuff (cross compiler env. etc).

HS2

How do I create a 'Workspace' tagfile?  When I right-click 'Add Tag File...' under the Workspace Tag File group in the Tag Files dialog, it prompts me to select the source type (at which point I select Java) - and then adds the newly-created tag file to the Java group, not the Workspace group.

When I try to create an 'Auto-Updated Tag File', I am not able to select the JARs that need to be tagged.

What am I missing / doing wrong?

hs2

  • Senior Community Member
  • Posts: 2736
  • Hero Points: 285
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #5 on: October 18, 2006, 05:33:12 pm »
It's a bit tricky ...
1. Add the Java-type tagfile as you already did. (I think it's also poss. to do that on the 'Java' section.)
2. select this newly created tagfile by e.g. r-clicking 'Auto tag files -> Add (or use the Add-Button at the bottom of the dialog)
3. remove (r-click) this 'global' tagfile from the global' Java section, but only 'from the list' and not the file itself
   (except you made a copy to another location and selected this copy by adding it the the Auto-list)

BTW: There is also a ''mktags(.exe)' executable wich could be used independently from Slick to create tagfiles.

Hope this works (did that time ago),

HS2

sacharya

  • Community Member
  • Posts: 7
  • Hero Points: 1
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #6 on: October 18, 2006, 06:14:05 pm »

Ah, perfect!  That's exactly what I wanted.  Thanks so much for your help.

Now, a minor gripe to the SE team - this is incredibly unintuitive!  I hope you will revise the Tag Files dialog to allow for an easier way to do this in a future version - or, at the least, revise the online help documentation to illustrate how to do this.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4263
  • Hero Points: 310
Re: 'Best Practices' for tagging third-party JARs for my Java project?
« Reply #7 on: October 18, 2006, 07:33:33 pm »
I definitely agree.  Where to add workspace tag files is not the least bit obvious.  More docs about this area will help too.  I think there are some doc changes planned for this.