Gradleで外部依存関係を指定する方法は、具体的には以下の通り。
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' | |
dependencies { compile 'commons-lang:commons-lang:2.6' } | |
repositories { | |
// Maven central repository | |
mavenCentral() | |
// local repository | |
mavenLocal() | |
// remote repository | |
maven { url 'http://repo.example.com/maven' } | |
// local repository | |
maven { url 'file:///c:/repo/maven' } | |
} |
上記の例では、dependenciesプロパティ(5行目)で外部依存関係を指定している。compileはjava pluginで定義されているconfigurationでコンパイル時および実行時に必要な外部モジュールを指す。
外部モジュールは、‘group:name:version’という書式で指定する。group, name, versionはそれぞれMavenのgroupId, artifactId, version(これらの詳細は、Maven - Guide to Naming Conventionsを参照)に相当する。
外部依存関係として指定された外部モジュールは、reositoriesプロパティに定義したリポジトリから検索される。リポジトリについては、『dev-xconnecting: GradleでMavenリポジトリを使う』を参照のこと。
関連リンク
- Gradle本家ユーザガイド
- Gradle User Guide
- 7.2.2. External dependenciesから必要(または理解度)に応じてリンクをたどっていくとよい
- Gradle User Guide
0 件のコメント:
コメントを投稿