• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse build source folders / class path folders

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys : I always notice that in eclipse there are all these options, for example, "add Library", which I never utilize. How do "add Library" and "add Class Folder" differ ? And why are they used in builds ? Generally I stick with default projects, but more and more, Im starting to work on projects where ant/maven configurations, in spite of the excellent plugin support, sometimes have to be "massaged" into eclipse, and often the utilization of these features is necessary to compile industrial grade applications in the IDE.....
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used "add library" several times to add 3rd-party libraries, most recently the Apache Jakarta Project's Commons-BeanUtils library. I typically use the "Add Jar" button (I think it's called) to add the library's jar file to my project.

I've never used "add Class Folder," don't even remember seeing it, but I would guess from the name that it is different than adding a library. You might try the online Eclipse User Manual for insight.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks... I'm wondering how this relates to java builds in general though.... I can usually get eclipse to "work" by hacking it.... But I want to understand what it's doing at a more fundamental level.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Maven projects, use the m2eclipse plugin. Then when you load the Maven project into Eclipse (or create a Maven Project directly in Eclipse), the m2eclipse plugin will automatically sync the dependency list in your pom.xml with the list of JARs in the Eclipse build path.

With Ant project, you will have to manually add any dependencies in your Ant build to the Eclipse build path, otherwise Eclipse will not know about them and you will have to deal with a lot of red underlines and, even worse, non-functioning command completion.

And whether you do "add class folder" or "add jar", the result is that the item is added to the classpath when the compiler is run. In addition, the classes are examined to provide command completion.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"And whether is is "add class folder" or "add jar", the result is that the item is added to the classpath when the compiler is run. "

Can you elaborate on this? I'm not sure how eclipse compiles classes if you are using ant... Whats confusing is how it is that the eclipse is able to "use" the resources created by ant...? And more interesting, how those resources are intermingled with the niceties of the IDE like code-completion.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I rephrased the text, hopefully that is clearer.

As far as I know, Eclipse doesn't use the information in the Ant script to populate the build path. You have to do that manually, Which means that when adding a JAR to the build you need to add it twice - once to the Ant script and once to Eclipse. But it has been a while since I did projects that use Ant, so perhaps is the 2 or 3 years since then things might have improved.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what do eclipse "builders" do ? (Attached a screenshot here....) Note that you can use the "ant" builder.... you can check it , or un check it. I usually leave it unchecked. But sometimes checking it helps to fix things for me.
Filename: a.tiff
Description:
File size: 97 Kbytes
[Download a.tiff] Download Attachment
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Builders are things that are run when you click the Build button or menu option. The builders are run in the order in which they appear for the project. You can choose to use a Java builder, an Ant builder, or any number of other builders, either by themselves or in combination.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats interesting. I guess that means that builders could potentially overwrite each others work . seems like a dangerous feature to implement.

In any case, I find that activating multiple builders (java and ant) , and then switching back to one (java) fixes issues. Maybe because ant needs to "set some things up" before the regular java builds will work....
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is correct, Builder do whatever it is that they do. And having them conflict with each other is a possibility. That is always a potential problem when you have a framework that enables plugins.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic