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

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.

Related

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.

Two Eclipses on same Maven repository

I have one single external installation of Maven 3.0.4 and two Eclipses (Juno and Indigo) referring it in their m2e settings.
Also I have one single user setting file which describes one single local repository. Both Eclipses refer it.
I have a problems with Maven which can be suspected as conflict between Eclipses.
For example, one of Eclipses (say Indigo) can be blind concerning some global repository (say central). This means that it's subnodes in "Maven Repositories" view of eclipse are empty
Updating/Rebuilding index does not help and probably does nothing since ends very fast.
Reloading settings also does not help.
The question is: is it possible to use one single maven with several Eclipses? Is it possible that principal multiuser system does not support multiusing?
Where the data can be corrupted?
You would be better of ignoring the Eclipse specific installs of Maven.
I have found that relying on pre-installed software on Eclipse, leads to problems for the following reasons.
You will never know exactly what version of maven they have installed and why (finding out is harder than installing yourself)
If it won't run in the IDE, what chance will your build server have (and you will meet those problems in Jenkins or your CI server when it comes to release time)
It is very easy to install Maven yourself and run it from the commandline and less problematic.
http://maven.apache.org/download.cgi
If there is a team of developers using maven think about hosting it yourself on a nexus server.

Is there a way to develop OSGi bundles without opening or importing the dependent bundles in Eclipse?

When you develop OSGi bundles using eclipse, there are many denpendent bundles to be imported and opened. When there're many bundles, setting up projects is time-comsuming and difficult, especially to newbies .
I've tried the Tycho plugin and m2e; it seems that they are not for this goal.
You can use Eclipse Target Platform concept.
Moreover, with some luck and persistence, you can use remote P2 site as a Target Platform definition in Eclipse. Since you can export Target Platform definition as a file, that means the whole setup for developers will be importing project with that file and selecting this target platform in Eclipse preferences. The Eclipse will download the whole bunch of dependencies itself. For more details see the blog post here.
Also, since you can use that P2 site as a repository for Tycho builds, that allows you to make Tycho use the same set of dependencies as you use in Eclipse making the build more stable. You can host P2 site as a static web content or use repository, like Nexus (however, only commercial version supports P2 repositories, so I have not tried that myself).

Eclipse Automatically Download / Update JAR files

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/

How to integrate maven the right way into Eclipse and into the software development process?

