Eclipse 3.4 ganymede gave me a VERY frustrated day yet again :(
I spent most of the day convincing it to to install the m2eclipse plugin.
It kept on telling me:
No repository found containing: org.maven.ide.components.dependency_tree/osgi.bundle
So after updating all my eclipse plugins and also using the
Maven Integration for Eclipse Dev Update Site and restarting Eclipse, it finally decided it will install.
(You almost want to swear at it and call it M$ Eclipse. Ok it wasn't that bad.)
Next I came to a painful catch 22: I want a Dynamic Web Project so that my code can be automatically deployed on my Glassfish server. But I also want it to be a Maven project for all the maven goodness, without changing the standard maven code layout.
I googled for hours but I only found my worst fear to be true: The only way to do it is to make it a web project, changing its structure to be in the maven layout and then activate it as a maven project. I improved on
this site's methods a bit by doing some configs up front and thus avoiding to mess with them later. Here are my steps as good as I remembered:
- (I created a reference maven web project in eclipse, but it turned out that I didn't actually need it)
- Create a new Eclipse Dynamic Web Project. Don't click finish, click [next].
- Set the 'Content Directory' to 'src/main/webapp' and the 'Java Source Directory' to 'src/main/java'. Now you can click [finish].
- Right click on the project -> Maven -> Enable Dependancy Management.
- Set the packaging to war, [finish].
- You can delete the build folder now since maven already started to use the target folder.
If you need the other standard maven source and target folers, you can add them manually or directly in .classpath:
<classpathentry kind="src" path="src/main/resources">
<classpathentry kind="src" output="target/test-classes"
path="src/test/java">
<classpathentry kind="src" output="target/test-classes"
path="src/test/resources">
- From there I just had to set maven to use Java6 in pom.xml:
<build>
<pluginmanagement>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-compiler-plugin</artifactid>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginmanagement>
</build>
- Right click on the project -> Maven -> Update Dependancies.
- I removed the following from .settings/org.eclipse.wst.common.component:
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/
>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/
>
- Then I could run maven tasks and also deploy it to my glassfish server (already set up to be managed by eclipse the normal JavaEE way (run as -> run on server))
sweetness! I love Eclipse+JavaEE+maven again.
I think the WTP or whatever does the new 'Dynamic Web Project' wizard would do well to have a checkbox which can setup the web project in the maven sturcture for you.
tomorrow (aka later today) I have to do the real work of actually putting an application into this empty shell.
goodnight