Maven2 compatibility layer providing legacy APIs for Maven3 environment.
npx @tessl/cli install tessl/maven-org-apache-maven--maven-compat@3.9.0Maven Compat is a Java library that provides backward compatibility for Maven2 APIs within the Apache Maven ecosystem. This compatibility layer preserves legacy Maven2 APIs and functionality that may still be needed by plugins or tools built for earlier versions of Maven, enabling smooth transitions and continued operation of older Maven-based tools and plugins.
pom.xml:<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.9.11</version>
</dependency>// Runtime information
import org.apache.maven.execution.RuntimeInformation;
import org.apache.maven.execution.DefaultRuntimeInformation;
// Artifact management
import org.apache.maven.artifact.ArtifactScopeEnum;
import org.apache.maven.artifact.ArtifactStatus;
// Artifact operations
import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.installer.ArtifactInstaller;
import org.apache.maven.artifact.resolver.ArtifactResolver;
// Repository operations
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
// Profile management
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.DefaultProfileManager;
// Project building
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuilderConfiguration;
// Legacy repository system
import org.apache.maven.repository.legacy.LegacyRepositorySystem;// Create a runtime information instance
RuntimeInformation runtimeInfo = new DefaultRuntimeInformation();
ArtifactVersion version = runtimeInfo.getApplicationVersion();
// Work with artifact scopes
ArtifactScopeEnum scope = ArtifactScopeEnum.compile;
boolean includesTest = scope.encloses(ArtifactScopeEnum.test);
// Create artifact status
ArtifactStatus status = ArtifactStatus.valueOf("DEPLOYED");
// Use profile manager for profile activation
ProfileManager profileManager = new DefaultProfileManager();
profileManager.explicitlyActivate("production");
List activeProfiles = profileManager.getActiveProfiles();
// Repository operations through legacy system
LegacyRepositorySystem repoSystem = new LegacyRepositorySystem();
ArtifactRepository localRepo = repoSystem.createDefaultLocalRepository();Maven Compat is organized into several key functional areas:
Important Note: Most APIs in this library are marked as @Deprecated and are maintained solely for backward compatibility. New development should use the corresponding Maven 3.x APIs where available.
Provides Maven runtime version information and execution context for compatibility with Maven2 patterns.
public interface RuntimeInformation {
ArtifactVersion getApplicationVersion();
}
public class DefaultRuntimeInformation implements RuntimeInformation {
public ArtifactVersion getApplicationVersion();
}Core artifact management functionality including scoping, status tracking, and repository layout support.
public enum ArtifactScopeEnum {
compile(1), test(2), runtime(3), provided(4), system(5), runtime_plus_system(6);
String getScope();
boolean encloses(ArtifactScopeEnum scope);
static ArtifactScopeEnum checkScope(ArtifactScopeEnum scope);
}
public class ArtifactStatus implements Comparable<ArtifactStatus> {
public static final ArtifactStatus NONE, GENERATED, CONVERTED, PARTNER, DEPLOYED, VERIFIED;
static ArtifactStatus valueOf(String status);
int compareTo(ArtifactStatus s);
}Legacy repository system providing artifact deployment, installation, resolution, and repository management.
public interface ArtifactDeployer {
String ROLE = ArtifactDeployer.class.getName();
void deploy(File source, Artifact artifact, ArtifactRepository deploymentRepository,
ArtifactRepository localRepository) throws ArtifactDeploymentException;
}
public interface ArtifactInstaller {
String ROLE = ArtifactInstaller.class.getName();
void install(File source, Artifact artifact, ArtifactRepository localRepository)
throws ArtifactInstallationException;
}
public interface ArtifactResolver {
ArtifactResolutionResult resolve(ArtifactResolutionRequest request);
// Many deprecated methods also available - see sub-doc for complete API
}Maven profile activation and management system for backward compatibility with Maven2 profile handling.
public interface ProfileManager {
void addProfile(Profile profile);
void explicitlyActivate(String profileId);
void explicitlyDeactivate(String profileId);
List getActiveProfiles() throws ProfileActivationException;
Properties getRequestProperties();
}
public interface MavenProfilesBuilder {
String ROLE = MavenProfilesBuilder.class.getName();
ProfilesRoot buildProfiles(File basedir) throws ProfilesBuilderException;
}Legacy project building system for constructing Maven projects from POM files with Maven2 compatibility.
public interface MavenProjectBuilder {
MavenProject build(File pom, ProjectBuilderConfiguration configuration)
throws ProjectBuildingException;
MavenProject buildFromRepository(Artifact artifact, List<ArtifactRepository> remoteRepositories,
ArtifactRepository localRepository) throws ProjectBuildingException;
MavenProject buildStandaloneSuperProject(ProjectBuilderConfiguration configuration)
throws ProjectBuildingException;
}
public interface ProjectBuilderConfiguration {
// Configuration methods for project building
}Dependency metadata processing, graph management, and classpath transformation for legacy compatibility.
public interface MetadataSource {
String ROLE = MetadataSource.class.getName();
MetadataResolution retrieve(ArtifactMetadata artifact, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories) throws MetadataRetrievalException;
}
public interface ClasspathTransformation {
String ROLE = ClasspathTransformation.class.getName();
ClasspathContainer transform(MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve)
throws ClasspathTransformationException;
}Main legacy repository system implementation providing comprehensive backward compatibility.
public class LegacyRepositorySystem implements RepositorySystem {
Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type);
ArtifactRepository createDefaultLocalRepository() throws InvalidRepositoryException;
ArtifactResolutionResult resolve(ArtifactResolutionRequest request) throws ArtifactResolutionException;
void injectMirror(List<ArtifactRepository> repositories, List<Mirror> mirrors);
void injectAuthentication(List<ArtifactRepository> repositories, List<Server> servers);
}