184

I'm reading about Maven right now and everywhere in a text I see this word (mojo). I approximately understand what it means, but I would not refuse from a good explanation. I tried to google, but found only non-maven explanations.

POJO - ok, but MOJO? Maven Old Java Object?

gvlasov
  • 18,638
  • 21
  • 74
  • 110
dnim
  • 2,470
  • 4
  • 20
  • 19

4 Answers4

193

Yes, from http://maven.apache.org/plugin-developers/index.html:

What is a Mojo? A mojo is a Maven plain Old Java Object. Each mojo is an executable goal in Maven, and a plugin is a distribution of one or more related mojos.

In short, a mojo is a maven goal, to extend functionality not already found in maven.

Lynn Crumbling
  • 12,985
  • 8
  • 57
  • 95
  • So is "mojo" just a synonym for "goal" in Maven terminology? Or do they represent different entities that are closely related? – waldyrious Aug 18 '21 at 11:57
  • 1
    @waldyrious The "goal" of a "plugin" is a concept. It is implemented using a "mojo". The "mojo", in its compiled form, resides in the jar corresponding of the plugin. Same thing, different levels of abstraction. – David Tonhofer Sep 23 '22 at 12:48
72

As written here:

A Maven Plugin is a Maven artifact which contains a plugin descriptor and one or more Mojos. A Mojo can be thought of as a goal in Maven, and every goal corresponds to a Mojo. The compiler:compile goal corresponds to the CompilerMojo class in the Maven Compiler Plugin, and the jar:jar goal corresponds to the JarMojo class in the Maven Jar Plugin. When you write your own plugin, you are simply grouping together a set of related Mojos (or goals) in a single plugin artifact.

A Mojo simply associates with a Maven goal, so we can say a Mojo is much more than just a goal in Maven.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Venky Vungarala
  • 1,175
  • 10
  • 6
16

The Maven site says Mojo is the combination of "Maven" + "POJO (Plain Old Java Object)". So then, MOJO = Maven Old Java Object.

But another, different answer at Maven: The Complete Reference which I think is from the same group of people that are managing the Maven site suggest Mojo is meant to mean Magical POJO.

randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72
Javateer
  • 161
  • 1
  • 2
  • 1
    I don't see anywhere in the page that "Magical POJO" is suggested; if anything, the page defines what mojo means in classic context, so as to say "but that has nothing to do with this definition." – Lynn Crumbling Dec 23 '13 at 16:20
  • Magical POJO is suggested in the last paragraph of the linked document (Maven: The Complete Reference): `Mojo? What is a Mojo? The word mojo is defined as "a magic charm or spell", "an amulet, often in a small flannel bag containing one or more magic items", and "personal magnetism; charm". Maven uses the term Mojo because it is a play on the word Pojo (Plain-old Java Object).` – codefan-BK Oct 25 '14 at 13:44
  • @codefan-BK If the Maven site says that the M in Mojo stands for Maven, why would you make the leap to thinking that is suggesting that it is `Magical POGO` instead? It's already defined. – Lynn Crumbling Dec 11 '14 at 16:47
  • 2
    @Lynn Crumbling Taking the definition following the link you provided alone your short answer is exhaustive, indeed. But regarding the additional explanation in the second link given by Javateer reveals that the people deciding for the name Mojo thought to play with the word magical as well. So both of you are right, you and Javateer. Both explanations just shed light on two facets of the same subject. I feel no contradiction here, should I? – codefan-BK Dec 12 '14 at 19:20
  • @codefan-BK Replacing the word 'Maven' with "Magical' removes the underlying framework... so yes, I'd feel a contradiction :) – Lynn Crumbling Jan 07 '22 at 15:15
4
  • MOJO (Maven Old Java Object) is a goal in Maven.

  • In maven, everything is done by plugin, a plugin has one or more related mojos i.e. goals.

  • Mojo is single unit of task in maven.

for example : elicpse:eclipse the eclipse plugin with eclipse goal is a MOJO

Premraj
  • 72,055
  • 26
  • 237
  • 180