Maven Tutorial 08 - Eclipse Plugin for Maven and Maven Plugin for Eclipse

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I've mentioned earlier that maven has a modular architecture and it's comprised of a lot of plugins Eclipse is an ID that was very widely used and even that has a modular architecture there are a lot of plugins inside Eclipse and it just so happens that mimin has an eclipse plug-in and Eclipse has a maven plugin we'll have a look at both of them in this tutorial but it does make sense because even though you use maven and the command line for having a project structure using art types and things like that you won't actually be doing any coding in the command line you're using text editors you would normally use an IDE for that and once you're inside an IDE you might have to run maven command so you need you need a good integration between maven and your IDE and you know thanks to these plugins maven in Eclipse work very well together and we'll have a look at how we can use these plugins so the first thing we're going to talk about is the Eclipse plugin for maven so if I have a maven you know pom not XML here and I have the source directory here now say I want to open this inside Eclipse I can use the Eclipse plug-in in order to generate an eclipse project out of a pond or XML so what I need to do is I need to call the ambien Eclipse coolin Eclipse now note that I'm not entering the details about the Eclipse plugin in the Palm D'Or XML you don't have to mention all the plugins that you use in the build phase inside your pom dot xml may even automatically connects to the repository and checks what plugin it is the first part of the command you know gives information about what the plug-in is so it's gonna have a look at the repository and identify what they clips bloodiness and you would enter some configuration values in the Palm D'Or XML about the plug-in and that's the only reason why you would you know modify the pom dot XML if you have if you are happy with the defaults there's no reason to add the plug-in details in your pom dot XML so I'm okay with the defaults here I just warned Eclipse plug-in to create an eclipse project so that I can open up the source code inside Eclipse so I press Enter so again Minh is going to look at the repository and download the plugins and the components required for running this command okay so it's finished the download and here you can see it's there's an info message it says wrote the eclipse project from my web app at this location which is the web and my web app so this is the location where the eclipse project has been created and since the files are hidden by default if I do a show hidden files I can see the dot class path in the dart project that has information to eclipse about how to open this project in the workspace so now what I'll do is I'll open eclipse and I will open this project location inside of Eclipse so I don't have to do imports and things like that now what I do is inside eclipse I just open the project as if it were a project that was created in Eclipse itself okay so I'll say file import and the same existing projects I don't have to do any configuration it's already an existing project so I will choose the root directory just my web app I say ok now it detects that there is this my web app project so when I say finish it's going to open this up all the configurations are in place no matter what all configurations you have in your palm dot XML all those will get imported in some cases you might see an error here here you see a red exclamation point and there will be errors and it says unbound class path variable m2 underscored repo so what's happening is the jars that this project is referring - since it's coming from the maven repository eclipse does not know what the maven repository is now let me just right-click properties so here you go the the libraries is from M to underscore a poem to underscore it was available which needs to be substituted with the actual value of the repository now the repository is most flames it's in the home folder with the underscore I'm sorry it's dot M - yeah here it is dot M - repository so this is the this is the directory location which the M to underscore repo variable should point to so what I will do is here I'll add a variable and the say configure variables create new one m to underscore repo and this will be slash dot m2 and repository okay I can also choose the folder here and I can configure the same thing here but yeah here you go just press ok so it's the same thing now I'll say ok done now it says the classpath variables have been changed you want to do a full build yes say ok and ok again now it's going to do a full build and that error is going to go away of course this is a code related error but the variable error that was there there's no longer showing up and since we are given the location of the repository it knows where to pull up these jars and it's referenced those jars accordingly ok so now we have imported the project inside eclipse but now the problem is we have to run any maven commands I would still have to go to the command line this may I can run it inside eclipse so here what we will do is we will install a maven plugin for Eclipse so this plug-in which is called the m2 Eclipse plug-in will help us run maven commands inside Eclipse itself and you know once you have the plugin inside Eclipse if eclipse is your main development environment you wouldn't you won't ever want to go and run commands in the command line everything can be accomplished in the GUI and it makes life a lot easier so we'll install the m2 Eclipse plug-in now so what we do is in Eclipse menu the health menu you would go and there's this minimal I entry here called install new software just click on that and here what we need to do is we need to enter the site where the m2 Eclipse plug-in is available now if I just look at what all are available I'll say all available site and m2 Eclipse sites are also available here so I will just say search everything and I select all available sites everything comes up and I can search here I will search for maven so there are a few plugins which have the word maven in it this is what I'm looking at maven integration for Eclipse so I'll just choose this one there are a few extras and a few other plugins we're not going to worry about that for now I'll just use this main plug-in lets say next so it's gonna gather all the dependencies and it will install ok so this is the only plugin that's required press next again and it's gonna you know there's a license terms and if you agree click on accept and press finish now it's going to download and install the clips plug-in and after the installation it's gonna prompt for a restart it's better to restart eclipse is gonna restart and the m2 Eclipse plug-in will start working now man eclipse loads up after installation I see this overview screen where there's a new entry which talks about the maven integration for Eclipse you can probably read through some of the stuff here but I'll go to the workbench now the few of the benefits of having this em--to Eclipse plugin is that first of all you can run maven commands from the Eclipse IDE so if you go to the bomb load XML you right-click you have this entry for maven and you see this IDE dependency at plug in new maven module so all these maven commands can be run over here and then when you go to the runners menu so here you see you have a few entries for me when you have a maven build may even clean maven install naman package so all these correspond to with the mvn commands that will run in the camp and you know in the command line so I may even build would be a build commander maven clean would be ambient clean let me even install me even package old corresponds to M be an install and mean package commands so this is something you can use to directly run the maven commands another benefit is you can search for dependencies you can search for artifacts right from the maven I write from the Eclipse ID and this is something that we're going to look at in the next tutorial
Info
Channel: Java Brains
Views: 228,429
Rating: undefined out of 5
Keywords: maven, build, apache, tutorial, technology, computers, java, free, j2ee, ee, educational, eclipse, tomcat, javabrains, brains, koushik
Id: xE2F4Z_wKCU
Channel Id: undefined
Length: 10min 10sec (610 seconds)
Published: Wed Jun 15 2011
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.