maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Coco <ma...@stevencoco.com>
Subject Re: m2 plugin config problems with eclipse
Date Thu, 05 Jan 2006 20:07:08 GMT
Hi.

I'm really new with Maven myself, but I'm also completely unaware of any
utility that the eclipse Maven plugin actually provides!  I can tell you
how I am using Maven in eclipse:

1. Set up eclipse's build path to 'mirror' the Maven settings.
2. Set up basic 'External Tools' to run maven tasks.
3. "Import" these basic external tools into your project as "builders"
and disable the default Java builder.

With this setup, the Maven plugin is providing no real utility.  But I
can use Maven from eclipse commands and it works just like from the
command line.  Here's the gory details of setting up eclipse:

The first thing I did was go ahead and install the Maven plugin.  I
wrote my POM by hand.  Then in eclipse, right-click the project and
choose Maven/Update Source Folders to get a start on having the eclipse
build path set up as it is declared in your POM.  Then go to the project
properties and tweak the build path by hand.  This allows eclipse to
correctly identify "source code" items in the package view.

Now, to set up the builder, first use this bizarre eclipse feature:  In
preferences, under Run/Debug, add a "String Substitution".  Choose the
folder that contains your Maven executable [mvn.bat on my windows
machine].  Name this whatever you like; I called mine "Maven bin".
Apparently it doesn't even matter.  When you set up an external program,
eclipse will automatically search within this directory for an external
program if you prompt it.  This is completely bizarre.  But, save your
preferences.

Go to the external tools menu and add a new "Program".  The "Location"
should be:  ${system_path:mvn.bat}  And as I said, eclipse will search
in that folder you chose above and find that there is a "mvn.bat" in
there, and this will execute when you run this tool.  Now, set the
"Working Directory" to ${project_loc}  Set arguments to whatever goal
you want: clean, compile, package...  Then on the "Refresh" tab I set it
up to refresh the 'project containing the selected resource'; and on the
"Common" tab I have it saved as a "local file" and I select "Display in
favorites menu".

Duplicate this task for each Maven goal you want easy access to:  Be
careful you don't make it too easy to execute something potentially
dangerous: don't add such tasks to the favorites menu; and force
yourself to have to open the dialog to run those when you need them.
Remember too that if you have two projects open, these will run on the
project that "contains the selected resource" so you don't want to
mistakenly run some goal on the wrong project.  You can also opt to have
none of these in the favorites menu, or dispense with creating these
external tools and specify them each time for each new project as I
explain below.  It seems a bit useful to have them around at least as
templates though.

OK.  No you have tasks that you can run by selecting your project and
then choosing the tool from the external tools menu.  It will execute in
your project's directory just like from the command line -- more
specifically, as I said, it will execute in the directory of the
"project that contains the selected resource", so be careful.

Now go back you your project preferences if you want to, and import
"Builders" for the eclipse clean and build commands.  Choose "Import"
and import your Maven-clean command for instance.  You wind up with a
copy of the task you imported, but it is probably safer to run since you
are sure this one only runs on the project you have in fact selected to
"clean" or "build" from the eclipse menu.  And you set the "Build
Options" so it executes on the appropriate command.

So that's the whole story from my "workbench"...

Frankly I am liking this mode of working a bit.  I did the same thing
with Ant, which is:  If you build with an external tool in eclipse, then
eclipse doesn't get so "sticky" with errors in your package view and
editors.  By that I mean: when you "build" with eclipse's default Java
builder, if you have errors, most of the time on non-trivial projects
you have to clean the project to have it truly recognize any changes you
make and to be sure all the up to date classes are being loaded here and
there.  Using Maven or Ant frees the eclipse editor to attempt to behave
[sensibly] and dynamically parse the source in place instead of doing
some incremental compiling or whatever the heck it is all doing in
there!  Basically I have to do less double-checking of the IDE and it
has become more useful.  But mileage varies.......

Good luck in any case!

Regards,
Steev Coco.


Roland Oertig wrote:

>Hi
>
>I downloaded and use the maven-plugin offered on the Appache
>http://maven.apache.org/eclipse-plugin.html .
>
>After having spent hours "googeling" around, to try to find some documents
>or hints how to use the m2 plugin in eclipse with run--> external tools -->
>m2 build in the popup window "Create, manage and run configurations", I have
>to give up and hope that one of you guys can help me.
>
> 
>
>In the eclipse Windows --> Preferences --> Maven2 I set the local Repository
>folder to C:\maven-2.0.1
>
>and to Java --> Classpath Variables I added M2_REPO and MAVEN_REPO (just to
>be sure) to point to my local repository (e.g. E:\maven\localrepository)
>
> 
>
>Next I try to start a maven goal through the run --> external tools:
>
>I entered the base directory (e.g. E:/myApp) and goal (e.g. install) in the
>requested fields.
>
> 
>
>It return immediately with an information in the border of the console view
>window, like:
>
><terminated>myApp[m2 build}
>C:\Program\Java\jre1.5.0\bin\javaw.exe(05.01.20006 14:20:34)
>
> 
>
>I tried to also write the output to a logfile but nothing gets written
>there, but the file gets created. The only info I get on the console is:
>
>[Console output redirected to file:E:\HotelDatabase\maven_eclipse_run]
>
> 
>
>If I run m2 from the windows command line everything goes perfect.
>
> 
>
>I appreciate if someone can help me and give me glue on what I missed!
>
> 
>
>Thanks in advance.
>
>Cheers
>
>Roland
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message