Package org.openrewrite.maven
Class MavenExecutionContextView
java.lang.Object
org.openrewrite.DelegatingExecutionContext
org.openrewrite.maven.MavenExecutionContextView
- All Implemented Interfaces:
org.openrewrite.ExecutionContext,org.openrewrite.rpc.RpcCodec<org.openrewrite.ExecutionContext>
public class MavenExecutionContextView
extends org.openrewrite.DelegatingExecutionContext
-
Field Summary
Fields inherited from interface org.openrewrite.ExecutionContext
CURRENT_CYCLE, CURRENT_RECIPE, REQUIRE_PRINT_EQUALS_INPUT, RUN_TIMEOUT, SCANNING_MUTATION_VALIDATION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable MavenSettingseffectiveSettings(org.openrewrite.maven.tree.MavenResolutionResult mrr) The maven settings in effect are a combination of the settings defined in the context and the settings that were in effect when a given pom was parsed.@Nullable Boolean@Nullable BooleanGet a sharedMavenArtifactCachefor this execution context, lazily initializing one on first access.getCredentials(@Nullable MavenSettings mavenSettings) Get credentials set on this execution context, unless overridden by a supplied maven settings file.getMirrors(@Nullable MavenSettings mavenSettings) Get mirrors set on this execution context, unless overridden by a supplied maven settings file.getRepositories(@Nullable MavenSettings mavenSettings, @Nullable List<String> activeProfiles) Get repositories set on this execution context, unless overridden by a supplied maven settings file.@Nullable MavenSettingsConnection endpoints, each ahost:port, that have proven unreachable (a connection-level failure, as opposed to an HTTP error response) during this execution.recordResolutionTime(Duration time) setActiveProfiles(List<String> activeProfiles) setAddCentralRepository(boolean useCentralRepository) setAddLocalRepository(boolean useLocalRepository) setArtifactCache(MavenArtifactCache artifactCache) setCredentials(Collection<MavenRepositoryCredentials> credentials) setLocalRepository(MavenRepository localRepository) setMavenSettings(@Nullable MavenSettings settings, String... activeProfiles) Replaces the current Maven execution settings with the providedMavenSettings.setMirrors(@Nullable Collection<MavenRepositoryMirror> mirrors) setPinnedSnapshotVersions(Collection<ResolvedGroupArtifactVersion> pinnedSnapshotVersions) Require dependency resolution that encounters a matching group:artifact:version coordinate to resolve to a particular dated snapshot version, effectively making snapshot resolution deterministic.setPomCache(MavenPomCache pomCache) setRepositories(List<MavenRepository> repositories) setResolutionListener(ResolutionEventListener listener) static MavenExecutionContextViewview(org.openrewrite.ExecutionContext ctx) Methods inherited from class org.openrewrite.DelegatingExecutionContext
getDelegate, getMessage, getMessages, getOnError, getOnTimeout, pollMessage, putMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.ExecutionContext
addObserver, computeMessage, computeMessageIfAbsent, getCycle, getCycleDetails, getMessage, getObservers, pollMessage, putCurrentRecipe, putMessageInCollection, putMessageInSet, rpcReceive, rpcSend
-
Constructor Details
-
MavenExecutionContextView
public MavenExecutionContextView(org.openrewrite.ExecutionContext delegate)
-
-
Method Details
-
view
-
recordResolutionTime
-
getResolutionTime
-
getUnreachableEndpoints
Connection endpoints, each ahost:port, that have proven unreachable (a connection-level failure, as opposed to an HTTP error response) during this execution. Repositories on these endpoints are skipped for the remainder of the run rather than re-probed for every declaration, so a single dead repository costs one connection timeout instead of one per artifact. The key ishost:portrather than the full repository URI because a connection failure occurs before any path is sent and so is independent of the path; the same dead host declared under different paths or ids is therefore deduped. The set is concurrent because resolution runs across multiple threads sharing one execution context. -
setResolutionListener
-
getResolutionListener
-
setMirrors
-
getMirrors
-
getMirrors
Get mirrors set on this execution context, unless overridden by a supplied maven settings file.- Parameters:
mavenSettings- The maven settings defining mirrors to use, if any.- Returns:
- The mirrors to use for dependency resolution.
-
setCredentials
-
getCredentials
-
getCredentials
Get credentials set on this execution context, unless overridden by a supplied maven settings file.- Parameters:
mavenSettings- The maven settings defining credentials (in its server configuration) to use, if any.- Returns:
- The credentials to use for dependency resolution.
-
setPomCache
-
getPomCache
-
setArtifactCache
-
getArtifactCache
Get a sharedMavenArtifactCachefor this execution context, lazily initializing one on first access. Defaults to aLocalMavenArtifactCacheat~/.rewrite/cache/artifacts, falling back to a single JVM-lifetime temp directory if the user home directory is not writable.Callers that want to override this (for example, to point at a shared on-disk cache backed by a persistent volume) can do so via
setArtifactCache(MavenArtifactCache)before any recipe visitor resolves artifacts. -
setLocalRepository
-
getLocalRepository
-
setAddLocalRepository
-
getAddLocalRepository
-
setAddCentralRepository
-
getAddCentralRepository
-
setRepositories
-
getRepositories
-
getRepositories
public List<MavenRepository> getRepositories(@Nullable MavenSettings mavenSettings, @Nullable List<String> activeProfiles) Get repositories set on this execution context, unless overridden by a supplied maven settings file.- Parameters:
mavenSettings- The maven settings defining repositories to use, if any.activeProfiles- The active profiles to use, if any, with the accompanying maven settings.- Returns:
- The repositories to use for dependency resolution.
-
setPinnedSnapshotVersions
public MavenExecutionContextView setPinnedSnapshotVersions(Collection<ResolvedGroupArtifactVersion> pinnedSnapshotVersions) Require dependency resolution that encounters a matching group:artifact:version coordinate to resolve to a particular dated snapshot version, effectively making snapshot resolution deterministic.- Parameters:
pinnedSnapshotVersions- A set of group:artifact:version and the dated snapshot version to pin them to.
-
getPinnedSnapshotVersions
-
setActiveProfiles
-
getActiveProfiles
-
setMavenSettings
public MavenExecutionContextView setMavenSettings(@Nullable MavenSettings settings, String... activeProfiles) Replaces the current Maven execution settings with the providedMavenSettings.This method does not merge with or preserve any existing configuration. All previously configured repositories, mirrors, credentials, active profiles, and local repository settings will be discarded and replaced entirely with those derived from the given
settings.If
settingsisnull, this call is a no-op and the current configuration remains unchanged.- Parameters:
settings- the Maven settings to apply; ifnull, no changes are madeactiveProfiles- additional active profiles to consider; these are resolved against the provided settings to determine the effective profiles- Returns:
- this execution context view with the updated Maven settings applied
-
getSettings
-
effectiveSettings
public @Nullable MavenSettings effectiveSettings(org.openrewrite.maven.tree.MavenResolutionResult mrr) The maven settings in effect are a combination of the settings defined in the context and the settings that were in effect when a given pom was parsed.
-