mirror of https://github.com/apache/maven.git
[MNG-7454] Include resolver-transport-http in Maven (#711)
But keep Wagon as default transport. This PR merely includes resolver http and file transport and switches wagon-http to non-shaded one. Changes: * switch to non-shaded wagon-http (as httpClient is now shared) * include resolver http and file transport * override resolver default behaviour (native transport preferred over wagon, when both on classpath) * provide simplistic means to choose transport The chosen transport can be seen in debug (-X) output on line `[DEBUG] Using transporter XXX...` The `-Dmaven.transport` simplistic switch can be used to choose transport: * not set: default, that is Wagon * `wagon`: explicitly sets Wagon * `resolver`: explicitly sets resolver native transports (file and http) * `auto`: relies on resolver "auto discovery" (priorities, etc). This is MUST to keep transport pluggable with 3rd party transports. In fact, this was the default so far in Maven, along with the fact that native resolver transports were not included (as resolver prefers native ones over Wagon).
This commit is contained in:
parent
c99028b9fb
commit
be2b7f890d
|
@ -63,21 +63,10 @@ under the License.
|
|||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http</artifactId>
|
||||
<classifier>shaded</classifier>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http-shared</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -86,12 +75,16 @@ under the License.
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-connector-basic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-connector-basic</artifactId>
|
||||
<artifactId>maven-resolver-transport-file</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
|
|
|
@ -78,6 +78,22 @@ import org.slf4j.LoggerFactory;
|
|||
@Named
|
||||
public class DefaultRepositorySystemSessionFactory
|
||||
{
|
||||
private static final String MAVEN_TRANSPORT_KEY = "maven.transport";
|
||||
|
||||
private static final String MAVEN_TRANSPORT_WAGON = "wagon";
|
||||
|
||||
private static final String MAVEN_TRANSPORT_RESOLVER = "resolver";
|
||||
|
||||
private static final String MAVEN_TRANSPORT_AUTO = "auto";
|
||||
|
||||
private static final String WAGON_TRANSPORTER_KEY_PRIORITY_KEY = "aether.priority.WagonTransporterFactory";
|
||||
|
||||
private static final String RESOLVER_HTTP_TRANSPORTER_PRIORITY_KEY = "aether.priority.HttpTransporterFactory";
|
||||
|
||||
private static final String RESOLVER_FILE_TRANSPORTER_PRIORITY_KEY = "aether.priority.FileTransporterFactory";
|
||||
|
||||
private static final String RESOLVER_MAX_PRIORITY = String.valueOf( Float.MAX_VALUE );
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
private final ArtifactHandlerManager artifactHandlerManager;
|
||||
|
@ -245,6 +261,25 @@ public class DefaultRepositorySystemSessionFactory
|
|||
}
|
||||
session.setAuthenticationSelector( authSelector );
|
||||
|
||||
String transport = request.getUserProperties().getProperty( MAVEN_TRANSPORT_KEY, MAVEN_TRANSPORT_WAGON );
|
||||
if ( MAVEN_TRANSPORT_RESOLVER.equals( transport ) )
|
||||
{
|
||||
// Make sure (whatever extra priority is set) that resolver native is selected
|
||||
configProps.put( RESOLVER_FILE_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY );
|
||||
configProps.put( RESOLVER_HTTP_TRANSPORTER_PRIORITY_KEY, RESOLVER_MAX_PRIORITY );
|
||||
}
|
||||
else if ( MAVEN_TRANSPORT_WAGON.equals( transport ) )
|
||||
{
|
||||
// Make sure (whatever extra priority is set) that wagon is selected
|
||||
configProps.put( WAGON_TRANSPORTER_KEY_PRIORITY_KEY, RESOLVER_MAX_PRIORITY );
|
||||
}
|
||||
else if ( !MAVEN_TRANSPORT_AUTO.equals( transport ) )
|
||||
{
|
||||
throw new IllegalArgumentException( "Unknown maven.transport=" + transport
|
||||
+ ". Supported ones are: " + MAVEN_TRANSPORT_WAGON + ", "
|
||||
+ MAVEN_TRANSPORT_RESOLVER + " and " + MAVEN_TRANSPORT_AUTO );
|
||||
}
|
||||
|
||||
session.setTransferListener( request.getTransferListener() );
|
||||
|
||||
session.setRepositoryListener( eventSpyDispatcher.chainListener( new LoggingRepositoryListener( logger ) ) );
|
||||
|
|
|
@ -117,12 +117,12 @@ under the License.
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-wagon</artifactId>
|
||||
<artifactId>maven-resolver-transport-file</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-http</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -65,7 +65,7 @@ under the License.
|
|||
<cipherVersion>2.0</cipherVersion>
|
||||
<modelloVersion>2.0.0</modelloVersion>
|
||||
<jxpathVersion>1.3</jxpathVersion>
|
||||
<resolverVersion>1.7.2</resolverVersion>
|
||||
<resolverVersion>1.7.3</resolverVersion>
|
||||
<slf4jVersion>1.7.32</slf4jVersion>
|
||||
<xmlunitVersion>2.6.4</xmlunitVersion>
|
||||
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
|
||||
|
@ -340,7 +340,6 @@ under the License.
|
|||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http</artifactId>
|
||||
<version>${wagonVersion}</version>
|
||||
<classifier>shaded</classifier>
|
||||
</dependency>
|
||||
<!-- Repository -->
|
||||
<dependency>
|
||||
|
@ -368,6 +367,16 @@ under the License.
|
|||
<artifactId>maven-resolver-connector-basic</artifactId>
|
||||
<version>${resolverVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-file</artifactId>
|
||||
<version>${resolverVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-http</artifactId>
|
||||
<version>${resolverVersion}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.resolver</groupId>
|
||||
<artifactId>maven-resolver-transport-wagon</artifactId>
|
||||
|
|
Loading…
Reference in New Issue