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
  • Constructor Details

    • MavenExecutionContextView

      public MavenExecutionContextView(org.openrewrite.ExecutionContext delegate)
  • Method Details

    • view

      public static MavenExecutionContextView view(org.openrewrite.ExecutionContext ctx)
    • recordResolutionTime

      public MavenExecutionContextView recordResolutionTime(Duration time)
    • getResolutionTime

      public Duration getResolutionTime()
    • setResolutionListener

      public MavenExecutionContextView setResolutionListener(ResolutionEventListener listener)
    • getResolutionListener

      public ResolutionEventListener getResolutionListener()
    • setMirrors

      public MavenExecutionContextView setMirrors(@Nullable Collection<MavenRepositoryMirror> mirrors)
    • getMirrors

      public Collection<MavenRepositoryMirror> getMirrors()
    • getMirrors

      public Collection<MavenRepositoryMirror> getMirrors(@Nullable MavenSettings mavenSettings)
      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

      public MavenExecutionContextView setCredentials(Collection<MavenRepositoryCredentials> credentials)
    • getCredentials

      public Collection<MavenRepositoryCredentials> getCredentials()
    • getCredentials

      public Collection<MavenRepositoryCredentials> getCredentials(@Nullable MavenSettings mavenSettings)
      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

      public MavenExecutionContextView setPomCache(MavenPomCache pomCache)
    • getPomCache

      public MavenPomCache getPomCache()
    • setLocalRepository

      public MavenExecutionContextView setLocalRepository(MavenRepository localRepository)
    • getLocalRepository

      public MavenRepository getLocalRepository()
    • setAddLocalRepository

      public MavenExecutionContextView setAddLocalRepository(boolean useLocalRepository)
    • getAddLocalRepository

      public @Nullable Boolean getAddLocalRepository()
    • setAddCentralRepository

      public MavenExecutionContextView setAddCentralRepository(boolean useCentralRepository)
    • getAddCentralRepository

      public @Nullable Boolean getAddCentralRepository()
    • setRepositories

      public MavenExecutionContextView setRepositories(List<MavenRepository> repositories)
    • getRepositories

      public List<MavenRepository> 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

      public Collection<ResolvedGroupArtifactVersion> getPinnedSnapshotVersions()
    • setActiveProfiles

      public MavenExecutionContextView setActiveProfiles(List<String> activeProfiles)
    • getActiveProfiles

      public List<String> getActiveProfiles()
    • setMavenSettings

      public MavenExecutionContextView setMavenSettings(@Nullable MavenSettings settings, String... activeProfiles)
      Replaces the current Maven execution settings with the provided MavenSettings.

      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 settings is null, this call is a no-op and the current configuration remains unchanged.

      Parameters:
      settings - the Maven settings to apply; if null, no changes are made
      activeProfiles - 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

      public @Nullable MavenSettings 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.