LoginSignup
3
2

More than 3 years have passed since last update.

Eclipse Buildship プラグインでGradleの実行時オプションを指定する方法

Last updated at Posted at 2019-09-10

Eclipse Buildshipとは

Eclipse Buildship is a collection of Eclipse plug-ins that provide support for building software using Gradle.
https://projects.eclipse.org/projects/tools.buildship

とあるように、GradleをEclipse上で扱うためのプラグインです。

Installの有無は、Eclipse上からは help> About Eclipse IDE から確認できます。

下図は Eclipse Buildship Version 3.1.1 がインストールされている様子です。
Eclipse Buildship version.png

やりたいこと

Buildship経由のgradleタスク実行時にオプションを追加したい。CLIでいうとgradle build -x test ただ、それだけです。ただそれだけがEclipseのBuildshp経由できず、なんだかモヤモヤしつつも諦めてCLIコマンドをいつも叩いていましたが、回避方法がわかったので備忘に残しておきました。

環境

Eclipse: Version: 2018-12 (4.10.0)
Buidship: 3.1.1

実現方法

Gradle Tasks > にタスクを設定します。

image.png

次に、Project Settings で、Override project settings にチェックを入れ、Program Arguments-x, testという2つの引数を追加します。

image.png

これだけです。これだけで gradle build -x test と同等のビルドが実行できます。
簡単なんですがここまでに中々至らず、諦めてターミナルからいつもコマンドを打っていました。

NGケース1

以下のようにGradle tasksに build -x test と横着して書いても上手く認識してくれません。

image.png

FAILURE: Build failed with an exception.

* What went wrong:
Task 'build -x test' not found in root project 'buildship-example'.

NGケース2

同様に、Program Argumentsに -x test とワンラインで書いても上手く認識してくれません。

image.png

FAILURE: Build failed with an exception.

* What went wrong:
Task ' test' not found in root project 'buildship-example'. Some candidates are: 'test'.

なんとなくワンラインで書きたくなりますが、いい感じに認識はしてくれませんのでご注意ください。

まとめ

  • EclipseとBuildshipでGradleビルドしている方がどれほどいらっしゃるかは不明ですが、やむえない理由で同じ用にハマった人の助けになれば幸いです
  • Eclipseとかの設定手順を説明するのに、キャプチャをペタペタ貼って手順書を書くのは6,7年ぶりで懐かしい感覚になりました
3
2
0

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