Selena+Maven best practices

Hi,

I'm wondering what are the "best practices" for a Selena+Maven combination. I'm starting a new webapp project, and I would like to use maven for the build system. However, it seems to be difficult to make cohabit. For now, here's what I've done :

- create a new project from scratch. As I wanted to use Maven, I used src/main/java as the java directory, then chose some dependencies. IJ created the following :
.
|-src/main/java
|-web
|---|-WEB-INF
|-lib
|-... some libs

etc...

I had to refactor the "web" directory in order to make it fit the standard Maven directory : moved to src/main then renamed it to "webapp". Ok, seems good.

Now, I created a pom.xml file which described my dependencies. For tests purposes, I added an hibernate-annotations dependency, then built my project with Maven. All went fine : the integrated plugin downloaded all required, and created the build directory with the dependencies.

What I am now wondering is how I can keep in sync with Selena : if I manage my libs with IJ, then I'll have to manually setup all dependencies, and I loose most of the advantages of using Maven. If I use Maven, then the dependencies are downloaded at build time, and IJ won't recognize the "missing" classes (imports) and I loose the interest of using IJ.

Question is how to get IJ in sync with the libraries Maven is able to download by itself ? I could duplicate the libs, but I would be non sense : every version change would require that I update the IJ project structure in order to keep the libs in sync. Is there any cleaner way ?

Thx.

6 comments
Comment actions Permalink

Cedric Champeau wrote:

Hi,

Question is how to get IJ in sync with the libraries Maven is able to download by itself ? I could duplicate the libs, but I would be non sense : every version change would require

that I update the IJ project structure in order to keep the libs in sync. Is there any
cleaner way ?

Whenever I change the dependencies in the pom I do a "mvn idea:idea". That updates the
dependencies for IJ.

When invoked for the first time it creates the idea project files (*.ipr, *.iml, *.iws)

Whats lost when doing this, are the Module-Settings for Groovy source-folders and
test-folders. I wonder whether this is a bug in the jetgroovy-plugin, the idea-maven-plugin
or even the groovy-maven-plugin?


Dirk

0
Comment actions Permalink

Thanks, but for this project, I'm not using (I should say "for now") Groovy. I was thinking of the default Maven integration, which seems to collapse with the library definition in a project file. I'm using the bundled Maven plugin in M2. But I guess if I try the groovy maven plugin I could do the same.

0
Comment actions Permalink

I'm not sure I understand your problem, if you're using the IDEA bundled maven integration, IDEA defines all lib references all by itself, according to your pom.

0
Comment actions Permalink

mmm... do you mean there's a bug and that IJ should keep the pom in sync with the project ? Maybe I've done it the wrong way, and that I should start from a POM, and not create a POM after having created a project in IJ...

0
Comment actions Permalink

Here it goes, you were right : you must start from a POM, and not create it lately.

0
Comment actions Permalink

whenever you update your pom and want your modifications taken into account, you'll need to click the update button in the maven projects tab

0

Please sign in to leave a comment.