On 07/08/2014 11:20 PM, Les Gasser wrote:
I'm a new Maven user, using it almost completely through Eclipse.
I've installed Nexus as a repository manager. It all works.
1. Suppose I set up a dependency today, say on "needed-component". I
have to explicitly reference the specific version I want, say
"needed-component-2.3.4". I had hoped there would be a way to just
make a dependency to "needed-component" and have Maven keep me up to
date with the latest version, but I gather that's not the Maven
concept. Am I overlooking something?
This gives you repeatable builds. If someone picks up your project and
builds it, they will get a resulting artifact that is exactly the same
one that you made.
This is a good thing.
2. OK so I have the explicit dependency to "needed-component-2.3.4",
set up using Properties->Maven->Add Dependency, finding the most
recent version in central, etc. Now is there any way to be notified
via Nexus/Maven/Eclipse when a newer version of needed-component
becomes available? Kind of a "check for component updates"?
Usually you can subscribe to the forum or user group that is associated
with that artifact.
That way, you usually get a note about what new features are included
and what old features have been changed or eliminated.
Having new versions automatically adopted sounds pretty good until a new
version breaks your build without you being aware that it was changed.
You will tear your hair out trying to figure why your latest code change
caused such a strange error in your application.
It is a lot saner to try to have a stable set of dependencies from the
start of a release cycle until the end.
If you really need to upgrade a dependency in the midst of a development
cycle, you want to do that as a separate task so that you can test the
new version of the library with a stable version of your code.
3. Failing that, I suppose I have to survey repositories like central
myself and notice when new versions appear. OK so a year from now I
see "needed-component-3.0.3" is in central. Is there any way via maven
or maven/eclipse to update the original dependency, changing it from
"needed-component-2.3.4" to "needed-component-2.3.4"? Or do I have to
go in and edit the dependency spec in the project's pom.xml file
myself?
You should have a parent pom for your project and in that pom, you
maintain the versions as variables. It has no code but you "install" it
with Maven as a module.
In your code modules, you specify the parent project by its GAV and you
use the variables names for the versions in the GAV spec for a
dependency org.apache.jackrabbit:jackrabbit-core:${jackrabbit.version}
That way you only have to change one thing when you decide to adopt a
new version of a dependency.
Changing the variable jackrabbit.version in the parent will make sure
that every module will be built with the same version of jackrabbit.
You still need to rebuild each module but it will not require any
editing of the module's pom.xml file.
4. Eclipse/Maven has an Add Dependency capability. Suppose you make a
conceptual or typing mistake when adding a dependency and want to
revert. Why no symmetric Delete Dependency? Again, is pom.xml editing
the only recourse?
Make sure that you are using Eclipse/STS or have plain eclipse with all
of the m2e plugins that support Maven.
If you do this, you have a very nice graphical editor for pom files and
adding or deleting a dependency is just pointing and clicking and you
will probably never use the "Add Dependency"
It has a dependency navigation that makes it easy to see all of the
transitive dependencies and you can also easily find all of the modules
that require a version of one of the low level dependencies.
(One click answers the question : "Who is dragging in version 1.0 of
log4j?")
STS from the Spring guys is a very good way to get Eclipse. It comes out
of the box with all of the plug-ins required to use Maven.
We started with plain Eclipse but every update was a really long process
to find and load all of the plug-ins and it was hard to be sure that
every team member had the same configuration of plug-ins.
Once we found STS, Eclipse got a lot easier. One download and a single
configuration to set up out SVN connection and the new version is ready
to run. Takes 15-20 minutes to upgrade Eclipse now.
Once you get your parent pom set up life gets pretty easy. Also look at
dependency management.
Thanks for any help.
- Les
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--
Ron Wheeler
President
Artifact Software Inc
email: [email protected]
skype: ronaldmwheeler
phone: 866-970-2435, ext 102
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]