こんにちは。
gradleのプラグインをGitHubから拾ってきて自分の環境で使おうとしたときエラーが出たので解決方法をメモ。
環境
Ubuntu 18.04
Gradle 4.4.1
社内プロキシ環境下で作業を行いました
問題
GitHubで公開されているこのgradleプラグインをローカル環境でビルドしたときに以下のエラーが出ました。
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.ajoberstar:grgit:2.0.0.
Required by:
project :
> Could not resolve org.ajoberstar:grgit:2.0.0.
> Could not get resource 'https://repo.maven.apache.org/maven2/org/ajoberstar/grgit/2.0.0/grgit-2.0.0.pom'.
> Could not GET 'https://repo.maven.apache.org/maven2/org/ajoberstar/grgit/2.0.0/grgit-2.0.0.pom'.
> repo.maven.apache.org: 名前またはサービスが不明です
> Could not resolve org.ajoberstar:grgit:2.0.0.
> Could not get resource 'https://jcenter.bintray.com/org/ajoberstar/grgit/2.0.0/grgit-2.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/org/ajoberstar/grgit/2.0.0/grgit-2.0.0.pom'.
> jcenter.bintray.com: 名前またはサービスが不明です
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
エラー内容
repo.maven.apache.orgとかjcenter.bintray.comが不明ですって言われてそんなわけないだろと。
これは適切に名前解決ができていないので、プロキシの設定が漏れていそうだなと。
解決方法
~/.gradle/gradle.propertiesファイルに以下を追記します。
~/.gradle/gradle.propertiesがない場合は作ってください。
systemProp.http.proxyHost=プロキシのホスト名
systemProp.http.proxyPort=プロキシのポート番号
systemProp.http.proxyUser=プロキシ認証のユーザー名
systemProp.http.proxyPassword=プロキシ認証のパスワード
systemProp.http.nonProxyHosts=localhost
systemProp.https.proxyHost=プロキシのホスト名
systemProp.https.proxyPort=プロキシのポート番号
systemProp.https.proxyUser=プロキシ認証のユーザー名
systemProp.https.proxyPassword=プロキシ認証のパスワード
systemProp.https.nonProxyHosts=localhost
これでビルドが無事通るようになりました。
まとめ
プロキシめんどくさい。
おわり。