Interface Packaging

All Superinterfaces:
ExtensibleEnum

@Experimental @Immutable public interface Packaging extends ExtensibleEnum
Represents the packaging of a Maven project.

The Packaging class defines the type of artifact that a Maven project produces during the build process. The packaging type determines the structure of the project's output and how Maven will treat the resulting artifact.

Common packaging types include jar, war, pom, maven-plugin, ear, and others. These types influence various aspects of the build lifecycle, such as which plugins are executed and how dependencies are managed.

The Packaging class is an immutable value object, ensuring that once a packaging type is defined, it cannot be changed.

Standard Packaging Types

  • jar: Packages the project as a Java Archive (JAR) file.
  • war: Packages the project as a Web Application Archive (WAR) file.
  • pom: Indicates that the project does not produce a deployable artifact but is used for dependency management or as an aggregator.
  • maven-plugin: Packages the project as a Maven plugin.

Usage Example

 
 Session session = ... // Obtain a Maven session
 Packaging packaging = session.requirePackaging("jar");
 System.out.println(packaging.getId()); // Outputs "jar"
 
 
Since:
4.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    id()
    The packaging id.
    default Language
    The language of this packaging.
    Returns the binding to use specifically for this packaging keyed by lifecycle id.
    The type of main artifact produced by this packaging.
  • Method Details

    • id

      The packaging id.
      Specified by:
      id in interface ExtensibleEnum
      Returns:
      the id
    • language

      @Nonnull default Language language()
      The language of this packaging.
    • type

      @Nonnull Type type()
      The type of main artifact produced by this packaging.
    • plugins

      Returns the binding to use specifically for this packaging keyed by lifecycle id. This will be used instead of the default packaging definition.