Maven Core class descriptions
I want to understand how Maven works so I’m gonna look at all classes. There are 368 in the maven-core module alone, or actually more, as some are generated during the generate-source phase by the Modello plugin (Model, Profile and Prerequisites from the org.apache.maven.api.model package). Total of packages is 52 I think.
It is gonna be extremely laborious work but I might learn a lot. My most important motivation to do this is to get a better understanding of complex codebases which will help me to build and/or find the right tools for quicker and more effective ways of code exploration.
Note: I might not finish this list, it is just a begin of laborious work to understand a complex codebase.\
Note 2: to read this page correctly, read it in the GitHub repository directly instead of on the static blog page. The latter does not display the collapsable sections well, or actually it only shows the first part of the whole thing.
package org.apache.maven;
AbstractMavenLifecycleParticipant : public abstract class
The classes implementing this class reside in the test directory.
Allows core extensions to participate in Maven build session lifecycle.
All callback methods (will) follow beforeXXX/afterXXX naming pattern to indicate at what lifecycle point it is being called.
@see example @see MNG-4224 @since 3.0-alpha-3 GitHub
BuildAbort : public class extends Error
A special throwable used to signal a graceful abort of the build.
BuildFailureException : public class extends Exception
One or more builds failed.
DefaultMaven : public class implements Maven
@Singleton
Big class. Many fields. Key terms: profiles, Mavensession, MavenExecutionResult, dependencyGraph, callListeners, validateLocalRepository, getExtensionComponents, getProjectScopedExtensionComponents, validatePrerequisitesForNonMavenPluginProjects, getAllProfiles.
Interface Maven is an interface in the same folder.
Three imports do not work: Model, Prerequisites and Profile. These are created during generate-sources phase by the modello plugin, based on .mdo file.
GitHub
DuplicateProjectException : public class extends MavenExecutionException
Small Exception class. Has method that gets and returns pom files of colliding projects.
Signals a collision of two or more projects with the same g:a:v during a reactor build.
GitHub
InternalErrorException : public class extends MavenExecutionException
Signals an internal error in Maven itself, e.g. a programming bug.
Maven : public interface
One method inside: MavenExecutionResult execute(MavenExecutionRequest request);
The main Maven execution entry point, which will execute a full Maven execution session. Implemented by DefaultMaven.
@see org.apache.maven.execution.MavenSession
GitHub
MavenExecutionException : public class extends Exception
Has this method: public File getPomFile() {return pomFile;}
The Exception is created with pom file as argument.
GitHub
MissingProfilesException : public class extends Exception
Signals that the user referenced one or more Maven profiles that could not be located in either the project or the settings.
GitHub
ProjectBuildFailureException : public class extends BuildFailureException
Has method public String >getProjectId() { return projectId; }
Exception which occurs when a normal (i.e. non-aggregator) mojo fails to execute. In this case, the mojo failed while executing against a particular project instance, so we can wrap the {@link MojoFailureException} with context information including projectId that caused the failure.
GitHub
ProjectCycleException : public class extends BuildFailureException
No Javadoc comments, no get method.
GitHub
ReactorReader : class ReactorReader implements MavenWorkspaceReader
MavenWorkspaceReader comes from maven-imp module.
MavenWorkspaceReader is interface with one method:
-> Model findModel(Artifact artifact);
Note the 'Model' return value and the 'Artifact' argument.
MavenWorkspaceReader extends WorkspaceReader from org.eclipse.aether.repository
Public methods:
public WorkspaceRepository getRepository()
public File findArtifact(Artifact artifact)
public List
public Model findModel(Artifact artifact)
An implementation of a workspace reader that knows how to search the Maven reactor for artifacts, either as packaged jar if it has been built, or only compile output directory if packaging hasn't happened yet.
GitHub
</details>
RepositoryUtils : public class
Utility class with lots of imports from:
- org.apache.maven.artifact
- org.eclipse.aether.artifact
- org.eclipse.aether.graph
- org.eclipse.aether.repository
Object types: ArtifactHandler, DefaultArtifactHandler, ArtifactHandlerManager, ArtifactRepository, ArtifactRepositoryPolicy, MavenArtifactProperties, DefaultRepositorySystemSession, RepositorySystem, RepositorySystemSession, Artifact, ArtifactProperties, ArtifactType, ArtifactTypeRegistry, DefaultArtifact, DefaultArtifactType, Dependency, DependencyFilter, DependencyNode, Exclusion, Authentication, LocalRepository, LocalRepositoryManager, Proxy, RemoteRepository, RepositoryPolicy, WorkspaceReader, WorkspaceRepository, AuthenticationBuilder.
Remarkable: the Maven Artifact type and the Eclipse Artifact type seemto differ, given this method:
-> public static org.apache.maven.artifact.Artifact toArtifact(Artifact artifact)
Warning: This is an internal utility class that is only public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without prior notice.
GitHub
SessionScoped : public @interface
Marker annotation, @Retention(RUNTIME)
Indicates that annotated component should be instantiated before session execution starts and discarded after session execution completes.
GitHub
DependencyResolutionRequiredException : public class extends Exception
Exception constructor has Artifact as argument.
Message: "Attempted to access the artifact " + artifact + "; which has not yet been resolved"
Exception that occurs when an artifact file is used, but has not been resolved.
GitHub
InvalidRepositoryException : public class extends Exception
String repositoryId is an argument for the constructor.
Error constructing an artifact repository.
GitHub
ArtifactFactory : public interface (deprecated)
Interface defining all sorts of constructors for Artifact object. DEPRECATED.
Selection of constructors:
-> Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type);
-> Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier);
-> Artifact createDependencyArtifact(String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional);
-> Artifact createBuildArtifact(String groupId, String artifactId, String version, String packaging);
-> Artifact createProjectArtifact(String groupId, String artifactId, String version);
-> Artifact createParentArtifact(String groupId, String artifactId, String version);
-> Artifact createPluginArtifact(String groupId, String artifactId, VersionRange versionRange);
-> Artifact createProjectArtifact(String groupId, String artifactId, String version, String scope);
-> Artifact createExtensionArtifact(String groupId, String artifactId, VersionRange versionRange);
ArtifactFactory - deprecated.
GitHub
DefaultArtifactFactory : public class implements ArtifactFactory
Implementation of interface. The constructor with the complete set of arguments does all the work:
-> private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope, boolean optional);
It is not a static factory, everything instance based. The constructor has an interesting argument:
-> public DefaultArtifactFactory(ArtifactHandlerManager artifactHandlerManager) { this.artifactHandlerManager = artifactHandlerManager; }
DefaultArtifactFactory.
GitHub
DefaultArtifactHandler : public class implements ArtifactHandler
Class that creates ArtifactHandler instances. Lot of getters and setters. The constructor with all params is the following:
-> public DefaultArtifactHandler(final String type, final String extension, final String classifier, final String directory, final String packaging, final boolean includesDependencies, final String language, final boolean addedToClasspath);
GitHub
ArtifactHandlerManager : public interface
Interface, one final static field and one method (second method is deprecated):
-> String ROLE = ArtifactHandlerManager.class.getName();
-> ArtifactHandler getArtifactHandler(String type);
GitHub
DefaultArtifactHandlerManager : public class extends AbstractEventSpy implements ArtifactHandlerManager
@Singleton
This is the constructor declaration. Note the TypeRegistry argument:
public DefaultArtifactHandlerManager(TypeRegistry typeRegistry)
GitHub
LegacyArtifactHandlerManager : public class extends AbstractEventSpy
@Singleton
This is the constructor:
public LegacyArtifactHandlerManager(Map<String, ArtifactHandler> artifactHandlers) {this.artifactHandlers = requireNonNull(artifactHandlers);} GitHub
DefaultRepositoryRequest : public class implements RepositoryRequest
Four instance fields:
private boolean offline;
private boolean forceUpdate;
private ArtifactRepository localRepository;
private List<ArtifactRepository> remoteRepositories;
Constructor creates a shallow copy of the specified repository request.
public DefaultRepositoryRequest(RepositoryRequest repositoryRequest) {
setLocalRepository(repositoryRequest.getLocalRepository());
setRemoteRepositories(repositoryRequest.getRemoteRepositories());
setOffline(repositoryRequest.isOffline());
setForceUpdate(repositoryRequest.isForceUpdate());
}
Collects basic settings to access the repository system.
## package org.apache.maven.artifact.repository; GitHub
MavenArtifactRepository : public class implements ArtifactRepository
These are the fields. Lots of getters and setters:
private static final String LS = System.lineSeparator();
private String id;
private String url;
private String basedir;
private Path basedirPath;
private String protocol;
private ArtifactRepositoryLayout layout;
private ArtifactRepositoryPolicy snapshots;
private ArtifactRepositoryPolicy releases;
private Authentication authentication;
private Proxy proxy;
private List<ArtifactRepository> mirroredRepositories = Collections.emptyList();
private boolean blocked;
Abstraction of an artifact repository. Artifact repositories can be remote, local, or even build reactor or IDE workspace.
GitHub
RepositoryCache : public interface (Deprecated)
@Deprecated
Caches auxiliary data used during repository access like already processed metadata. The data in the cache is meant for exclusive consumption by the repository system and is opaque to the cache implementation.
GitHub
RepositoryRequest : public interface
Collects basic settings to access the repository system.
GitHub
DefaultRepositoryLayout : public class implements ArtifactRepositoryLayout
@Singleton
This class has methods in it that compose path-like strings using StringBuilder, with groupId, artifactId, baseVersion etc.
GitHub
DefaultMetadataReader : public class implements MetadataReader
@Singleton
Uses library org.apache.maven.artifact.repository.metadata.Metadata but MetaData class is not in it. Can be a modello thing. Has all sorts of read methods that read metadata in various types.
Handles deserialization of metadata from some kind of textual format like XML.
GitHub
MetadataParseException : public class extends IOException
Error message has int lineNumber and int columnNumber as arguments. Has get methods for both.
Signals a failure to parse the metadata due to invalid syntax (e.g. non well formed XML or unknown elements).
GitHub
MetadataReader : public interface
All about reading metadata and whether to be strict with parsing.
Handles deserialization of metadata from some kind of textual format like XML.
GitHub
AbstractScopeArtifactFilter : abstract class implements ArtifactFilter
Fields:
private boolean compileScope;
private boolean runtimeScope;
private boolean testScope;
private boolean providedScope;
private boolean systemScope;
Filter to only retain objects in the given artifactScope or better.
GitHub
AndArtifactFilter : public class implements ArtifactFilter
One field:
private Set<ArtifactFilter> filters;
Apply multiple filters.
GitHub
CumulativeScopeArtifactFilter : public class extends AbstractScopeArtifactFilter
One field:
private Set<String> scopes;
Filter to only retain objects in the given scope or better. This implementation allows the accumulation of multiple scopes and their associated implied scopes, so that the user can single step. This should be a more efficient implementation of multiple standard {@link ScopeArtifactFilter} instances ORed together.
GitHub
ExcludesArtifactFilter : public class extends IncludesArtifactFilter
Filter to exclude from a list of artifact patterns.
GitHub
ExclusionArtifactFilter : public class implements ArtifactFilter
Filter to exclude from a list of artifact patterns.
GitHub
ExclusionSetFilter : public class implements ArtifactFilter
One field:
private Set<String> excludes;
Filter to exclude from a list of artifact patterns.
GitHub
IncludesArtifactFilter : public class implements ArtifactFilter
One field:
private final Set<String> patterns;
Filter to include from a list of artifact patterns.
GitHub
ScopeArtifactFilter : public class extends AbstractScopeArtifactFilter
One field:
private final String scope;
Filter to only retain objects in the given artifactScope or better.
GitHub
MavenRepositorySystem : public class
@Singleton
Huge class, no Javadoc. I find it remarkable that it has (overloaded) methods that create all sorts of Artifact objects. Class DefaultArtifactFactory has all these methods as well.
Other remarkable thing: hardcoded value for repository:
-> public static final String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2";
GitHub
ArtifactClassRealmConstituent : class implements ClassRealmConstituent
One field:
private final Artifact artifact;
This class lets you inquire the specific artifact object it contains using get methods.
GitHub
ClassRealmConstituent : public interface
Interface describing ArtifactClassRealmConstituent.
Describes a constituent of a class realm.
GitHub
ClassRealmManager : public interface
Manages the class realms used by Maven. Warning: This is an internal utility interface that is only public for technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without prior notice.
GitHub
ClassRealmManagerDelegate : public interface
ClassRealmManagerDelegate is used to perform addition configuration of class realms created by ClassRealmManager.
GitHub
ClassRealmRequest : public interface
Contains an enum 'RealmType', values Core, Project, Plugin, Extension.
Describes the requirements for a new class realm.
GitHub
DefaultClassRealmManager : public class implements ClassRealmManager
@Singleton
Has methods to create ClassRealms. It is a big class.
Manages the class realms used by Maven. Warning: This is an internal utility class that is only public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without prior notice.
GitHub
DefaultClassRealmRequest : class implements ClassRealmRequest
POJO, getters and setters. This is the constructor:
-> DefaultClassRealmRequest( RealmType type, ClassLoader parent, List
GitHub
</details> ## package org.apache.maven.configuration;
BasedirBeanConfigurationPathTranslator : public class implements BeanConfigurationPathTranslator
Just one import:
-> import java.io.File;
And one method:
public File translatePath(File path)
A path translator that resolves relative paths against a specific base directory.
GitHub
BeanConfigurationException : public class extends Exception
Thrown when a bean couldn't be configured.
GitHub
BeanConfigurationPathTranslator : public interface
Implemented by BasedirBeanConfigurationPathTranslator.
Postprocesses filesystem paths. For instance, a path translator might want to resolve relative paths given in the bean configuration against some base directory.
GitHub
BeanConfigurationRequest : public interface
A request to configure a bean from some configuration in the POM or similar.
GitHub
BeanConfigurationValuePreprocessor : public interface
Preprocesses a value from a bean configuration before the bean configurator unmarshals it into a bean property. A common use case for such preprocessing is the evaluation of variables within the configuration value.
GitHub
BeanConfigurator : public interface
Unmarshals some textual configuration from the POM or similar into the properties of a bean. This component works similar to the way Maven configures plugins from the POM, i.e. some configuration like {@code value</param>} is mapped to an equally named property of the bean and converted. The properties of the bean are supposed to either have a public setter or be backed by an equally named field (of any visibility).
GitHub
DefaultBeanConfigurationRequest : public class implements BeanConfigurationRequest
This is an interesting class, seems to deal with finding and configuring plugins.
Constructor:
public DefaultBeanConfigurationRequest setConfiguration(
Model model,
String pluginGroupId,
String pluginArtifactId,
String pluginExecutionId
)
Javadoc constructor: Sets the configuration to the configuration taken from the specified build plugin in the POM. First, the build plugins will be searched for the specified plugin, if that fails, the plugin management section will be searched.
Javadoc class: Basic bean configuration request.
GitHub
DefaultBeanConfigurator : public class implements BeanConfigurator
@Singleton
Has nested static classes in it, 'XmlConverter' and 'PathConverter'.
Warning: This is an internal class that is only public for technical reasons, it is not part of the public API. In particular, this class can be changed or deleted without prior notice.
GitHub
EnhancedComponentConfigurator : public class extends BasicComponentConfigurator
@Singleton
A component configurator which can leverage the {@link EnhancedConfigurationConverter} and {@link EnhancedConverterLookup}.
GitHub
EnhancedConfigurationConverter : class extends ObjectWithFieldsConverter
An enhanced {@link ObjectWithFieldsConverter} leveraging the {@link TypeAwareExpressionEvaluator} interface.
GitHub