Class MavenFactory

java.lang.Object
io.smallrye.beanbag.maven.MavenFactory

public final class MavenFactory extends Object
A factory for objects that are useful for resolving dependencies via Maven.
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a new factory.
    create(ClassLoader classLoader)
    Create a new factory.
    create(ClassLoader classLoader, Consumer<io.smallrye.beanbag.BeanBag.Builder> configurator)
    Create a new factory.
    create(ClassLoader classLoader, Consumer<io.smallrye.beanbag.BeanBag.Builder> configurator, io.smallrye.beanbag.DependencyFilter dependencyFilter)
    Create a new factory.
    create(List<ClassLoader> classLoaders, Consumer<io.smallrye.beanbag.BeanBag.Builder> configurator, io.smallrye.beanbag.DependencyFilter dependencyFilter)
    Create a new factory.
    static List<org.eclipse.aether.repository.RemoteRepository>
    createRemoteRepositoryList(org.apache.maven.settings.Settings settings)
    Create a remote repository list from the given settings.
    org.eclipse.aether.RepositorySystemSession
    createSession(org.apache.maven.settings.Settings settings)
    Create a repository system session using the given settings with reasonable default behavior.
    static org.apache.maven.settings.Settings
    createSettings(File globalSettings, File userSettings, Consumer<org.apache.maven.settings.building.SettingsProblem> problemHandler)
    Create a basic settings instance using reasonable defaults.
    org.apache.maven.settings.Settings
    createSettingsFromContainer(File globalSettings, File userSettings, Consumer<org.apache.maven.settings.building.SettingsProblem> problemHandler)
    Create a basic settings from the container SettingsBuilder using reasonable defaults.
    dumpSettings(StringBuilder sb, org.apache.maven.settings.Settings settings, int indent)
    Dump the given settings to a string.
    static String
    dumpSettings(org.apache.maven.settings.Settings settings)
    Dump the given settings to a string.
    io.smallrye.beanbag.BeanBag
    Get the bean container used to set up the Maven environment.
    static File
    Get the location of the global settings file, if it can be determined.
    org.eclipse.aether.RepositorySystem
    Locate the Maven repository system instance.
    org.apache.maven.settings.building.SettingsBuilder
    Locate the Maven settings builder instance.
    static File
    Get the location of the user settings file, if it can be determined.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static MavenFactory create(List<ClassLoader> classLoaders, Consumer<io.smallrye.beanbag.BeanBag.Builder> configurator, io.smallrye.beanbag.DependencyFilter dependencyFilter)
      Create a new factory. The given class loader instances are used to find the components of the Maven resolver.
      Parameters:
      classLoaders - the class loaders to search (must not be null)
      configurator - an additional configurator which can be used to modify the container configuration (must not be null)
      dependencyFilter - a filter which can be used to exclude certain implementations (must not be null)
      Returns:
      the Maven factory instance (not null)
    • create

      public static MavenFactory create(ClassLoader classLoader, Consumer<io.smallrye.beanbag.BeanBag.Builder> configurator, io.smallrye.beanbag.DependencyFilter dependencyFilter)
      Create a new factory. The given class loader instance is used to find the components of the Maven resolver.
      Parameters:
      classLoader - the class loader (must not be null)
      configurator - an additional configurator which can be used to modify the container configuration (must not be null)
      dependencyFilter - a filter which can be used to exclude certain implementations (must not be null)
      Returns:
      the Maven factory instance (not null)
    • create

      public static MavenFactory create(ClassLoader classLoader, Consumer<io.smallrye.beanbag.BeanBag.Builder> configurator)
      Create a new factory. The given class loader instance is used to find the components of the Maven resolver.
      Parameters:
      classLoader - the class loader (must not be null)
      configurator - an additional configurator which can be used to modify the container configuration (must not be null)
      Returns:
      the Maven factory instance (not null)
    • create

      public static MavenFactory create(ClassLoader classLoader)
      Create a new factory. The given class loader instance is used to find the components of the Maven resolver.
      Parameters:
      classLoader - the class loader (must not be null)
      Returns:
      the Maven factory instance (not null)
    • create

      public static MavenFactory create()
      Create a new factory. The caller's class loader instance is used to find the components of the Maven resolver.
      Returns:
      the Maven factory instance (not null)
    • getContainer

      public io.smallrye.beanbag.BeanBag getContainer()
      Get the bean container used to set up the Maven environment.
      Returns:
      the container (not null)
    • getRepositorySystem

      public org.eclipse.aether.RepositorySystem getRepositorySystem() throws io.smallrye.beanbag.BeanInstantiationException
      Locate the Maven repository system instance.
      Returns:
      the repository system instance (not null)
      Throws:
      io.smallrye.beanbag.BeanInstantiationException - if there is some problem finding or creating the repository system instance
    • getSettingsBuilder

      public org.apache.maven.settings.building.SettingsBuilder getSettingsBuilder() throws io.smallrye.beanbag.BeanInstantiationException
      Locate the Maven settings builder instance.
      Returns:
      the repository system instance (not null)
      Throws:
      io.smallrye.beanbag.BeanInstantiationException - if there is some problem finding or creating the repository system instance
    • createSettingsFromContainer

      public org.apache.maven.settings.Settings createSettingsFromContainer(File globalSettings, File userSettings, Consumer<org.apache.maven.settings.building.SettingsProblem> problemHandler) throws org.apache.maven.settings.building.SettingsBuildingException
      Create a basic settings from the container SettingsBuilder using reasonable defaults.
      Parameters:
      globalSettings - the global settings file (may be null if none)
      userSettings - the user settings file (may be null if none)
      problemHandler - the problem handler (may be null if none)
      Returns:
      the settings (not null)
      Throws:
      org.apache.maven.settings.building.SettingsBuildingException - if creating the settings has failed
    • createSettings

      public static org.apache.maven.settings.Settings createSettings(File globalSettings, File userSettings, Consumer<org.apache.maven.settings.building.SettingsProblem> problemHandler) throws org.apache.maven.settings.building.SettingsBuildingException
      Create a basic settings instance using reasonable defaults.
      Parameters:
      globalSettings - the global settings file (may be null if none)
      userSettings - the user settings file (may be null if none)
      problemHandler - the problem handler (may be null if none)
      Returns:
      the settings (not null)
      Throws:
      org.apache.maven.settings.building.SettingsBuildingException - if creating the settings has failed
    • createSession

      public org.eclipse.aether.RepositorySystemSession createSession(org.apache.maven.settings.Settings settings) throws io.smallrye.beanbag.BeanInstantiationException
      Create a repository system session using the given settings with reasonable default behavior.
      Parameters:
      settings - the settings to use (must not be null)
      Returns:
      the repository system session (not null)
      Throws:
      io.smallrye.beanbag.BeanInstantiationException - if there is some problem finding or creating the repository system instance
    • createRemoteRepositoryList

      public static List<org.eclipse.aether.repository.RemoteRepository> createRemoteRepositoryList(org.apache.maven.settings.Settings settings)
      Create a remote repository list from the given settings.
      Parameters:
      settings - the settings (must not be null)
      Returns:
      the remote repository list (not null)
    • getGlobalSettingsLocation

      public static File getGlobalSettingsLocation()
      Get the location of the global settings file, if it can be determined. The file may or may not actually exist.
      Returns:
      the location of the global settings file, or null if it cannot be determined
    • getUserSettingsLocation

      public static File getUserSettingsLocation()
      Get the location of the user settings file, if it can be determined. The file may or may not actually exist.
      Returns:
      the location of the user settings file, or null if it cannot be determined
    • dumpSettings

      public static String dumpSettings(org.apache.maven.settings.Settings settings)
      Dump the given settings to a string. Any passwords or secrets in the settings are masked. This is mainly useful for debugging; the output format may change and is not intended to be parsed by machines.
      Parameters:
      settings - the settings to dump (must not be null)
      Returns:
      a string containing the dump of the settings
    • dumpSettings

      public static StringBuilder dumpSettings(StringBuilder sb, org.apache.maven.settings.Settings settings, int indent)
      Dump the given settings to a string. Any passwords or secrets in the settings are masked. This is mainly useful for debugging; the output format may change and is not intended to be parsed by machines.
      Parameters:
      sb - the string builder to append to (must not be null)
      settings - the settings to dump (must not be null)
      indent - the indentation level
      Returns:
      the string builder sb