Skip to content

[API] Add noun-style accessors to remaining @Immutable API types (deprecate old getXxx() getters)Β #13830

Open

Description

@gnodet

Add noun-style accessors to remaining @Immutable API types (deprecating old-style getXxx())

Background

Maven 4.1.0 started the migration of @Immutable API types to noun-style accessors (e.g. id(), type() instead of getId(), getType()), consistent with the immutable value-object pattern and established in JDK types like Record. The reference implementation is org.apache.maven.api.Repository, which now exposes id() and type() as the canonical accessors while getId() / getType() are deprecated (@Deprecated(since = "4.1.0", forRemoval = true)) with default implementations delegating to the new names.

This issue covers the remaining interfaces and targets 4.2.0.

This issue tracks the remaining @Immutable interfaces that still only expose the old getXxx() / isXxx() style and need the same treatment.

Scope

The following interfaces need new noun-style accessors added, with the old getters kept as @Deprecated(since = "4.2.0", forRemoval = true) default methods delegating to the new ones. Each new accessor should carry a @since 4.2.0 javadoc tag.

maven-api-core β€” org.apache.maven.api

Artifact

  • isSnapshot() β†’ add boolean snapshot()

Dependency

  • isOptional() β†’ add boolean optional()

Type

  • getLanguage() β†’ add Language language()
  • getExtension() β†’ add String extension()
  • getClassifier() β†’ add String classifier()
  • isIncludesDependencies() β†’ add boolean includesDependencies()
  • getPathTypes() β†’ add Set<PathType> pathTypes()

Note: Packaging.language() already exists as a noun-style default method but it internally calls type().getLanguage() β€” once Type.language() is added, its body must be updated to call type().language().

maven-api-core β€” org.apache.maven.api.services

Request

  • getSession() β†’ add S session()
  • getTrace() β†’ add RequestTrace trace()

Result

  • getRequest() β†’ add REQ request()

BuilderProblem

  • getSource() β†’ add String source()
  • getLineNumber() β†’ add int lineNumber()
  • getColumnNumber() β†’ add int columnNumber()
  • getLocation() β†’ add String location()
  • getException() β†’ add Exception exception()
  • getMessage() β†’ add String message()
  • getSeverity() β†’ add Severity severity()

RepositoryAwareRequest (extends Request)

  • getRepositories() β†’ add List<RemoteRepository> repositories()

ArtifactCoordinatesFactoryRequest

  • getGroupId() β†’ add String groupId()
  • getArtifactId() β†’ add String artifactId()
  • getVersion() β†’ add String version()
  • getClassifier() β†’ add String classifier()
  • getExtension() β†’ add String extension()
  • getType() β†’ add String type()
  • getCoordinatesString() β†’ add String coordinatesString()

ArtifactDeployerRequest

  • getRepository() β†’ add RemoteRepository repository()
  • getArtifacts() β†’ add Collection<ProducedArtifact> artifacts()
  • getRetryFailedDeploymentCount() β†’ add int retryFailedDeploymentCount()

ArtifactFactoryRequest

  • getGroupId() β†’ add String groupId()
  • getArtifactId() β†’ add String artifactId()
  • getVersion() β†’ add String version()
  • getClassifier() β†’ add String classifier()
  • getExtension() β†’ add String extension()
  • getType() β†’ add String type()

ArtifactInstallerRequest

  • getArtifacts() β†’ add Collection<ProducedArtifact> artifacts()

ArtifactResolverRequest

  • getCoordinates() β†’ add Collection<ArtifactCoordinates> coordinates()

DependencyCoordinatesFactoryRequest

  • getScope() β†’ add DependencyScope scope()
  • isOptional() β†’ add boolean optional()
  • getExclusions() β†’ add Collection<Exclusion> exclusions()

DependencyResolverRequest

  • getRequestType() β†’ add RequestType requestType()
  • getProject() β†’ add Optional<Project> project()
  • getRootArtifact() β†’ add Optional<Artifact> rootArtifact()
  • getRoot() β†’ add Optional<DependencyCoordinates> root()
  • getDependencies() β†’ add Collection<DependencyCoordinates> dependencies()
  • getManagedDependencies() β†’ add Collection<DependencyCoordinates> managedDependencies()
  • getVerbose() β†’ add boolean verbose()
  • getPathScope() β†’ add PathScope pathScope()
  • getPathTypeFilter() β†’ add Predicate<PathType> pathTypeFilter()
  • getTargetVersion() β†’ add Version targetVersion()

