MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
stiggs
Post subject: Integrating Maven with your MyEclipse Webapps...  PostPosted: Mar 17, 2008 - 01:07 AM
Registered Member
Registered Member


Joined: Sep 25, 2005
Posts: 8

Here is how I have integrated my maven builds with myeclipse.

Install the maven integration for eclipse - http://m2eclipse.codehaus.org/

Create a new Maven project (File -> New -> Project -> Maven -> Maven Project)

Set your packaging to war, and check off "/src/main/webapp" in the Project Layout section.

Once the project is created, right click, and go to Properties -> Java Build Path -> Libraries -> Add Library -> MyEclipse Libraries,
click Next and select J2EE 1.x or Java EE 5 libraries

Now, shutdown Eclipse and open up the .project file in your favourite text editor.

Now, I modified the .project file to add the MyEclipse natures back in. (Make sure to change the <name> node value to your project name)

<!-- START -->
Code:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
   <name>SampleWeb</name>  <!-- this is your project name -->
   <comment></comment>
   <projects>
   </projects>
   <buildSpec>
      <buildCommand>
         <name>org.maven.ide.eclipse.maven2Builder</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>org.eclipse.jdt.core.javabuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>org.eclipse.wst.validation.validationbuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
      <buildCommand>
         <name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>
         <arguments>
         </arguments>
      </buildCommand>
   </buildSpec>
   <natures>
      <nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>
      <nature>org.eclipse.jdt.core.javanature</nature>
      <nature>org.maven.ide.eclipse.maven2Nature</nature>
      <nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>
   </natures>
</projectDescription>
<!-- END -->


Now, open up eclipse, right click on the project, and go to Properties -> MyEclipse -> Web -> ContextRoot and set your context root.
You'll notice that the Web-root folder is still set to /WebRoot so this has to be changed.
Go back to your filesystem, and open up your ".mymetadata" with your text editor. Change this:

<attributes>
<attribute name="webrootdir" value="/WebRoot" />
</attributes>

to this:

<attributes>
<attribute name="webrootdir" value="/src/main/webapp" />
</attributes>

Now, you have to restart MyEclipse again. Almost there, just a few more steps.

Create WEB-INF, WEB-INF/lib and WEB-INF/classes directories under /src/main/webapp and put in your web.xml file.

Right click on your project, go to Properties -> Java Build Path -> Source and set your output folder to /src/main/webapp/WEB-INF/classes

Now you're ready to go. You can deploy your web project to a server, and you can also do your maven builds.
 
 View user's profile Send private message  
Reply with quote Back to top
support-rkalla
Post subject: RE: Integrating maven with your webapps...  PostPosted: Mar 17, 2008 - 10:28 PM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23824

stiggs this really kicks ass man, thanks for taking the time to post it. I'll mark it as sticky for other folks that are curious.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
stiggs
Post subject: RE: Integrating maven with your webapps...  PostPosted: Mar 17, 2008 - 10:34 PM
Registered Member
Registered Member


Joined: Sep 25, 2005
Posts: 8

No problem, it would be nice if in a future release, this could be automated.
 
 View user's profile Send private message  
Reply with quote Back to top
ayang
Post subject: RE: Integrating maven with your webapps...  PostPosted: Mar 18, 2008 - 03:15 PM



Joined: Mar 14, 2008
Posts: 25

stiggs - have you tried the q4e plugin? i'm just getting started with it myself and the deploy issues I'm running into may necessitate similar metadata hacking, but the dependency analysis/view features are oh-so-delicious.
 
 View user's profile Send private message  
Reply with quote Back to top
stiggs
Post subject: RE: Integrating maven with your webapps...  PostPosted: Mar 19, 2008 - 03:32 AM
Registered Member
Registered Member


Joined: Sep 25, 2005
Posts: 8

I haven't even heard of q4e until now. THere aren't enough hours in the day to keep learning all this new stuff. I find what I have now is sufficient. The dependancy graphing looks kinda cool, but I tend to use a lot of the same libraries and I already know what their dependancies are, or I don't really care :-) Maybe I'll post a message one of these days describing all the project files that get created, and how to modify them.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits