This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
eclipse { | |
pathVariables 'GRADLE_USER_HOME': gradle.gradleUserHomeDir | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'commons-lang:commons-lang:2.6' | |
} |
この例では、クラスパス変数GRADLE_USER_HOMEにgradleのユーザホームディレクトリを指定している(5行目)。
eclipseタスクを実行後に、Eclipse上でプロジェクトを更新すると、クラスパス変数がEclipseに反映される。Eclipseで作成したJavaプロジェクトでは、eclipseタスク実行後にJDKへの参照が重複して登録されることがあったので、事前にcleanEclipseタスクを実行しておくのが無難。
Mavenリポジトリなどを使って依存関係を解決している場合、上記のようにクラスパス変数を指定しておくと、Eclipseの.classpathファイルにユーザディレクトリの絶対パスが記述されるのを防ぐことができる。
0 件のコメント:
コメントを投稿