ModelBuilderRequest

  • getSource() β†’ add Source source()
  • getRequestType() β†’ add RequestType requestType()
  • isLocationTracking() β†’ add boolean locationTracking()
  • isRecursive() β†’ add boolean recursive()
  • getProfiles() β†’ add List<Profile> profiles()
  • getActiveProfileIds() β†’ add List<String> activeProfileIds()
  • getInactiveProfileIds() β†’ add List<String> inactiveProfileIds()
  • getSystemProperties() β†’ add Map<String, String> systemProperties()
  • getUserProperties() β†’ add Map<String, String> userProperties()
  • getRepositoryMerging() β†’ add RepositoryMerging repositoryMerging()
  • getLifecycleBindingsInjector() β†’ add LifecycleBindingsInjector lifecycleBindingsInjector()

ProjectBuilderRequest

  • getPath() β†’ add Optional<Path> path()
  • getSource() β†’ add Optional<Source> source()
  • isAllowStubModel() β†’ add boolean allowStubModel()
  • isRecursive() β†’ add boolean recursive()
  • isProcessPlugins() β†’ add boolean processPlugins()
  • getRepositories() β†’ add List<RemoteRepository> repositories()

SettingsBuilderRequest

  • getInstallationSettingsSource() β†’ add Optional<Source> installationSettingsSource()
  • getProjectSettingsSource() β†’ add Optional<Source> projectSettingsSource()
  • getUserSettingsSource() β†’ add Optional<Source> userSettingsSource()
  • getInterpolationSource() β†’ add Optional<UnaryOperator<String>> interpolationSource()

maven-api-core β€” org.apache.maven.api.services.xml

XmlReaderRequest

  • getPath() β†’ add Path path()
  • getRootDirectory() β†’ add Path rootDirectory()
  • getURL() β†’ add URL url() (note: acronym, keep lowercase url() per Java convention, matching RemoteRepository.url())
  • getInputStream() β†’ add InputStream inputStream()
  • getReader() β†’ add Reader reader()
  • getTransformer() β†’ add Transformer transformer()
  • isStrict() β†’ add boolean strict()
  • getModelId() β†’ add String modelId()
  • getLocation() β†’ add String location()
  • isAddDefaultEntities() β†’ add boolean addDefaultEntities()

Implementation Pattern

Exact pattern from Repository.java:

// New noun-style accessor (canonical, abstract)
/**
 * Gets the identifier of this repository.
 *
 * @return the (case-sensitive) identifier, never {@code null}
 * @since 4.2.0
 */
@Nonnull
String id();

// Old getter kept as deprecated default delegating to the new accessor
@Nonnull
@Deprecated(since = "4.2.0", forRemoval = true)
default String getId() {
    return id();
}

For boolean properties using isXxx():

// New noun-style accessor
/**
 * Returns whether this artifact is a snapshot.
 *
 * @since 4.2.0
 */
boolean snapshot();

// Old getter deprecated
@Deprecated(since = "4.2.0", forRemoval = true)
default boolean isSnapshot() {
    return snapshot();
}

For the builder inner classes and their concrete implementations (e.g. ArtifactDeployerRequest has a static inner ArtifactDeployerRequestBuilder), the builder class's concrete implementations of the getters should be updated to also implement the new noun-style methods, or the deprecated defaults on the interface will suffice.

Acceptance Criteria

  • All listed @Immutable interfaces have noun-style accessor methods added.
  • All old getXxx() / isXxx() methods on those interfaces are retained as @Deprecated(since = "4.2.0", forRemoval = true) default methods delegating to the new accessor.
  • Existing callers of old getters continue to compile (binary + source compat preserved).
  • Packaging.language() body updated from type().getLanguage() to type().language().
  • Any internal Maven code that calls the old getters on these interfaces should be updated to use the new noun-style accessors (the deprecated wrappers exist for external consumers, not for in-tree code).

Activity

  1. codewithsinchana commented on Nov 5, 2026

    @codewithsinchana
    Contributor

    I'd like to contribute a small, focused part of this issue by adding the noun-style snapshot() accessor to Artifact, while retaining isSnapshot() as a deprecated compatibility method. I'll also update the relevant implementation and internal callers. Would this scope be suitable for a separate PR?

  2. codewithsinchana commented on Nov 12, 2026

    @codewithsinchana
    Contributor

    I've submitted a focused contribution for the Artifact.snapshot() accessor as part of this issue. The change retains isSnapshot() as a deprecated compatibility method. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions