LoginSignup
4
3

More than 5 years have passed since last update.

buildshipで使うデフォルトのJAVA_HOMEを指定

Posted at

詰まったのでメモ

問題

  • インストール済みのJava
    • jre 10.0.2 (Windows x64)
    • jdk 10.0.2 (Windows x64)
  • eclipse: Photon Release (4.8.0) 20180619-1200
    • PleiadesのJRE無し版
  • buildship: 2.2.1.v20180125-1441
  • gradle: 4.9

これでEclipseのGradleタスクビューからcompileJavaしようとすると、JREの方を使ってしまいコンパイルができない。

作業ディレクトリー: C:\~~
Gradle ユーザー・ホーム: C:\Users\~\.gradle
Gradle ディストリビューション: ターゲット・ビルドからの Gradle ラッパー
Gradle バージョン: 4.9
Java ホーム: C:\Program Files\Java\jre-10.0.2
JVM 引数: なし
プログラムの引数: なし
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle タスク: :compileJava

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 0s
1 actionable task: 1 executed

一応Eclipseの実行の構成からJavaホームを指定すればできるが、プロジェクトごと・タスクごとに設定する必要があり面倒くさい。
設定をプロジェクト内のgradle.propertiesに書くこともできるが、リポジトリがローカルのパスで汚染されてしまうのでやりたくない。

EclipseのGradleの設定で何をもとにJAVA_HOMEを決めるか設定できるらしい。

しかしなぜか知らないがその設定がない(STSの方のGradleを使っていた時はあった気もするが)。

image.png

ここではGradleはインストールせずgradlewだけで運用したいので断念。


gradlewを使う際のJREを指定するには次のようにする。

~/.gradle/gradle.properties
org.gradle.java.home=C:\\Program Files\\Java\\jdk-10.0.2

修正箇所がユーザーホームに飛び火し普通にgradlewするときもこちらが参照されてしまうが、EclipseからしかGradleを使う予定はないのでとりあえずこれで妥協。

4
3
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
3