On Wed, Dec 26, 2012 at 10:54 AM, Niranjan Rao <[email protected]> wrote:

> I read the blog entry and still confused about why we should not be using
> profiles. Perhaps I am just being dumb.
>

No, it's just not explained very well.

Maven wants your build to be repeatable.  That means when you build version
21, and I build version 21, we get exactly the same version 21.  There
shouldn't even BE a discussion about "which" version 21 we're talking
about.  There should be only one version 21, period, end of story, amen.

There are a few facilities within Maven that make it possible to alter the
output of a build.  Profiles are one of those facilities.  Profiles let you
alter things about the way that Maven goes about its business producing
artifacts, and so it is possible that if I build version 21 with a profile,
and you build version 21 without one (or with a default one), then we end
up with different version 21s.  Oops.

Now, if you use profiles properly, they can be powerful, and the things
that they change may not--in your world, in your company, according to the
rules by which you are forced to "live" professionally--contribute to
variances in "your" version 21 and "my" version 21.  For example, "your"
version 21 may--by use of an activated profile--include an extra header in
a MANIFEST.MF file somewhere that may make "your" version 21 different from
"my" version 21 (if we ran your version 21 through a hash function and mine
through the same hash function the outputs would be different).  This is
technically, ruthlessly speaking a bad thing, since "version 21" now does
not denote anything (you have to add "with the special MANIFEST.MF header"
or "without the special MANIFEST.MF header" to further indicate what you're
talking about).  But maybe no one cares in your world/company.  That's fine.

When you start doing resource filtering using profiles, you're
probably--but not necessarily--heading into murky waters.  Maybe those
resources are important and semantically significant to your artifacts.  In
that case, you probably don't want to do it (so you don't have to have
discussions about which version 21 you and your coworkers are talking
about).  On the other hand, maybe resource filtering via a profile in your
world is simply adding a property somewhere that has no real value except
to, say, identify the build machine--yeah, the two version 21s are
different, but not in any meaningful way, and it doesn't really matter in
some fashion which one of them you get).  Repeatable?  No, not
intrinsically.  Bad?  Not necessarily.

Profiles can also alter dependencies, which is almost--almost--always a
disaster unless you have the means to control when such builds are produced
and released into the world.

In your case, the real Maven people will bark and howl--justifiably, as
they have--because if you build your version 21 and I build your version
21, our version 21s are going to have different requirements and
configurations.  We now have to specify to each other which version 21
we're talking about--the one with the message queue hosted on machine A or
the one referencing a message queue on machine B (the presence of machine A
or B is now an effective prerequisite of the build, but not reflected in
the version number).

My view is that if you have control of your ecosystem and consumers (i.e.
you can say with certainty who all will be producing artifacts and builds,
and who all will be consuming them, and you can further control how they do
those builds), then you are pretty much OK within that ecosystem using
profiles of almost any kind.  Leak anything outside of that ecosystem and
things will go bad in a hurry.

Hope that helps.

Best,
Laird

-- 
http://about.me/lairdnelson

Reply via email to