Missing annotations on api (#1428)

This commit is contained in:
Guillaume Nodet 2024-02-29 00:54:53 +01:00 committed by GitHub
parent 24eee1f8e6
commit 456890d40b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 183 additions and 8 deletions

View File

@ -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 {
/**

View File

@ -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 {
/**

View File

@ -31,6 +31,8 @@ import org.apache.maven.api.xml.XmlNode;
* 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 {

View File

@ -29,6 +29,8 @@ import org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle;
/**
* Represents a maven plugin runtime
*
* @since 4.0.0
*/
@Experimental
public interface Plugin {

View File

@ -24,6 +24,8 @@ import org.apache.maven.api.annotations.Nonnull;
/**
* A remote repository that can be used to download or upload artifacts.
*
* @since 4.0.0
*/
@Experimental
@Immutable

View File

@ -27,6 +27,7 @@ import org.apache.maven.api.annotations.ThreadSafe;
* Services can be retrieved from the session using the
* {@link Session#getService(Class)} method.
*
* @since 4.0.0
* @see Session#getService(Class)
*/
@Experimental

View File

@ -502,15 +502,63 @@ public interface Session {
@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);
}

View File

@ -30,6 +30,8 @@ import org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle;
* 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

View File

@ -20,6 +20,7 @@ package org.apache.maven.api.plugin;
import java.util.function.Supplier;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Provider;
/**
@ -32,6 +33,7 @@ import org.apache.maven.api.annotations.Provider;
*
* @since 4.0.0
*/
@Experimental
@Provider
public interface Log {
/**

View File

@ -26,9 +26,10 @@ import org.apache.maven.api.annotations.Nonnull;
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 + "'"));
}
}

View File

@ -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> {}

View File

@ -22,11 +22,15 @@ import java.nio.file.Path;
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 {
/**

View File

@ -20,9 +20,15 @@ package org.apache.maven.api.services;
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 {
/**

View File

@ -25,6 +25,8 @@ import org.apache.maven.api.model.Model;
/**
* Provides the super POM that all models implicitly inherit from.
*
* @since 4.0.0
*/
@Experimental
public interface SuperPomProvider extends Service {

View File

@ -25,6 +25,8 @@ import org.apache.maven.api.annotations.Nonnull;
/**
* 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 {

View File

@ -22,12 +22,18 @@ import java.nio.file.Path;
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();

View File

@ -20,9 +20,15 @@ package org.apache.maven.api.services;
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.

View File

@ -27,6 +27,8 @@ import org.apache.maven.api.annotations.Nonnull;
/**
* Parses and evaluates version ranges encountered in dependency declarations.
*
* @since 4.0.0
*/
@Experimental
@Consumer

View File

@ -26,6 +26,10 @@ import org.apache.maven.api.annotations.NotThreadSafe;
import static org.apache.maven.api.services.BaseRequest.nonNull;
/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionRangeResolverRequest {

View File

@ -26,6 +26,10 @@ import org.apache.maven.api.Version;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionRangeResolverResult {

View File

@ -27,6 +27,8 @@ import org.apache.maven.api.annotations.Nonnull;
/**
* Resolves artifact meta/pseudo versions.
*
* @since 4.0.0
*/
@Experimental
@Consumer

View File

@ -26,6 +26,10 @@ import org.apache.maven.api.annotations.NotThreadSafe;
import static org.apache.maven.api.services.BaseRequest.nonNull;
/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionResolverRequest {

View File

@ -26,6 +26,10 @@ import org.apache.maven.api.Version;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
/**
*
* @since 4.0.0
*/
@Experimental
public interface VersionResolverResult {

View File

@ -31,7 +31,7 @@ import java.lang.annotation.Target;
* 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

View File

@ -21,8 +21,24 @@ package org.apache.maven.api.spi;
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();
}

View File

@ -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> {}

View File

@ -22,6 +22,7 @@ import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;
import org.apache.maven.api.annotations.Nonnull;
import org.apache.maven.api.annotations.Nullable;
@ -31,8 +32,11 @@ import org.apache.maven.api.services.Source;
/**
* The {@code ModelParser} interface is used to locate and read {@link Model}s from the file system.
* This allows plugging in additional syntaxes for the main model read by Maven when building a project.
*
* @since 4.0.0
*/
@Experimental
@Consumer
public interface ModelParser extends SpiService {
/**
@ -64,6 +68,7 @@ public interface ModelParser extends SpiService {
* @return an optional parsed {@link Model} or {@code null} if none could be found
* @throws ModelParserException if the located model cannot be parsed
*/
@Nonnull
default Optional<Model> locateAndParse(@Nonnull Path dir, @Nullable Map<String, ?> options)
throws ModelParserException {
return locate(dir).map(s -> parse(s, options));

View File

@ -19,5 +19,12 @@
package org.apache.maven.api.spi;
import org.apache.maven.api.PathScope;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;
/**
* @since 4.0.0
*/
@Experimental
@Consumer
public interface PathScopeProvider extends ExtensibleEnumProvider<PathScope> {}

View File

@ -19,5 +19,12 @@
package org.apache.maven.api.spi;
import org.apache.maven.api.ProjectScope;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;
/**
* @since 4.0.0
*/
@Experimental
@Consumer
public interface ProjectScopeProvider extends ExtensibleEnumProvider<ProjectScope> {}

View File

@ -20,13 +20,17 @@ package org.apache.maven.api.spi;
import java.util.Map;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;
/**
* Component able to contribute to Maven session user properties. This SPI component is invoked
* very early, while there is no session created yet.
*
* @since 4.0.0
*/
@Experimental
@Consumer
public interface PropertyContributor extends SpiService {
/**
* Invoked just before session is created with a mutable map that carries collected user properties so far.

View File

@ -19,5 +19,12 @@
package org.apache.maven.api.spi;
import org.apache.maven.api.Type;
import org.apache.maven.api.annotations.Consumer;
import org.apache.maven.api.annotations.Experimental;
/**
* @since 4.0.0
*/
@Experimental
@Consumer
public interface TypeProvider extends ExtensibleEnumProvider<Type> {}