import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.jboss.shrinkwrap.resolver.api.maven.MavenResolverSystem;

MavenResolverSystem resolver = Maven.configureResolver()
    .fromFile("/path/to/test-settings.xml");

Use this resolver for subsequent resolve operations. Constructing it and then calling another default resolver leaves the setting on the unused object. An Arquillian test can create this repository session after Maven has already started the test process, so an earlier command-line download does not establish its inputs.

The selected file uses Maven settings syntax. Inside settings, a minimal route is:

<proxies>
  <proxy>
    <id>test-network</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>proxy.example.net</host>
    <port>8080</port>
    <nonProxyHosts>localhost|*.internal.example.net</nonProxyHosts>
  </proxy>
</proxies>

Replace the path, endpoint and intended bypasses. The host has no URL prefix. If this test resolver is allowed to reach a public repository through an unauthenticated public intermediary, the HTTP proxy list supplies candidate host/port values; check access to the actual repository. Supply proxy authentication through supported settings; repository/server accounts authenticate a different service.

The maintained implementation loads active proxy entries from the settings model into the repository session's selector. Defaults also consider user/global settings locations; an explicit file helps when an IDE, build agent or test runner has another home directory.

Verify the settings path, repository URL and whether the artifact actually needed downloading. A warmed repository can hide a missing route. The resolver obtains deployment artifacts; an HTTP client exercised by the test makes another request and needs its own configuration. For Maven Surefire tests whose HTTP client honors JVM proxy properties, configure the test JVM’s proxy inputs.

Ũhoro ũhĩtĩte