You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2005/10/31 19:21:40 UTC

svn commit: r329875 - /maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt

Author: jvanzyl
Date: Mon Oct 31 10:21:35 2005
New Revision: 329875

URL: http://svn.apache.org/viewcvs?rev=329875&view=rev
Log:
o checking eclipse ide guide sent to me by Bernd Mau <Ma...@hhla.de>

  Kenney, Vincent, do you think you could take a look at this. I'm not
  an Eclipse user.


Modified:
    maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt

Modified: maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt?rev=329875&r1=329874&r2=329875&view=diff
==============================================================================
--- maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt (original)
+++ maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt Mon Oct 31 10:21:35 2005
@@ -1,17 +1,233 @@
  ------
  Guide to using Eclipse with Maven 2.x
  ------
- Jason van Zyl
+ Bernd Mau, mau@hhla.de
  ------
- 12 October 2005
+ 28 October 2005
  ------
  
 Guide to using Eclipse with Maven 2.x
 
- To generate the Eclipse project files from your POM you execute the following command:
+ This mini guide explains howto use Maven 2 in Eclipse IDE.
 
+ * {{{#Maven 2 repository}Maven 2 repository}}
+
+ * {{{#Maven as an external tool}Maven as an external tool}}
+
+ * {{{#Simple Project}Simple Project}}
+
+ * {{{#Multiple Module Project}Multiple Module Project}}
+
+* {Maven 2 repository}
+
+ Eclipse needs to know the path to the local maven
+repository. Therefore the classpath variable <M2_REPO> has to be
+set. Execute the following command:
+
++----+
+
+mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo 
+
++----+
+
+ You can also define a new classpath variable inside eclipse: From the
+menu bar, select Window > Preferences.  Select the Java > Build Path >
+Classpath Variables page.
+
+ <<Issue:>> The command does not work. Aside from it should not require a POM.
+
+* {Maven as an external tool}
+
+ You might want to execute some maven goals from inside eclipse. This
+is possible by configuring an external launcher. It is best practice
+to prepare eclipse by adding a variable, which points to your local
+maven excutable (mvn.bat/mvn). From the menu bar, select Window >
+Preferences.  Select the Run/Debug > String Substitution. Add a new
+variable e.g.  <maven_exec>. When you set up a new external launcher
+(from the menu bar, select Run > External Tools. Select Program) you
+can refer to <maven_exec> in the location field. Furhtermore refer to
+<project_loc> as the working directory and specify the maven goals of
+your choice as arguments, e.g. <eclipse:eclipse>. For further
+information please refer to the eclipse help.
+
+ <<Issue:>> Would be nice, if the plugin generates the variable and a runner.
+
+
+* {Simple Project}
+
+ If you have a simple java project which is made up of only one
+module, using eclipse is very simple. To generate the eclipse project
+files from your POM you execute the following command:
+
++----+
+
+mvn eclipse:eclipse
+
++----+
+
+ If you have created or checked out the project with eclipse, you only
+have to refresh the project in your workspace. Otherwise you have to
+import the project into your eclipse workspace (From the menu bar,
+select File >Import >Existing Projects into Workspace). In the
+latter case the project (directory) should not be located in your
+workspace, because eclipse might come into trouble, especially if you
+want to use eclipse as the scm client.
+
+* {Multiple Module Project}
+
+ Due to the workspace idea many eclipse users are used to a flat
+layout and therefore want to keep this structure, which is possible
+but not recommended.  Actually, the only reason for a {{{#Flat Project
+Layout}flat multiple module project layout}} is the possibility to
+checkout and edit the parent POM without checking out the whole
+project. The following sample shows how to handle maven multiple
+module projects with eclipse while keeping the
+{{{http://maven.apache.org/guides/mini/guide-multi-module.html}recommended
+hierachical project layout}}.
+
+
+** {Step by Step from Scratch}
+
+ Supposing eclipse is your favorite SCM client, this step by step
+example shows how to set up a new mutiple module project.
+
+ [[1]] Set up a new eclipse workspace called <step-by-step> and add
+the <M2_REPO> classpath variable as {{{#Maven 2 repository}described
+above}}.
+
+ [[1]] Open the command line shell and change to the newly created workspace directory.
+
+ [[1]] From the command line change to newly created <step-by-step>
+workspace and create a new maven project using the archetype plugin.
+
++----+
+mvn archetype:create -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse
++----+
+
+ [[1]] Create a new simple project <guide-ide-eclipse> inside the
+<step-by-step> workspace with eclipse (From the menu bar, select
+File >New >Project. Select Simple >Project). Eclipse will
+create a simple <.project>-file for your <guide-ide-eclipse>-project
+and you should be able to see the <pom.xml>-file.
+
+ [[1]] Delete the <src>-folder and open the <pom.xml>-file to change
+the packaging of your parent project to <pom>
+
++----+
+  <packaging>pom</packaging>
++----+
+
+ <<Issue:>> mvn eclipse:eclipse may should generate a simple
+<.project>-file for pom types.
+
+ [[1]] From the command line change to the <guide-ide-eclipse> project
+directory and create some modules.
+
++----+
+cd guide-ide-eclipse
+mvn archetype:create -DgroupId=guide.ide.eclipse -DartifactId=guide-ide-eclipse-site
+mvn archetype:create -DgroupId=guide.ide.eclipse.core -DartifactId=guide-ide-eclipse-core
+mvn archetype:create -DgroupId=guide.ide.eclipse.module1 -DartifactId=guide-ide-eclipse-module1
++----+
+
+ [[1]] Add the newly created modules to your parent pom.
+
++----+
+  <modules>
+    <module>guide-ide-eclipse-site</module>
+    <module>guide-ide-eclipse-core</module>
+    <module>guide-ide-eclipse-module1</module>
+  </modules>
++----+
+
+ [[1]] Add the parent to the POMs of the new modules:
+
++----+
+  <parent>
+	<groupId>guide.ide.eclipse</groupId>
+	<artifactId>guide-ide-eclipse</artifactId>
+	<version>1.0-SNAPSHOT</version>
+  </parent>
++----+
+
+ [[1]] Add dependency from <module1> to the <core>-module:
+
++----+
+    <dependency>
+      <groupId>guide.ide.eclipse.core</groupId>
+      <artifactId>guide-ide-eclipse-core</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
 +----+
 
+ [[1]] Install the project in your local repository and generate the eclipse files:
+
++----+
+mvn install
 mvn eclipse:eclipse
++----+
 
+ [[1]] Check in your project using the eclipse team support (select
+from the context menu Team >Share Project). <Note:> Don not check
+in the generated eclipse files. If you use CVS you should have a
+<.cvsignore>-file with the following entries for each module:
+
++----+
+target
+.classpath
+.project
+.wtpmodules
 +----+
+
+ Even the parent project should have this <.cvsignore>-file. Eclipse
+will automatically generate a new simple <.project>-file when you
+check out the project from the repository.
+
+ <<Issue:>> Plugin should optionally generate the <.cvsignore>-files.
+
+ []
+
+ From now on you have different options to proceed. If you are working
+on all modules simultanously and you rather have eclipse project
+dependencies than binary dependencies, you should set up a new workspace
+and import all projects form <step-by-step/guide-ide-eclipse>. Note,
+you have to delete the <.project>-file of your parent project
+before. The result is equals to checking out the whole project from
+the command line, running <mvn eclipse:eclipse> and finally importing
+the projects into your eclipse workspace. In both cases you will be
+able to synchronize your changes using eclipse.
+
+ In case of large projects whith many people it can be quite tedious
+to check out all modules and keep them up to date. Especially if you
+are only interested in one or two modules. In this case using binary
+dependencies is much more comfortable. Just check out the modules you
+want to work on with eclipse and run <mvn eclipse:eclipse> for each
+module (see also {{{#Maven as an external tool}Maven as an external
+tool}}). Of course all referenced artifacts have to be available from
+your maven repository.
+
+ <<Issue:>> The maven-eclipse-plugin should optionally generate
+project dependencies for those modules which are available in the
+workspace.
+ 
+** {Flat Project Layout}
+
+ It is possible to move the parent POM in its own directory on the
+same level with the referenced modules.
+
+ [[1]] Create a new directory under <guide-ide-eclipse> called
+<guide-ide-eclipse-project> and move the parent POM to it.
+
+ [[1]] Change the module references in the parent POM to:
+
++----+
+  <modules>
+    <module>../guide-ide-eclipse-site</module>
+    <module>../guide-ide-eclipse-core</module>
+    <module>../guide-ide-eclipse-module1</module>
+  </modules>
++----+
+ []
+
+ <<Issue:>> The release plugin does not support the flat structure
+({{{http://jira.codehaus.org/browse/MNG-1263}MNG-1263}})



RE: svn commit: r329875 - /maven/components/trunk/maven-site/src/site/apt/guides/mini/guide-ide-eclipse.apt

Posted by Vincent Massol <vm...@pivolis.com>.
Some comments inside.

> -----Original Message-----
> From: jvanzyl@apache.org [mailto:jvanzyl@apache.org]
> Sent: lundi 31 octobre 2005 19:22
> To: commits@maven.apache.org
> Subject: svn commit: r329875 - /maven/components/trunk/maven-
> site/src/site/apt/guides/mini/guide-ide-eclipse.apt

[snip]

>  Guide to using Eclipse with Maven 2.x
> 
> - To generate the Eclipse project files from your POM you execute the
> following command:
> + This mini guide explains howto use Maven 2 in Eclipse IDE.
> 
> + * {{{#Maven 2 repository}Maven 2 repository}}
> +
> + * {{{#Maven as an external tool}Maven as an external tool}}
> +
> + * {{{#Simple Project}Simple Project}}
> +
> + * {{{#Multiple Module Project}Multiple Module Project}}
> +
> +* {Maven 2 repository}
> +
> + Eclipse needs to know the path to the local maven
> +repository. Therefore the classpath variable <M2_REPO> has to be
> +set. Execute the following command:
> +
> ++----+
> +
> +mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-
> repo

I think the eclipse.workspace parameter has to be explained. If you read it
you could be under the impression it specifies the location of the local
maven repository.

It should also be mentioned that this system property is optional and if not
specified the default eclipse workspace is going to be used.

> + You can also define a new classpath variable inside eclipse: From the
> +menu bar, select Window > Preferences.  Select the Java > Build Path >
> +Classpath Variables page.
> +
> + <<Issue:>> The command does not work. Aside from it should not require a
> POM.
> +
> +* {Maven as an external tool}
> +
> + You might want to execute some maven goals from inside eclipse. This
> +is possible by configuring an external launcher. It is best practice
> +to prepare eclipse by adding a variable, which points to your local
> +maven excutable (mvn.bat/mvn). From the menu bar, select Window >
> +Preferences.  Select the Run/Debug > String Substitution. Add a new
> +variable e.g.  <maven_exec>. When you set up a new external launcher
> +(from the menu bar, select Run > External Tools. Select Program) you
> +can refer to <maven_exec> in the location field. Furhtermore refer to
> +<project_loc> as the working directory and specify the maven goals of
> +your choice as arguments, e.g. <eclipse:eclipse>. For further
> +information please refer to the eclipse help.
> +
> + <<Issue:>> Would be nice, if the plugin generates the variable and a
> runner.

Never used that.

> +* {Simple Project}
> +
> + If you have a simple java project which is made up of only one
> +module, using eclipse is very simple. To generate the eclipse project
> +files from your POM you execute the following command:
> +
> ++----+
> +
> +mvn eclipse:eclipse

You should note that will not generate any eclipse project files for
projects with a pom packaging and that this is an issue. The eclipse plugin
should generate the eclipse project files for leaf projects independently of
their packaging.

> + If you have created or checked out the project with eclipse, you only
> +have to refresh the project in your workspace. Otherwise you have to
> +import the project into your eclipse workspace (From the menu bar,
> +select File >Import >Existing Projects into Workspace). In the
> +latter case the project (directory) should not be located in your
> +workspace, because eclipse might come into trouble, especially if you
> +want to use eclipse as the scm client.
> +
> +* {Multiple Module Project}

[snip]

I haven't checked what's below. I just wanted to point out that using
several eclipse projects to represent a full project is not working fine for
me and the only solution that works right now is having a single eclipse
project for all modules.

The problems I have with a multiple eclipse projects approach:

- you have *lot* tedious work to do. You must manually create parent project
and manually link each file, *one by one* to that project

- the files that you link are NOT version-controlled. If you make changes to
them you won't have annotations to tell you you've made changes. You also
won't be able to commit them, nor do any SCM operations on them

- you won't be able to select your whole project and select team>commit...
and have subclipse show the list of all your changes that you can then
select and commit. You'll need to hand pick changes for each module and
commit them separately... So long for atomic commits. Obviously you could
use the synchronization perspective but I've never liked it and it takes way
too long to be usable IMO. You'll need to cerate a working set. But even
that will not work because in the working set you'll have your parent
projects which will fail as they're not SCM-enabled...

Obviously I also understand that having a single big project does not scale
when the project becomes too big. That said this is what works the best for
me for now.... until Eclipse starts supporting overlapping projects as IDEA
does...

YMMV

-Vincent


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