4
6

More than 5 years have passed since last update.

Eclipse で Gradle のプロキシ設定

Last updated at Posted at 2017-12-20

何を解決するか?

Eclipse の標準プラグイン「buildship」を使って Gradele プロジェクトをビルドしようとしたところ、社内プロキシの接続設定が必要でしたので、そのことについて書きます。

環境

  • Eclipse 4.7 Oxygen (pleiades 4.7)
  • gradle 4.4 (buildship)
  • Windows 10
  • インターネット接続は社内プロキシ経由(認証あり)

解決方法

gradlew.bat と同じディレクトリに gradele.propeties を作成して、プロキシを設定します。

gradele.propeties
# HTTPプロキシ設定
systemProp.http.proxyHost=<プロキシサーバ名>
systemProp.http.proxyPort=<ポート番号>
systemProp.http.proxyUser=<ユーザー名>
systemProp.http.proxyPassword=<パスワード>
systemProp.http.nonProxyHosts=<プロキシを適用しないアドレス 例)123.564.*, localhost>

# HTTPSプロキシ設定
systemProp.https.proxyHost=<プロキシサーバ名>
systemProp.https.proxyPort=<ポート番号>
systemProp.https.proxyUser=<ユーザー名>
systemProp.https.proxyPassword=<パスワード>
systemProp.https.nonProxyHosts=<プロキシを適用しないアドレス 例)123.564.*, localhost>

確認方法

コマンドプロンプトから gradlew.bat をオプションを付けて実行します。

> gradlew --scan build

プロキシを原因とするエラーの場合、jcenter などの外部リポジトリへ接続できないため、 UnknownHostException が出力されると思います。

Caused by: java.net.UnknownHostException: jcenter.bintray.com
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
        at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
        at java.net.InetAddress.getAllByName(InetAddress.java:1192)
        at java.net.InetAddress.getAllByName(InetAddress.java:1126)
(省略)
        ... 62 more
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
1 actionable task: 1 executed

きちんと設定できれば、上のコマンドが成功しますし、Eclipse から build タスクを実行しても正常に完了するようになります。これで解決しない場合、別の理由で外部リポジトリへの接続に失敗していることが考えられますので、別途、そちらを確認してください。

以上です。

4
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6