Annotation Type InjectMojo


  • @Retention(RUNTIME)
    @Inherited
    @Target({METHOD,PARAMETER})
    public @interface InjectMojo
    Annotation used in Maven plugin tests to inject and configure a Mojo instance. This annotation can be applied to either test methods or parameters to specify which Mojo should be instantiated and how it should be configured.

    The annotation requires a goal attribute to specify which Mojo goal should be instantiated. Optionally, a custom POM file can be specified to provide specific configuration for the test.

    Example usage on a test method:

     {@code
    Since:
    3.4.0
    See Also:
    MojoTest, MojoParameter, MojoExtension
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String goal
      Specifies the goal of the Mojo to instantiate.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String pom
      Specifies an optional POM file to use for Mojo configuration.
    • Element Detail

      • goal

        java.lang.String goal
        Specifies the goal of the Mojo to instantiate. This is a required attribute that maps to the Mojo's @Mojo(name = "...") annotation value.
        Returns:
        the goal name of the Mojo to test
      • pom

        java.lang.String pom
        Specifies an optional POM file to use for Mojo configuration. The path is relative to the test class location.

        NOTE: only plugin configuration is taken from provided POM, all other tags are ignored.

        If not specified, the default project configuration will be used.

        Returns:
        the path to a custom POM file, or an empty string to use defaults
        Default:
        ""