Eclipse Automatically Download / Update JAR files - eclipse

I just created a Web App project from a repository through Eclipse's SVN support. What I would be doing is have an ANT build going and then finally deploy through Tomcat.
I am using Eclipse IDE for Java EE developers on an Ubuntu system.
There are a number of jar files needed
to support my project - like Struts,
Hibernate, etc. etc.
Do I need to
manually download each of them
and put them in the lib folder?
OR
Does Eclipse have a solution to
automatically UPDATE these from the internet? Any plugins to automatically take care of this?

You should consider using Maven for your project. It's VERY well supported in Eclipse, and handles all dependencies (as well as other things, such as releases).
The problem is there's a bit of a learning curve, but if you intend your project to get to a considerable size, I'd say it's very important.
Maven has support for ant builds and most libraries are in the central Maven repository. You just say your project has a dependency on the external project and it will automatically download the dependencies.
http://maven.apache.org/

Related

Process of install the Junit library in Eclipse

Good morning guys,
what I am considering about is to build a standard process of installing a library in a java project in eclipse. I am a niewbie software developer so a prior sorry if this question is a bit stupid.
All what I want to do is to use the junit library. I have followed these septs.
I installed the junit-4.12.jar file from the web.
Inside the project folder I created a new file and I named it "lib".
I put in this folder thae jar file and then in eclipse I click
on project folder -> properties -> Java build path and I click on libraries and add jars. (not external jars).
Is that process ok?
your process isn't good because it doesn't scale: imagine you want to install 40 libraries in your project. and then imaging your team has 5 developers and each of them has to do the same. and what about CI server that must be automatic
in fact your problem was solved years ago and the solution is called 'dependency management tool'. those tools are usually built into something more powerful called 'build tool'. maven or gradle are examples of such tools. you just provide list of your dependencies (like junit) and that program automatically downloads them and build your project. and it's sufficient as long as your project is more less 'typical'
i don't remember if eclipse has build in support for maven (one of the oldest and most common). if not, just install the eclipse plugin and you're ready to go

Using maven generated sources in Eclipse

I have an application made up of a number of maven projects. I work on it in Eclipse. Some of the projects use Maven plugins to generate stub classes for web services etc.
When i import the projects into a new workspace I have to issue a maven generate sources command followed by attach source folders to build path on each project. The application i work on has more than 5-6 projects which require these steps.
Is there a plugin I can install in Eclipse to pick up the generated sources, or even one that generates the sources and updates the build path to save the manual steps?
I'm pretty sure the m2e plugin takes care of this automatically. m2e is included in the primary Java and Java EE packages of recent Eclipse versions, so you probably already have it. If you right-click on your project, and there is a Maven submenu, then the project is already managed by m2e. Otherwise, right-click and choose Configure > Convert to Maven project.
Well, it depends on exact maven plugin you are using.
generate sources
Before I considered that m2e connector would be needed for any non common plugin, like generator. But I came recently on some plugins (1), that do it without special m2e connector.
attach source folders to build path
For this part check build-helper-maven-plugin and answer to M2E and having maven generated source folders as eclipse source folders

Source jar files in eclipse

I am using eclipse and having difficulties in finding the related source jar files (including recursive dependencies) manually and linking each one of them to the 3rd party jars in the project class path. I need the source to understand the 3rd party functionality better.
What is the simple way to address this issue?
Your problem is twofold:
First, you have to get (read: download) all the source jar files you need.
Second, you have to tell Eclipse how to find the source jar for a given library.
If you create an Eclipse application (a product or plug-in based on Eclipse Platform or Eclipse RCP) which uses OSGi-Bundles coming from a p2 repository, and if the p2 repository contains the sources, you can usually install the "SDK" feature of the respective project to get the sources.
However, from your question I guess that you are developing a Java application (without OSGi or Eclipse runtime). In this case, I know of no builtin feature of Eclipse which could download and attach the source code for your library jars.
As Phantom Reference said, the best way is to use a tool which is able to download all the referenced jars including their source automatically. And, yes, Maven seems to be the tool of choice, because of its automated dependency management and resolution features.
BTW, if you don't want to use Maven (e.g., because you don't know it and you don't have time to get into it), you could still manually use a Maven repository to find the source (and binary) jars of most common 3rd party libraries there.
Have a look at http://search.maven.org.
I suggest you to move to maven build tool if you are not using it already.
You can configure the maven plug-in in eclipse to do this job for you.
Here are the commands to get the source code as well as the Javadocs by maven itself from command line.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
Here is the screen shot from my eclipse Windows --> Preferences that shows how to configure Maven to download and attach the source as well as Javadocs, all automatically. Hope this helps.

