• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cheating with Maven?

 
Ranch Hand
Posts: 80
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I have a problem with dependencies for Spring 3.1. I know that if I "just used Maven" it would all be easy. But that leaves two problems for me, first, I want to know what is happening, second, I don't know how to use Maven anyway, and don't really want to (can't really afford to) invest the time to learn right now (though, yes, it's on my list).

So, here's what I'm wondering. Is there a simple "recipe" that would allow me to kick off Maven (I'd have to download it first) and give it the pom elements that Spring provide for their stuff, and let Maven do the necessary downloads. Then, after it's done the downloads, I'd want to extract the stuff it had fetched, and stick the jars on my classpath in the usual (i.e. manual) way.

Is that possible? How would I do it?

Thanks,
Toby.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It took me a while to warm up to Maven as well, but it was worth the effort. You really should move Maven to the top of your "must-learn" list, since it makes it a lot easier to work with other things.

The hard part is creating the POM. Here's some stuff for Spring that includes Spring components for use with JPA and the web framework. Remove any items that don't amuse you.


Also, of course, you need to define the spring version. Like so:



This properties element is at the bottom of my POM.

Yes, Maven is "magic", and I never liked that, but it's in large part because Maven is designed to be able to do lots of things while requiring minimal configuration. Installing Maven is simple. Just download the zipfile, explode it, set MAVEN_HOME to point to the root of the exploded ZIP, and add $MAVEN_HOME/bin (or %MAVEN_HOME%\bin) to your PATH.

Some useful Maven goals that a minimal POM can invoke:

mvn clean - Remove all constructed objects
mvn compile - compile only
mvn clean compile war - clean, then compile and build a WAR from the results (web project). The "war" goal doesn't compile, only archive, so we must explicitly compile.
mvn test - does a compile, runs unit tests, and builds test reports
mvn package - construct a target artefact. Implies compile and test
mvn install - does a "mvn package, then installs the artefact in your Maven archive, where it can be used as a dependency by other POMs

There are many other goals, including some specialized ones that invoke dependencies on Maven plugins and massive functions like "mvn site", which not only does a "mvn package", it uploads the package to a central Maven repository, builds constructs an entire website including javadocs and test reports and uploads it, and so forth. You can also limit what tests (if any) are run for goals that request testing.
 
Toby Eggitt
Ranch Hand
Posts: 80
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim, I'm not totally clear how to proceed with this, but I figure I'll stick with 2.5.5, which is behaving for me, and wait till I have a chance to get to grips with Maven before I bother to upgrade.

Really appreciate your effort, thanks!

Toby
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic