Zero configuration?  Really?

  mwood@mhw ~ $ mkdir testmvn
  mwood@mhw ~ $ cd testmvn
  mwood@mhw ~/testmvn $ mvn install
  [INFO] Scanning for projects...
  [INFO]
  ------------------------------------------------------------------------
  [INFO] Building Maven Default Project
  [INFO]    task-segment: [install]
  [INFO]
  ------------------------------------------------------------------------
  [INFO]
  ------------------------------------------------------------------------
  [ERROR] BUILD ERROR
  [INFO]
  ------------------------------------------------------------------------
  [INFO] Cannot execute mojo: resources. It requires a project with an
  existing pom.xml, but the build is not using one.
  [INFO]
  ------------------------------------------------------------------------
  [INFO] For more information, run Maven with the -e switch
  [INFO]
  ------------------------------------------------------------------------
  [INFO] Total time: < 1 second
  [INFO] Finished at: Thu Apr 19 08:48:32 EDT 2012
  [INFO] Final Memory: 5M/75M
  [INFO]
  ------------------------------------------------------------------------

So I need to write a POM.  I hear that Maven can do that for me:

  mwood@mhw ~/testmvn $ mvn archetype:generate
  [INFO] Scanning for projects...
  [INFO] Searching repository for plugin with prefix: 'archetype'.
  [INFO]
  ------------------------------------------------------------------------
  [INFO] Building Maven Default Project
  [INFO]    task-segment: [archetype:generate] (aggregator-style)
  [INFO]
  ------------------------------------------------------------------------
  [INFO] Preparing archetype:generate
  [INFO] No goals needed for project - skipping
  [INFO] Setting property: classpath.resource.loader.class =>
  'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
  [INFO] Setting property: velocimacro.messages.on => 'false'.
  [INFO] Setting property: resource.loader => 'classpath'.
  [INFO] Setting property: resource.manager.logwhenfound => 'false'.
  [INFO] [archetype:generate {execution: default-cli}]
  [INFO] Generating project in Interactive mode
  [INFO] No archetype defined. Using maven-archetype-quickstart
  (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
  Choose archetype:
  [long list]
  Choose a number:
  
(1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41)
  15: : 

[It doesn't know which archetype I want.  Fair enough.]

  [INFO] artifact
  org.apache.maven.archetypes:maven-archetype-quickstart: checking for
  updates from central
  Define value for groupId: : edu.iupui.ulib
  Define value for artifactId: : testmvn
  Define value for version:  1.0-SNAPSHOT: : 

[Maven does not supply GAV coordinates.  I have to configure them.  Of
course I do -- how could it possibly know them until I tell it?]

  Define value for package:  edu.iupui.ulib: : 

[A reasonable guess.]

  Confirm properties configuration:
  groupId: edu.iupui.ulib
  artifactId: testmvn
  version: 1.0-SNAPSHOT
  package: edu.iupui.ulib
   Y: : y
  [INFO]
  ----------------------------------------------------------------------------
  [INFO] Using following parameters for creating OldArchetype:
  maven-archetype-quickstart:RELEASE
  [INFO]
  ----------------------------------------------------------------------------
  [INFO] Parameter: groupId, Value: edu.iupui.ulib
  [INFO] Parameter: packageName, Value: edu.iupui.ulib
  [INFO] Parameter: package, Value: edu.iupui.ulib
  [INFO] Parameter: artifactId, Value: testmvn
  [INFO] Parameter: basedir, Value: /home/mwood/testmvn
  [INFO] Parameter: version, Value: 1.0-SNAPSHOT
  [INFO] ********************* End of debug info from resources from
  generated POM ***********************
  [INFO] OldArchetype created in dir: /home/mwood/testmvn/testmvn
  [INFO]
  ------------------------------------------------------------------------
  [INFO] BUILD SUCCESSFUL
  [INFO]
  ------------------------------------------------------------------------
  [INFO] Total time: 1 minute 48 seconds
  [INFO] Finished at: Thu Apr 19 08:51:33 EDT 2012
  [INFO] Final Memory: 14M/173M
  [INFO]
  ------------------------------------------------------------------------

That's quite a bit more than zero:

  mwood@mhw ~/testmvn/testmvn $ ls -l pom.xml 
  -rw-r--r-- 1 mwood mwood 750 Apr 19 08:51 pom.xml

You could try doing it yourself:

  mwood@mhw ~/testmvn/testmvn $ echo "<project/>" > pom.xml

but you'll generate a FATAL ERROR.  "Not a v4.0.0 POM."  It must be
configured.

Returning to the generated configured POM, 'mvn deploy' chugs along
quite well for a bit and then dies because it doesn't know where the
repository is.  Of course it doesn't.  You have to configure it.  It's
nice enough to give you ten lines of POM template XML, but it can't
know what goes between the tags.

'mvn site:deploy' also doesn't know how to distribute the site.  You
have to configure it.  In two different files.  In two different
directories.  (There are good reasons for that.)

I'm being silly to make a point: 'zero configuration' isn't possible.
You need to configure your project even to start, and you need to know
some rather nontrivial and non-obvious stuff about Maven to do that
properly.  A complete deployable can't be done without more
configuration, some of it a bit abstruse.  This is not something
lacking in Maven; it must be that way to do its job: modelling and
orchestrating complex processes with many necessary parameters whose
values vary unpredictably with each application.

Some of this configuration can't be done until you know your local
policies, which means someone has to *create* local policies.

Maven strives heroically to simplify all this for us but, as Einstein
observed, there are limits to how much you can usefully simplify a
model.  Maven does very well, but it can't do everything for us.  It's
not possible to have concrete conventions for some aspects of a
project, since there is more than one possible project.

As long as I'm ranting: the Project Object Model is quite complex, of
necessity.  The Conventions represent a view over that model which
obscures many aspects of its complexity.  You often don't have to
write anything to control those aspects, but you do always have to
think about them.

Convention is simply built-in configuration which was agreed on by
some people who (we hope and believe) knew what they were doing and
which is generally accepted in the community.  Choosing not to
configure something is choosing to configure it the way Maven comes
out of the box.  Which means one needs to understand how Maven is
configured out of the box in order to make good choices.  Maven's
conventional configuration is pretty good and fairly general, but
discovering all of the bits you have to know can be challenging and,
until you know what bits to look for, Maven's behavior can be
puzzling.

-- 
Mark H. Wood, Lead System Programmer   mw...@iupui.edu
Asking whether markets are efficient is like asking whether people are smart.

Attachment: pgprH73SeCX1a.pgp
Description: PGP signature

Reply via email to