(Maven+Eclipse)How each developer handle the jars locally?

I'm kinda newbie to Maven and Continuous Integration, so excuse my trivial questions below
In our project we intend to introduce the Continuous Integration through performing automated daily builds on our development integration server using Maven and hudson
on our projects we used to check-in the all the jars (internal, commercial & 3rd party) to SCM under one separate project and force the web project to depend on that project so that the project can compile in eclipse then exporting an EAR
my question is, how will each developer locally on his machine compile the project now ?, should we remove the jars project at all from scm ?
If yes : does this mean that each developer must refer to the enterprise's maven repository from within eclipse so that the project can compile ? and in that case there will be extreme NW overhead ??
If No : there might be a conflict between jars on scm and those in maven repository
another question that is related to the above one, will each developer have his own maven local repository on his machine ?
final question, shall each developer compile the code using maven (through M2Eclipse) or using eclipse compiler as normal ?
thanks :)
The way we do, and I believe is quite common, is
We have our own installation of a repository manager, for example Nexus, installed at some machine in the intranet, available for all developers to use
Jars would not be in the SCM, but stored in the Nexus or equivalent. Common arrangement is to have there one repo for external dependencies, one for internal snapshot builds and one for internal release builds (per project). We have defined maven central repository as well as the internal repositories in Maven configuration, storing the artifacts in the relevant internal repositories (external, internal-release or internal-snapshot) and picking them up from there, but having central repo as a backup for standard plugins.
Repository references (definitions, urls) are either in Maven settings file or then in the pom.xml. Individual developer should not need to do anything, he/she just uses these files. pom.xml would be in the SCM, settings file could be there or not.
Maven uses also local cache when it downloads the files, so they are downloaded only once per version/machine, which should keep the NW overhead tolerable. Intranet repo is there also partly to reduce external network overhead.
Maven release plugin is often used to handle internal-snapshot and internal-release repository updates
Each developer has a local repository cache in his machine. This is a standard Maven feature. Eclipse can refer to these same files.
Code can be compiled with the help of eclipse-maven plugin (of which M2E is the most common), using Maven on the command line or then using Maven to generate regular Eclipse project files and then normally with Eclipse. We use command line and M2E+Eclipse both for this.
SCM would be for source code, repositories for binaries (including .jars)
You configure all dependencies in the pom.xml for each project. Maven then downloads all needed jars from your enterprise repository. You don't need your SCM project any more and i would remove it.
I don't think there is much network overhead, because Maven only downloads the jars the first time they are needed. After that, they are in the local repository (which every developer has on his machine), and only updates will be downloaded after the first time.
If you use M2Eclipse, then the standard Eclipse compiler will be extended with Maven builders, so you can use all Eclipse compile features.

Managing external jar dependencies

I'v written a selenium framework which needs to be extended to the team. I've checked in the code in SVN. How can I make sure that external jars are added to build path and folder that folder by other team members? Basically I want to manage these dependencies better. Somebody said, Maven can take care of these so I tried to install m2eclipse plugin for eclipse 3.2 without any success. Can Maven solve this problem and is there any better way of managing it?
Do the easy way: commit the jars into SVN. It will save everybody a lot of time.
If you are amenable to using Eclipse, Maven, and m2eclipse, I would suggest using SpringSource Tool Suite. It is an Eclipse based IDE with Maven and m2eclipse pre-bundled. This bundling makes getting those three tools to work together very easy.