public@interface Mojo { /** * goal name (required). * @return the goal name */ // 目标名称,这个在pom.xml中使用插件时配置goal需要用到 String name();
/** * default phase to bind your mojo. * @return the default phase */ // 配置默认绑定的阶段,这样就不需要在pom.xml中使用该插件的时候进行配置<phase>了 LifecyclePhase defaultPhase()default LifecyclePhase.NONE;
/** * the required dependency resolution scope. * @return the required dependency resolution scope */ // 表示在运行该Mojo之前必须解析所有指定范围的依赖 ResolutionScope requiresDependencyResolution()default ResolutionScope.NONE;
/** * the required dependency collection scope. * @return the required dependency collection scope */ ResolutionScope requiresDependencyCollection()default ResolutionScope.NONE;
/** * your Mojo instantiation strategy. (Only <code>per-lookup</code> and <code>singleton</code> are supported) * @return the instantiation strategy */ InstantiationStrategy instantiationStrategy()default InstantiationStrategy.PER_LOOKUP;
/** * execution strategy: <code>once-per-session</code> or <code>always</code>. * @return <code>once-per-session</code> or <code>always</code> */ String executionStrategy()default "once-per-session";
/** * does your mojo requires a project to be executed? * @return requires a project */ // 表示该项目是否必须在一个maven项目中运行 booleanrequiresProject()defaulttrue;
/** * does your mojo requires a reporting context to be executed? * @return requires a reporting context */ // 表示是否要求项目报告生成 booleanrequiresReports()defaultfalse;
/** * if the Mojo uses the Maven project and its child modules. * @return uses the Maven project and its child modules */ // 当Mojo在多模块项目上运行时,配置了该目标只会在顶层模块运行 booleanaggregator()defaultfalse;
/** * can this Mojo be invoked directly only? * @return invoked directly only */ // 如果为true,表示只能通过命令行来进行调用,不能在pom中将其绑定到生命周期阶段 booleanrequiresDirectInvocation()defaultfalse;
/** * does this Mojo need to be online to be executed? * @return need to be online */ // 是否要求maven必须是online状态 booleanrequiresOnline()defaultfalse;
booleaninheritByDefault()defaulttrue;
/** * own configurator class. * @return own configurator class */ String configurator()default "";
/** * is your mojo thread safe (since Maven 3.x)? * @return is thread safe */ booleanthreadSafe()defaultfalse; }
public@interface Parameter { /** * name of the bean property used to get/set the field: by default, field name is used. * @return the name of the bean property */ // 参数名 String name()default "";
/** * alias supported to get parameter value. * @return the alias */ // 参数别名 String alias()default "";
/** * Property to use to retrieve a value. Can come from <code>-D</code> execution, setting properties or pom * properties. * @return property name */ // 表达式,可以在命令行使用-D进行配置,也可以在settings.xml中配置或者在pom.xml中配置 // 如使用 ${maven.test.skip} String property()default "";
/** * parameter default value, eventually containing <code>${...}</code> expressions which will be interpreted at * inject time: see * <a href="/ref/current/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html"> * PluginParameterExpressionEvaluator</a>. * @return the default value */ // 默认值,没有配置时使用的默认值 String defaultValue()default "";
/** * is the parameter required? * @return <code>true</code> if the Mojo should fail when the parameter cannot be injected */ // 是否必须设置 booleanrequired()defaultfalse;
/** * Specifies that this parameter cannot be configured directly by the user (as in the case of POM-specified * configuration). This is useful when you want to force the user to use common POM elements rather than plugin * configurations, as in the case where you want to use the artifact's final name as a parameter. In this case, you * want the user to modify <code><build><finalName/></build></code> rather than specifying a value * for finalName directly in the plugin configuration section. It is also useful to ensure that - for example - a * List-typed parameter which expects items of type Artifact doesn't get a List full of Strings. * * @return <code>true</code> if the user should not be allowed to configure the parameter directly */ // 只读的表示用户无法对该参数进行配置 booleanreadonly()defaultfalse; }