What is MOJO in Maven?
Asked Answered
H

4

185

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?

Hagiocracy answered 7/12, 2011 at 18:31 Comment(1)
:) As I understood - in some sense - it's just wordplay...Hagiocracy
T
196

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.

Turf answered 7/12, 2011 at 18:34 Comment(2)
So is "mojo" just a synonym for "goal" in Maven terminology? Or do they represent different entities that are closely related?Expatriate
@Expatriate 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.Biblicist
H
74

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.

Hame answered 15/9, 2014 at 10:1 Comment(3)
This is by far the best answer, I feel sorry you don't have more upvotes! The other answers don't give any more information than what is in the documentation already.Cinch
@Cinch Unfortunately, it's also unoriginal; copy and pasted directly from another source without any attribution.Turf
Shame. Still useful though.Cinch
L
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.

Lalita answered 28/3, 2013 at 23:15 Comment(5)
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."Turf
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).Ashien
@Ashien 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.Turf
@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?Ashien
@Ashien Replacing the word 'Maven' with "Magical' removes the underlying framework... so yes, I'd feel a contradiction :)Turf
I
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

Imperfective answered 19/1, 2018 at 0:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.