Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 325381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:12:42+00:00 2026-05-12T09:12:42+00:00

I’m writing a maven plugin with a number of configurable parameters. There are a

  • 0

I’m writing a maven plugin with a number of configurable parameters. There are a number of parameters specified in the Mojo class. One of these parameters is required and must contain certain values (let’s say, either ‘Atwood’ or ‘Spolsky’). At the moment it is annotated with a. @required field as shows here:

public class GenerateMojo extends AbstractMojo{
   ...
   ...

   /**
   *@parameter
   *@required
   */
   private String someParameter;
   ...
   ...
}

Which is all well and good, but if someone forgets to include the parameter they get a generic error message like so:

Inside the definition for plugin 'xyz' specify the following:
<configuration>    
    ...   
    <someParameter>VALUE</someParameter>
</configuration>

If is possible to either (1) restrict the values that can be inputted to the someParmeter field to give a better error message, or (2) specify the error message myself so that I can write something like “The value for ‘someParameter’ needs to be either ‘Atwood’ or ‘Spolsky’ ??

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:12:42+00:00Added an answer on May 12, 2026 at 9:12 am

    There is an open Jira to add support for enumerations to parameter values in Maven 2.2 (it is already supported in Plexus on Java 5).

    You can specify a default value so at least the Mojo won’t fail in initialisation. You can then validate the value of the parameter in the execute() method and output a more helpful message.

    If there is no sensible default, you can set the default to a value that will be invalidated in the execute() method, this effectively means the user will have to define it, and they get a meaningful error message. For example:

    /**
     * @parameter expression="${someParameter}" default-value="_"
     */
    private String someParameter;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing a Maven plugin, you can configure various parameters within the mojo class,
I'm writing a Maven plugin (Mojo) that needs to execute a standard set of
I'm writing a Maven plugin and I am using default values for all parameters
I am writing a Maven plugin (Mojo) that imports a Jar library used by
I'm writing a Maven 2 plugin which must iterate over all project dependencies and
I'm writing a very simple Maven plugin, and I am kind of lost with
I'm writing a Maven plugin that takes as a parameter the path to the
I am writing a plugin to Maven. I want to customize action depend on
I'm writing my first Maven Mojo, in it I'm wanting to take a file
I am interested in writing an annotation processor for the maven-processor-plugin. I am relatively

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.