Class MavenConfigurationImpl

    • Constructor Detail

      • MavenConfigurationImpl

        public MavenConfigurationImpl​(org.ops4j.util.property.PropertyResolver propertyResolver,
                                      String pid)
        Creates a new service configuration.
        Parameters:
        propertyResolver - propertyResolver used to resolve properties; mandatory
        pid - configuration PID; mandatory
    • Method Detail

      • isValid

        public boolean isValid()
      • getSettingsFileUrl

        public URL getSettingsFileUrl()
        Returns the URL of settings file. Will try first to use the url as is. If a malformed url encountered then will try to use the url as a file path. If still not valid will throw the original Malformed URL exception.
        Specified by:
        getSettingsFileUrl in interface MavenConfiguration
        Returns:
        the url to settings file
        See Also:
        MavenConfiguration.getSettingsFileUrl()
      • getDefaultRepositories

        public List<MavenRepositoryURL> getDefaultRepositories()
                                                        throws MalformedURLException
        Repository is a comma separated list of repositories to be used. If repository acces requests authentication the user name and password must be specified in the repository url as for example http://user:password@repository.ops4j.org/maven2.
        If the repository from 1/2 bellow starts with a plus (+) the option 3 is also used and the repositories from settings.xml will be cummulated.
        Repository resolution:
        1. looks for a configuration property named repository;
        2. looks for a framework property/system setting repository;
        3. looks in settings.xml (see settings.xml resolution). in this case all configured repositories will be used including configured user/password. In this case the central repository is also added. Note that the local repository is added as the first repository if exists.
        Specified by:
        getDefaultRepositories in interface MavenConfiguration
        Returns:
        a list of default repositories. List can be null or empty if there are not default repositories to be searched.
        Throws:
        MalformedURLException
        See Also:
        MavenConfiguration.getRepositories(), MavenConfiguration.getLocalRepository()
      • getRepositories

        public List<MavenRepositoryURL> getRepositories()
                                                 throws MalformedURLException
        Repository is a comma separated list of repositories to be used. If repository access requests authentication the user name and password must be specified in the repository url as for example http://user:password@repository.ops4j.org/maven2.
        If the repository from 1/2 bellow starts with a plus (+) the option 3 is also used and the repositories from settings.xml will be cummulated.
        Repository resolution:
        1. looks for a configuration property named repository;
        2. looks for a framework property/system setting repository;
        3. looks in settings.xml (see settings.xml resolution). in this case all configured repositories will be used including configured user/password. In this case the central repository is also added. Note that the local repository is added as the first repository if exists.
        Specified by:
        getRepositories in interface MavenConfiguration
        Returns:
        a list of repositories. List can be null or empty if there are no repositories to be searched.
        Throws:
        MalformedURLException
        See Also:
        MavenConfiguration.getRepositories(), MavenConfiguration.getLocalRepository()
      • getLocalRepository

        public MavenRepositoryURL getLocalRepository()
        Resolves local repository directory by using the following resolution:
        1. looks for a configuration property named localRepository;
        2. looks for a framework property/system setting localRepository;
        3. looks in settings.xml (see settings.xml resolution);
        4. looks for system property maven.repo.local (PAXURL-231);
        5. falls back to ${user.home}/.m2/repository.
        Specified by:
        getLocalRepository in interface MavenConfiguration
        Returns:
        url of local repository. Can be null if there is no local repository.
        See Also:
        MavenConfiguration.getLocalRepository()
      • getTimeout

        public Integer getTimeout()
        Description copied from interface: MavenConfiguration
        Returns the read timeout configured in case the maven artifact is retrieved from a remote location.
        Specified by:
        getTimeout in interface MavenConfiguration
        Returns:
        the timeout in case artifacts are retrieved from a remote location
      • useFallbackRepositories

        public Boolean useFallbackRepositories()
        Returns true if the fallback repositories should be used instead of default ones. Default value is true.
        Specified by:
        useFallbackRepositories in interface MavenConfiguration
        Returns:
        true if the fallback repositories should be used
      • enableProxy

        @Deprecated
        public void enableProxy​(URL url)
        Deprecated.
        This method has side-effects and is only used in the "old" resolver.
        Enables the proxy server for a given URL.
        Specified by:
        enableProxy in interface MavenConfiguration
        Parameters:
        url - Enables the proxy server for a given URL.
      • getProxySettings

        public Map<String,​Map<String,​String>> getProxySettings​(String... protocols)
        Description copied from interface: MavenConfiguration
        Returns the active proxy settings from settings.xml The fields are user, pass, host, port, nonProxyHosts, protocol.
        Specified by:
        getProxySettings in interface MavenConfiguration
        Parameters:
        protocols - protocols to be recognized.
        Returns:
        the active proxy settings
      • setSettings

        public void setSettings​(org.apache.maven.settings.Settings settings)
      • getPid

        public String getPid()
        Description copied from interface: MavenConfiguration
        Returns PID for properties used by this configuration. It's used as prefix for properties in associated PropertyResolver
        Specified by:
        getPid in interface MavenConfiguration
        Returns:
      • contains

        public boolean contains​(String propertyName)
        Returns true if the the property was set.
        Parameters:
        propertyName - name of the property
        Returns:
        true if property is set
      • set

        public <T> T set​(String propertyName,
                         T propertyValue)
        Sets a property.
        Parameters:
        propertyName - name of the property to set
        propertyValue - value of the property to set
        Returns:
        the value of property set (fluent api)
      • get

        public <T> T get​(String propertyName)
        Returns the property by name.
        Parameters:
        propertyName - name of the property
        Returns:
        property value