maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curtis Rueden <ctrue...@wisc.edu>
Subject Re: migrating from Eclipse to a Maven build
Date Thu, 07 Jun 2012 15:43:17 GMT
Hi RonA, Antonio & everyone,

On Thu, Jun 7, 2012 at 9:15 AM, Antonio Petrelli wrote:

> However I disagree with Ron, once you move to Maven, you'd better move
> in a clean way, so it's better to move directory as the Maven standard
> layout suggests.


Why? Maven does not require it. You can keep your existing source folder
(say, "src") using a single line of XML in the <build> section:

    <sourceDirectory>${project.basedir}/src</sourceDirectory>

If you have unit tests in a "test" folder you can do that too:

    <testSourceDirectory>${project.basedir}/test</testSourceDirectory>

Even if you want to keep your resources mixed in with your source (which a
lot of people do, even though IMO it is less clean), you can do that as
well; e.g.:

    <resources>
      <resource>
        <directory>${project.basedir}/src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>${project.basedir}/test</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </testResource>
    </testResources>

>From my perspective, one of the most common excuses for disliking Maven is
the "overly nested src/main/java" directory structure, but people often do
not realize that it is merely a convention, not a requirement. There are
many other Maven conventions that IMO have much more serious consequences
if not followed. Violating the standard directory structure is really not a
serious offender in comparison, and it can greatly aid in migrating a
project to Maven in a less disruptive way.

Regards,
Curtis

P.S. The Eclipse plugin you need is called M2E, and it comes with the
Eclipse 3.7 for Java Developers distribution (not just with Eclipse STS).
However, if you must use a specific other flavor of Eclipse, it can likely
still be installed just fine using the M2E update site (linked from
http://www.eclipse.org/m2e/download/).

Another alternative is the maven-eclipse-plugin (i.e., "mvn
eclipse:eclipse" to manually generate Eclipse metadata files), but IMO it
is less convenient. With M2E, your dependencies will automagically switch
between JAR dependencies (out of ~/.m2/repository) and Eclipse project
dependencies as you open and close upstream projects within Eclipse.


On Thu, Jun 7, 2012 at 9:15 AM, Antonio Petrelli <antonio.petrelli@gmail.com
> wrote:

> 2012/6/7 Ronald Albury <ronalbury@gmail.com>:
> > I have the project layout pretty clean - with one artifact per project
> (jar
> > library, executable jar, war/ear).  There are three top level
> applications
> > that come out of the workspace - an ear and two runnable jar files.  The
> > jar libraries are shared across the three applications.  I have heard
> > rumors that Maven will object to this sort of layout ... I'd be
> interested
> > in your opinion on that subject.
>
> Don't care about those rumours, they must be Ant users :-D
> Seriously, the fact that you have alread one artifact per project it's
> a nice start. All you have to do is create a project of time "pom" to
> rule them all, and then a module for each artifact. The type of the
> modules must match the type of your project (jar, ear, war).
> Dependencies between modules are just like the other dependencies.
> However I disagree with Ron, once you move to Maven, you'd better move
> in a clean way, so it's better to move directory as the Maven standard
> layout suggests.
>
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message