I am new to maven. The main feature I benefit from, yet, is the automatic dependency management. The standardized directory structure seems also to be nice, but Eclipse has a standard directory structure, too. The directory structure is now independent from Eclipse, but now it is dependent from maven. OK, I see, both programs seem to be quite flexible at this point.
I am not quite sure, if maven is more dedicated to servers or to client systems, e.g. there is a feature / plugin to generate a project website. Doesn't this make most sense on a server system?
How to integrate maven with a version control system (VCS), e.g. SVN? I think of a system where there is a repository and always up-to-date website with download section for development artifacts.
How to integrate maven with Eclipse? I'm now using m2eclipse with WTP integration. Its ok, but it has some behaviors that I don't like, e.g.:
When I generate new Java projects the JRE version is set to 1.4 . I have to reset it to 1.6 / workspace default manually.
Facets configuration is not stable. Some configurations have to be done manually and in a specific order.
Maybe I can fix them if I read more about it. And I have a more or less serious problem with its WTP extension. I think its important to say, that the WTP extension is not officially supported and may not have production quality.
I know there is another plugin which integrates maven into Eclipse. I did not try it, yet. Is it better?
Also I think, that maven may be useful for much more areas. For example the directory structure could be extended to hold e.g. requirements, specification and modeling artifacts. I think that would only work, if it would be standardized. Revision control for all documents would be nice, too.
So many thing, that could be integrated to support the complete software development prosess. Maybe its unrealistic, to get all of these features. For now the Eclipse integration with WTP and VCS integration have the highest priority for me.
Any suggestions? Thanks in advance.
The directory structure is now independent from Eclipse, but now it is dependent from maven. OK, I see, both programs seem to be quite flexible at this point.
Yes, they are both flexible so we could bend one or the other. But if I had to choose a layout, I would pick the IDE agnostic one i.e. the Maven layout and I would stick to the defaults to minimize the efforts and because they are well known (so anybody familiar with Maven knows where to find things). And if someone wants to use IntelliJ IDEA or NetBeans because he feels more productive with it, he can do it. In other words, I don't see any benefit to use the Eclipse layout.
I am not quite sure, if maven is more dedicated to servers or to client systems, e.g. there is a feature / plugin to generate a project website. Doesn't this make most sense on a server system?
Maven can be used for local builds on developer machines, for central builds on a continuous integration machine. And things like generating a website, deploying artifacts are usually done on the central server.
How to integrate maven with a version control system (VCS), e.g. SVN? I think of a system where there is a repository and always up-to-date website with download section for development artifacts.
I didn't really understand the first part of the question. How do you want to integrate Maven with SVN exactly (there is the maven-release-plugin but I'm not sure that's what the question is about)? For the second part, the traditional approach is to use a continuous integration server to trigger a build after a change in the VCS and to deploy (in the maven sense) the created artifacts to a "corporate repository". Many people use Hudson as CI server.
When I generate new Java projects the JRE version is set to 1.4 . I have to reset it to 1.6 / workspace default manually.
That's because the maven project itself is not configured to use 1.6 level (the Eclipse configuration is derived from the POM, which makes sense). You have to configure the maven compiler plugin for 1.6. Here is one way to do it (there are plenty of previous questions on this topic):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
And then update your project configuration under Eclipse via right-click then Maven > Update Project Configuration.
Facets configuration is not stable. Some configurations has to be done manuel and in a specific order.
They are for me and again, they are derived from your POM (e.g. from the version of your web.xml).
And I have a more or less serious problem with its WTP extention. I think its important to say, that the WTP extension is not officially supported and may not have production quality.
Huh? Where did you read this? Works fine for webapps for me.
I know there is another plugin which integrates maven into Eclipse. I did not try it,yet. Is it better?
I don't have experience with Eclipse IAM. But what is your problem with m2eclipse?
Also I think, that maven may be useful for much more areas. For example the directory structure could be extended to hold e.g. requirements, specification and modeling artifacts. I think that would only work, if it would be standardized. Revision control for all documents would be nice, too.
You're free to put whatever you want in your project tree. Many people are doing this and referring to docs from the site. Possibilities are endless.
Some random points to push you in the right direction:
The standardized directory structure seems also to be nice, but Eclipse has a standard directory structure, too
Eclipse does not have a "standard" directory structure. For example, some people put their unit tests in src next to their code, and others put it in a separate dir like tests or test. You can configure either up as much as you want, but Maven follows has defaults that almost everyone follows:
source in src/main/java
tests in src/test/java
resources necessary for running in src/main/resources
language files
Spring config files
resources necessary for running tests
golden results
config files in src/main/config
Eclipse is an IDE, and Maven is a built build management tool
case in point: if you ask Eclipse to build a JAR/WAR, you have to manually tell it what to include and where. Because you placed your files in Maven's defaults, you get things like:
JARs/WARs contain the compiled Java classes from src/main/java, but not the ones from src/test/java
config files from src/main/config don't go into the JAR/WAR (kinda defeats the purpose of a config file if it did)
test resources from src/test/resources don't go into the JAR/WAR
if you decide to build an assembly (Maven speak for a distribution of your code you can put on your website that includes documentation, source, binaries, etc.), it can make a JAR, the config files, and javadocs into a ZIP file.
I am not quite sure, if maven is more dedicated to servers or to client systems, e.g. there is a feature / plugin to generate a project website.
Yeah, the Maven site plugin.
Doesn't this make most sense on a server system?
Not really. Documentation is critical for any project, especially for client systems.
Maybe I can fix them if I read more about it. And I have a more or less serious problem with its WTP extention. I think its important to say, that the WTP extension is not officially supported and may not have production quality.
Because Maven integration with Eclipse via the m2eclipse plugin isn't perfect, I actually won't use it for WTP projects. I use the Maven Eclipse plugin to generate Eclipse project files and then import the project as a regular Eclipse project. The downside is that the Eclipse project files have to be re-run after any significant changes to the project.
Revision controll for all documents would be nice, too.
That's not Maven, or any build management tool. That's your SCM, Subversion or whatever.
When I generate new Java projects the JRE version is set to 1.4 . I have to reset it to 1.6 / workspace default manually.
You can set that through Maven.
Maybe its unrealistic, to get all of these features. For now the Eclipse integration with WTP and VCS integration have the highest priority for me.
The m2eclipse plugin and friends work best for simple Java Maven projects. Personally, I use the Maven eclipse plugin to generate an Eclipse project for any web, EJB, etc. projects.
There's downsides to that as mentioned earlier, but the upsides, including dependency management as you mentioned, outweigh them, IMHO.
Of course, a poorly configured Maven project is still a poorly configured project. It's not magic. :)