LoginSignup
2
1

More than 5 years have passed since last update.

(メモ)Gradleの力を借りて依存するライブラリのjarを一式取得する

Posted at

いろいろな理由()でGradleを使ってプロジェクトがビルドできないときに、予めGradleを用いて依存ライブラリ一式をまるっと手に入れる方法。

適当なJavaのGradleプロジェクトを作成してdependenciesとtaskを書くだけです。

サンプルはJasperReportsと専用のiText(とそれらが依存するライブラリ)を指定しています。

build.gradle
plugins {
    id 'java'
}

sourceCompatibility = 1.8

repositories {
    mavenCentral artifactUrls: [
        'http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/'
    ]
}

configurations {
    // プロジェクトをビルドすることはないので、依存していることだけを示すconfiguration
    dependentLib
}

dependencies {
    dependentLib 'net.sf.jasperreports:jasperreports:6.6.0'
    dependentLib 'com.lowagie:itext:2.1.7.js6'
}

// 依存ライブラリーをコピーするtask
task ('copyLib', type: Copy) {
    from configurations.dependentLib
    into 'build/lib'
}

あとはgradlew copyLibでjar一式が得られます。

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