Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing annotations on api #1428

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@
*/
package org.apache.maven.api;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Immutable;
import org.apache.maven.api.annotations.Nonnull;

/**
*
* @since 4.0.0
*/
@Experimental
@Immutable
public interface Dependency extends Artifact {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
*/
package org.apache.maven.api;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;

/**
* Implementation must have {@code equals()} and {@code hashCode()} implemented, so implementations of this interface
* can be used as keys.
*
* @since 4.0.0
*/
@Experimental
public interface ExtensibleEnum {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* An instance of this object is bound to the {@link org.apache.maven.api.di.MojoExecutionScoped}
* and available as {@code mojoExecution} within {@link org.apache.maven.api.plugin.annotations.Parameter}
* expressions.
*
* @since 4.0.0
*/
@Experimental
public interface MojoExecution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

/**
* Represents a maven plugin runtime
*
* @since 4.0.0
*/
@Experimental
public interface Plugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

/**
* A remote repository that can be used to download or upload artifacts.
*
* @since 4.0.0
*/
@Experimental
@Immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Services can be retrieved from the session using the
* {@link Session#getService(Class)} method.
*
* @since 4.0.0
* @see Session#getService(Class)
*/
@Experimental
Expand Down
58 changes: 53 additions & 5 deletions api/maven-api-core/src/main/java/org/apache/maven/api/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,63 @@ Artifact createArtifact(
@Nonnull
VersionConstraint parseVersionConstraint(@Nonnull String versionConstraint);

Type requireType(String id);
/**
* Obtain the {@link Type} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(TypeRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.TypeRegistry#require(String)
*/
@Nonnull
Type requireType(@Nonnull String id);

Language requireLanguage(String id);
/**
* Obtain the {@link Language} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(LanguageRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.LanguageRegistry#require(String)
*/
@Nonnull
Language requireLanguage(@Nonnull String id);

Packaging requirePackaging(String id);
/**
* Obtain the {@link Packaging} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(PackagingRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.PackagingRegistry#require(String)
*/
@Nonnull
Packaging requirePackaging(@Nonnull String id);

ProjectScope requireProjectScope(String id);
/**
* Obtain the {@link ProjectScope} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(ProjectScopeRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.ProjectScopeRegistry#require(String)
*/
@Nonnull
ProjectScope requireProjectScope(@Nonnull String id);

/**
* Obtain the {@link DependencyScope} from the specified {@code id}.
* <p>
* Shortcut for {@code DependencyScope.forId(...)}.
*
* @see org.apache.maven.api.DependencyScope#forId(String)
*/
@Nonnull
DependencyScope requireDependencyScope(@Nonnull String id);

PathScope requirePathScope(String id);
/**
* Obtain the {@link PathScope} from the specified {@code id}.
* <p>
* Shortcut for {@code getService(PathScopeRegistry.class).require(...)}.
*
* @see org.apache.maven.api.services.PathScopeRegistry#require(String)
*/
@Nonnull
PathScope requirePathScope(@Nonnull String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* annotation. If a {@code META-INF/maven/lifecycle.xml} file is packaged
* in the plugin, Maven will provide a default implementation that will parse
* the file and return the contained lifecycle definitions.
*
* @since 4.0.0
*/
@Experimental
@Consumer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.function.Supplier;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Provider;

/**
Expand All @@ -32,6 +33,7 @@
*
* @since 4.0.0
*/
@Experimental
@Provider
public interface Log {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

public interface ExtensibleEnumRegistry<T extends ExtensibleEnum> extends Service {
@Nonnull
Optional<T> lookup(String id);
Optional<T> lookup(@Nonnull String id);

default T require(String id) {
@Nonnull
default T require(@Nonnull String id) {
return lookup(id).orElseThrow(() -> new IllegalArgumentException("Unknown extensible enum value '" + id + "'"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
package org.apache.maven.api.services;

import org.apache.maven.api.ProjectScope;
import org.apache.maven.api.annotations.Experimental;

/**
* Manager for {@link ProjectScope}.
*
* @since 4.0.0
*/
@Experimental
public interface ProjectScopeRegistry extends ExtensibleEnumRegistry<ProjectScope> {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@

import org.apache.maven.api.Service;
import org.apache.maven.api.Session;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;

/**
* Builds the effective settings from a user settings file and/or a global settings file.
*
* @since 4.0.0
*/
@Experimental
public interface SettingsBuilder extends Service {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@

import java.util.List;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.settings.Settings;

/**
*
* @since 4.0.0
*/
@Experimental
public interface SettingsBuilderResult {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

/**
* Provides the super POM that all models implicitly inherit from.
*
* @since 4.0.0
*/
@Experimental
public interface SuperPomProvider extends Service {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

/**
* Builds the effective toolchains from a user toolchains file and/or a global toolchains file.
*
* @since 4.0.0
*/
@Experimental
public interface ToolchainsBuilder extends Service {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
import java.util.Optional;

import org.apache.maven.api.Session;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.annotations.NotThreadSafe;
import org.apache.maven.api.annotations.Nullable;

import static org.apache.maven.api.services.BaseRequest.nonNull;

/**
*
* @since 4.0.0
*/
@Experimental
public interface ToolchainsBuilderRequest {
@Nonnull
Session getSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@

import java.util.List;

import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.toolchain.PersistedToolchains;

/**
*
* @since 4.0.0
*/
@Experimental
public interface ToolchainsBuilderResult {
/**
* Gets the assembled toolchains.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

/**
* Parses and evaluates version ranges encountered in dependency declarations.
*
* @since 4.0.0
*/
@Experimental
@Consumer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

import static org.apache.maven.api.services.BaseRequest.nonNull;

/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionRangeResolverRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;

/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionRangeResolverResult {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

/**
* Resolves artifact meta/pseudo versions.
*
* @since 4.0.0
*/
@Experimental
@Consumer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

import static org.apache.maven.api.services.BaseRequest.nonNull;

/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionResolverRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;

/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionResolverResult {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* A type can be marked {@link Consumer} or {@link Provider} but not both. A type is assumed to be
* {@link Consumer} if it is not marked either {@link Consumer} or {@link Provider}.
* <p>
* A package can be marked {@link Provider}. In this case, all types in the package are considered
* A package can be marked {@link Consumer}. In this case, all types in the package are considered
* to be a provider type regardless of whether they are marked {@link Consumer} or {@link Provider}.
*
* @see Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,24 @@
import java.util.Collection;

import org.apache.maven.api.ExtensibleEnum;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;

/**
* An SPI interface to extend Maven with a new enum value.
*
* @param <T> The type of extensible enum to extend
*/
@Experimental
@Consumer
public interface ExtensibleEnumProvider<T extends ExtensibleEnum> extends SpiService {

/**
* Registers new values for the T extensible enum.
*
* @return a collection of T instances to register
*/
@Nonnull
Collection<T> provides();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@
package org.apache.maven.api.spi;

import org.apache.maven.api.Language;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;

/**
* @since 4.0.0
*/
@Experimental
@Consumer
public interface LanguageProvider extends ExtensibleEnumProvider<Language> {}
Loading