You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Thomas Meyer (JIRA)" <ji...@apache.org> on 2016/01/25 16:30:39 UTC
[jira] [Commented] (MCHECKSTYLE-316) Maven proxy settings is being
ignored
[ https://issues.apache.org/jira/browse/MCHECKSTYLE-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15115396#comment-15115396 ]
Thomas Meyer commented on MCHECKSTYLE-316:
------------------------------------------
okay, I think the correct thing would be to use a configured proxy in the URLResourceLoader (part of plexus-resources) and use
u.openConnection(proxy).getInputStream();
instead of
u.openStream();
but for this the proxy from the MavenSession should be injected into the URLResourceLoader object, but I know too few plexus object model on how to do that, if it's possible at all.
I check how other maven plugins (from the maven-plugins github project does solve this) and found this in the maven-plugins\maven-doap-plugin\src\main\java\org\apache\maven\plugin\doap\DoapUtil.java which is a maybe a good template for apache http client usage:
if ( settings != null && settings.getActiveProxy() != null )
{
Proxy activeProxy = settings.getActiveProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setNonProxyHosts( activeProxy.getNonProxyHosts() );
if ( StringUtils.isNotEmpty( activeProxy.getHost() )
&& !ProxyUtils.validateNonProxyHosts( proxyInfo, url.getHost() ) )
{
httpClient.getHostConfiguration().setProxy( activeProxy.getHost(), activeProxy.getPort() );
if ( StringUtils.isNotEmpty( activeProxy.getUsername() ) && activeProxy.getPassword() != null )
{
Credentials credentials =
new UsernamePasswordCredentials( activeProxy.getUsername(), activeProxy.getPassword() );
httpClient.getState().setProxyCredentials( AuthScope.ANY, credentials );
}
}
}
another interesting solution is contained in this plugin maven-plugins\maven-jarsigner-plugin\src\main\java\org\apache\maven\plugins\jarsigner\AbstractJarsignerMojo.java which seems to append some java system property switches to set the proxy.
> Maven proxy settings is being ignored
> -------------------------------------
>
> Key: MCHECKSTYLE-316
> URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-316
> Project: Maven Checkstyle Plugin
> Issue Type: Bug
> Components: checkstyle:check
> Affects Versions: 2.16
> Environment: Windows 7
> Reporter: Thomas Meyer
>
> Hi,
> having a suppression location of https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/suppressions.xml results in a call to
> DefaultCheckstyleExecutor.getSuppressionsFilePath():797
> which will try a resource lookup via DefaultResourceManager.getResourceAsFile() which will call URLResourceLoader.getResource()
> this will timeout and result in a ConnectionException.
> But in the underlying maven session a HTTP proxy is defined, but not used here.
> The DefaultBuildPluginManager.executeMojo() has the proxy information available in the MavenSession (session) as part of the request (DefaultMavenExecutionRequest) -> proxies
> So a fix would be to apply those configured proxies somehow to the checkstyle plugin, but I'm not sure who this is done best.
> Complete stack trace:
> Thread [main] (Suspended (exception ConnectException))
> owns: DualStackPlainSocketImpl (id=47)
> owns: HttpsClient (id=48)
> owns: DelegateHttpsURLConnection (id=49)
> owns: HttpsURLConnectionImpl (id=50)
> DualStackPlainSocketImpl.connect0(int, InetAddress, int) line: not available [native method]
> DualStackPlainSocketImpl.socketConnect(InetAddress, int, int) line: 79
> DualStackPlainSocketImpl(AbstractPlainSocketImpl).doConnect(InetAddress, int, int) line: 345
> DualStackPlainSocketImpl(AbstractPlainSocketImpl).connectToAddress(InetAddress, int, int) line: 206
> DualStackPlainSocketImpl(AbstractPlainSocketImpl).connect(SocketAddress, int) line: 188
> SocksSocketImpl(PlainSocketImpl).connect(SocketAddress, int) line: 172
> SocksSocketImpl.connect(SocketAddress, int) line: 392
> SSLSocketImpl(Socket).connect(SocketAddress, int) line: 589
> SSLSocketImpl.connect(SocketAddress, int) line: 656
> SSLSocketImpl(BaseSSLSocketImpl).connect(SocketAddress) line: 173
> HttpsClient(NetworkClient).doConnect(String, int) line: 180
> HttpsClient(HttpClient).openServer(String, int) line: 432
> HttpsClient(HttpClient).openServer() line: 527
> HttpsClient.<init>(SSLSocketFactory, URL, Proxy, int) line: 275
> HttpsClient.New(SSLSocketFactory, URL, HostnameVerifier, Proxy, boolean, int, HttpURLConnection) line: 371
> DelegateHttpsURLConnection(AbstractDelegateHttpsURLConnection).getNewHttpClient(URL, Proxy, int) line: 191
> DelegateHttpsURLConnection(HttpURLConnection).plainConnect0() line: 1104
> DelegateHttpsURLConnection(HttpURLConnection).plainConnect() line: 998 [local variables unavailable]
> DelegateHttpsURLConnection(AbstractDelegateHttpsURLConnection).connect() line: 177
> DelegateHttpsURLConnection(HttpURLConnection).getInputStream0() line: 1512
> DelegateHttpsURLConnection(HttpURLConnection).getInputStream() line: 1440
> HttpsURLConnectionImpl.getInputStream() line: 254 [local variables unavailable]
> URL.openStream() line: 1038 [local variables unavailable]
> URLResourceLoader.getResource(String) line: 73
> DefaultResourceManager.getResource(String) line: 159
> DefaultResourceManager.getResourceAsFile(String, String) line: 91
> DefaultCheckstyleExecutor.getSuppressionsFilePath(CheckstyleExecutorRequest) line: 797
> DefaultCheckstyleExecutor.executeCheckstyle(CheckstyleExecutorRequest) line: 117
> CheckstyleViolationCheckMojo.execute() line: 538
> DefaultBuildPluginManager.executeMojo(MavenSession, MojoExecution) line: 132
> MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex, DependencyContext) line: 208
> MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex, DependencyContext, PhaseRecorder) line: 153
> MojoExecutor.execute(MavenSession, List<MojoExecution>, ProjectIndex) line: 145
> LifecycleModuleBuilder.buildProject(MavenSession, MavenSession, ReactorContext, MavenProject, TaskSegment) line: 116
> LifecycleModuleBuilder.buildProject(MavenSession, ReactorContext, MavenProject, TaskSegment) line: 80
> SingleThreadedBuilder.build(MavenSession, ReactorContext, ProjectBuildList, List<TaskSegment>, ReactorBuildStatus) line: 51
> LifecycleStarter.execute(MavenSession) line: 120
> DefaultMaven.doExecute(MavenExecutionRequest) line: 347
> DefaultMaven.execute(MavenExecutionRequest) line: 154
> MavenCli.execute(MavenCli$CliRequest) line: 582
> MavenCli.doMain(MavenCli$CliRequest) line: 214
> MavenCli.main(String[], ClassWorld) line: 158
> NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
> NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> Method.invoke(Object, Object...) line: 497
> Launcher.launchEnhanced(String[]) line: 289
> Launcher.launch(String[]) line: 229
> Launcher.mainWithExitCode(String[]) line: 415
> Launcher.main(String[]) line: 356
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)