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

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. :)

Related

Eclipse project structure ANT and MAVEN

I am trying to set up a project, but feel completely overwhelmed with lack of knowledge. In university we used netbeans which resolved project structure gently for us. As community leans towards eclipse I am trying to migrate there, but feel myself like a penguin not able to fly. I can't understand project structure where and what has to be added, do I have to define ANT or MAVEN manually in eclipse can they be integrated? Where to go ? Apache manuals are so complicated, why is that I can program in Java , but don't know the fundamentals, soo depressed, please anyone guide me. I find pieces on web, but seems can't build full picture in my head.
You have a couple of options. Basically, eclipse uses a workspace, which contains one .metadata directory used by the plugins and all of the project folders. Projects can then be things like java projects, PDE projects, PHP projects, etc.
There is maven integration in eclipse which I would use, http://www.eclipse.org/m2e/ It was part of Indigo, which released June 2011.
Set up your java projects in your workspace, and then use m2e to mavenize them, or use m2e to generate the java projects into your workspace.
maven provides a facility to create a new project with the required structure based on the type of project (jar, war, etc.).
You can do this or achieve it directly from Eclipse as suggested by Paul Webster, by installing the m2e plugin.
This structure can then be easily built using maven, as well as developed in Eclipse.

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.

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/

JavaRebel with a Multi-module Enterprise Project in Maven

Does anybody have experience working with JavaRebel, specifically for a large web application built using Maven? There is a JavaRebel plugin for Maven that seems under-documented, does anybody have comments on how it works, can you really update one class in a Multi-module Enterprise Project and have it "automagically" change on your Server?
Are there any issues with different IDEs and this setup? For example NetBeans will not let you compile one class at a time in a Maven project (from what I can tell).
Disclaimer: I work for ZeroTurnaround.
JRebel (formerly JavaRebel) installation involves the application configuration file "rebel.xml" and modifying the container startup command line.
The Maven plugin is used to generate the "rebel.xml" file, that is used by the JRebel agent running in the container to find the files in the workspace. This allows to use IDE building to compile .java files and skip the Maven build process, as the changes to files will be picked up from the workspace. However as it relies on the IDE to compile the classes, it does depend on the IDE ability to compile efficiently. I know for sure that Eclipse will compile classes one at a time and am fairly sure you can configure NetBeans and IntelliJ IDEA to do the same.
In addition to the Maven/rebel.xml configuration you also need to configure the container startup command line. You may also need to install and IDE plugin or do some additional configuration to have the best expirience with JRebel. Following through the steps of Installation manual ensures that.
Hope this helps.
Disclaimer: I've not actually used this plugin myself.
This tutorial implies that JavaRebel works well with Eclipse 3.4. If you are also using m2eclipse it should work ok with Maven projects as well (as long as you ensure that Maven and Eclipse are compiling to the same target folder so the Eclipse incremental compiler can be used to modify the class file).
According to this post, you should configure the javarebel-maven-plugin to generate the rebel.xml (used to mount external folders to the application classpath). There's also a general installation guide you may find useful.

Maven2 Eclipse integration

There seem to be two rival Eclipse plugins for integrating with Maven:
m2Eclipse
and
q4e.
Has anyone recently evaluated or used these plugins?
Why would I choose one or the other?
Side by side comparison table of three maven plugins.
There is only one point where q4e is actually better: dependency viewer. You could see the dependency tree, manage your dependencies visually and even see them in a graph. But, m2eclipse works in a better way, specially because you can create you own build commands (in the run menu). q4e comes with some predefined commands and I can't find where to define a new one. In other words, m2eclipse is more friendly to the maven way.
I have been using m2Eclipse for quiet some time now and have found it to be very reliable. I wasn't aware of q4e until I saw this question so I can't recommend one over the other.
My 2cents,
I am using eclipse for some months now with m2eclipse integration. It's easy to use and straight forward. Once you associate your project to maven and update the dependencies using m2eclipse, any change to pom.xml are reflected to entire project, even Java version definition causes it to be compiled in right JRE (if you have it installed, and properly configured into eclipse.)
Another advantage I found is the maven plug-ins are easy to use integrated with eclipse (jetty being my best example, again, properly configured you can easily integrate maven, jetty-plug-in and Eclipse Debugger)
Compilation, packaging and all other maven features are equally easy to use with a couple clicks or shortcuts.
About q4e I have been reading a lot of good stuff about it and seems the next versions will do a lot more than m2eclipse, with a better dependency management and even visual graphs (!) but the general opinion is that m2eclipse is still better than q4e but q4e is getting better each new version and maybe will surpass m2eclipse soon.