如何在Tycho maven插件中使用代理?

时间:2017-04-26 10:14:22

标签: maven maven-plugin tycho kura

我正试图从公司防火墙后面构建Eclipse Kura项目。

当我尝试构建kura / examples / org.eclipse.kura.example.camel.aggregation(mvn clean install)时,它结束于:

Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'eclipse.kura' from location http://packagedrone.eclipse.org/p2/eclipse-kura-2.1
(...)
Caused by: java.lang.RuntimeException: Failed to load p2 repository with ID 'eclipse.kura' from location http://packagedrone.eclipse.org/p2/eclipse-kura-2.1
    at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.loadMetadataRepository(TargetPlatformFactoryImpl.java:296)
(...)
Caused by: java.net.SocketTimeoutException: Read timed out

我尝试设置代理:

               <plugin>
                        <groupId>org.eclipse.tycho</groupId>
                        <artifactId>tycho-maven-plugin</artifactId>
                        <version>${tycho-version}</version>
                        <extensions>true</extensions>
                        <configuration>
                                <argLine>-Dhttp.proxyHost=my-proxy-web -Dhttp.proxyPort=3128</argLine>
                        </configuration>
                </plugin>

但它没有用。 Kura项目使用的是tycho-maven-plugin的v0.20.0,我试图升级到1.0.0,但它没有用。

当我在浏览器中设置相同的代理时,我可以访问&#34; http://packagedrone.eclipse.org/p2/eclipse-kura-2.1&#34;

更新: 我已经在maven settings.xml中定义了我的代理,它可以在各种存储库中查找依赖项,但是Tycho maven插件没有考虑到这一点:

  <proxies>
    <proxy>
      <id>main-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>my-proxy-web</host>
      <port>3128</port>
      <nonProxyHosts>*.mycomp.fr</nonProxyHosts>
    </proxy>
  </proxies>

更新2:

使用-X和-s settings.xml运行时的

maven调试日志:

[DEBUG] Clearing proxy settings in OSGi runtime

(这是唯一提到&#34;代理&#34;对应Tycho插件源,没有&#34;配置代理&#34;没有&#34;忽略代理&#34;,它&#39 ; s似乎没有&#34;活跃&#34;代理已被发现)

[INFO] Computing target platform for MavenProject: org.eclipse.kura:org.eclipse.kura.example.camel.aggregation:1.1.0 @ /home/tristan/Dev/projects/IOT/kura.git/kura/examples/org.eclipse.kura.example.camel.aggregation/pom.xml
[DEBUG] Added p2 repository eclipse.kura (http://packagedrone.eclipse.org/p2/eclipse-kura-2.1)
[DEBUG] Using execution environment 'JavaSE-1.7' configured in Bundle-RequiredExecutionEnvironment
[DEBUG] Registered artifact repository org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey(uri=file:/resolution-context-artifacts@/home/tristan/Dev/projects/IOT/kura.git/kura/examples/org.eclipse.kura.example.camel.aggregation)
[INFO] Adding repository http://packagedrone.eclipse.org/p2/eclipse-kura-2.1
[WARNING] Failed to access p2 repository http://packagedrone.eclipse.org/p2/eclipse-kura-2.1, use local cache.
org.eclipse.equinox.p2.core.ProvisionException: Unable to read repository at http://packagedrone.eclipse.org/p2/eclipse-kura-2.1/content.xml.
(...)
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to packagedrone.eclipse.org:80 timed out

更新3: 我的错误&#34;更新2&#34;,我已经用如此多的设置完成了很多测试,我在这个测试中使用了错误的文件。

以下是正确设置代理的输出(仍然失败):

mvn clean install -X -s good-settings-with-proxy.xml

[DEBUG] Clearing proxy settings in OSGi runtime
[DEBUG] Configuring proxy for protocol http: host=10.91.31.45, port=3128

!ENTRY org.eclipse.core.net 1 0 2017-04-28 18:02:58.106
!MESSAGE System property http.proxyHost is not set but should be 10.91.31.45.

!ENTRY org.eclipse.core.net 1 0 2017-04-28 18:02:58.106
!MESSAGE System property http.proxyPort is not set but should be 3128.

如果我明确设置了警告中提到的系统属性:

mvn clean install -X -Dhttp.proxyHost=10.91.31.45 -Dhttp.proxyPort=3128 -s /home/tristan/CODE/apache-maven-3.2.3/conf/settings.with-proxy.xml

!ENTRY org.eclipse.core.net 1 0 2017-04-28 18:02:58.079
!MESSAGE System property http.proxyHost has been set to 10.91.31.45 by an external source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.net 1 0 2017-04-28 18:02:58.079
!MESSAGE System property http.proxyPort has been set to 3128 by an external source. This value will be overwritten using the values from the preferences
[DEBUG] Clearing proxy settings in OSGi runtime
[DEBUG] Configuring proxy for protocol http: host=10.91.31.45, port=3128, nonProxyHosts=*.edf.fr

!ENTRY org.eclipse.core.net 1 0 2017-04-28 18:02:58.106
!MESSAGE System property http.proxyHost is not set but should be 10.91.31.45.

!ENTRY org.eclipse.core.net 1 0 2017-04-28 18:02:58.106
!MESSAGE System property http.proxyPort is not set but should be 3128.

2 个答案:

答案 0 :(得分:0)

khmarbaise是对的,你应该在maven的settings.xml中配置代理

maven调试日志(mvn clean install -X)应该为您提供

的输出

https://github.com/eclipse/tycho/blob/f42e43c5722c0f74e55c5c03259476ac8b6f8836/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/OSGiProxyConfigurator.java#L65

如果没有,则出于某种原因不考虑您的代理设置

要在HTTP客户端级别进一步调试,请使用apache HTTP客户端跟踪,请参阅 https://wiki.eclipse.org/Equinox/p2/Reporting_Problems - &gt;报告网络连接问题

仔细检查的另一个先决条件是你的构建是否真的没有代理和一个干净的本地maven仓库。

答案 1 :(得分:0)

Tycho从settings.xml派生其配置,您将需要在Maven的settings.xml中同时提供具有不同ID的http和https代理元素(以避免在Tycho配置文件中重叠)。

<proxies>
  <proxy>
    <id>123</id>
    <active>true</active>
    <protocol>https</protocol>
    <host>my-proxy-web</host>
    <port>3128</port>
    <nonProxyHosts>*.mycomp.fr</nonProxyHosts>
  </proxy>
  <proxy>
    <id>321</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>my-proxy-web</host>
    <port>3128</port>
    <nonProxyHosts>*.mycomp.fr</nonProxyHosts>
  </proxy>
</proxies>