どうすればいいんだーって感じで意外に詰まったのでメモ。
参考
gradleでdependenciesのライセンス一覧を出力する - Olivinecafe - blog
手順
build.gradleの設定
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' } // License
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1"
}
}
apply plugin: 'com.android.application'
apply plugin: "com.github.hierynomus.license" // License
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.woshidan.recyclerviewclick"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
}
downloadLicenses {
ext.apacheTwo = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0')
ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php')
includeProjectDependencies = true
licenses = [
'org.apache.james:apache-mime4j:0.6' : apacheTwo,
'org.some-bsd:project:1.0' : bsd
]
aliases = [
(apacheTwo) : ['The Apache Software License, Version 2.0', 'Apache 2', 'Apache License Version 2.0', 'Apache License, Version 2.0', 'Apache License 2.0', license('Apache License', 'http://www.apache.org/licenses/LICENSE-2.0')],
(bsd) : ['BSD', license('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php')]
]
dependencyConfiguration = 'compile'
}
タスク downloadLicensesの実行
右側のGradleのタブを開いて、other以下のdownloadLicensesのタスクを実行します。

できあがり
下記のディレクトリに、dependency-license.xml, dependency-license.html, license-dependency.xml, license-dependency.htmlが生成されます。
用途に合わせて利用しましょう。

<!-- dependency-license.xml --> <dependencies> <dependency name='com.google.code.gson:gson:2.3.1'> <file>gson-2.3.1.jar</file> <license name='Apache License, Version 2.0' url='http://opensource.org/licenses/Apache-2.0' /> </dependency> <dependency name='com.android.support:support-v4:23.1.0'> <file>support-v4-23.1.0.aar</file> <license name='No license found' /> </dependency> <dependency name='com.squareup.retrofit:retrofit:1.9.0'> <file>retrofit-1.9.0.jar</file> <license name='Apache 2.0' url='http://www.apache.org/licenses/LICENSE-2.0.txt' /> </dependency> <dependency name='com.nineoldandroids:library:2.4.0'> <file>library-2.4.0.jar</file> <license name='Apache License, Version 2.0' url='http://opensource.org/licenses/Apache-2.0' /> </dependency> <dependency name='com.android.support:appcompat-v7:23.1.0'> <file>appcompat-v7-23.1.0.aar</file> <license name='No license found' /> </dependency> <dependency name='com.melnykov:floatingactionbutton:1.3.0'> <file>floatingactionbutton-1.3.0.aar</file> <license name='The MIT License (MIT)' url='https://github.com/makovkastar/FloatingActionButton/blob/master/LICENSE.MD' /> </dependency> <dependency name='com.android.support:recyclerview-v7:21.0.3'> <file>recyclerview-v7-21.0.3.aar</file> <license name='No license found' /> </dependency> <dependency name='com.android.support:support-annotations:23.1.0'> <file>support-annotations-23.1.0.jar</file> <license name='No license found' /> </dependency> </dependencies>
<!-- license-dependency.xml --> <licenses> <license name='Apache 2.0' url='http://www.apache.org/licenses/LICENSE-2.0.txt'> <dependency>retrofit-1.9.0.jar</dependency> </license> <license name='The MIT License (MIT)' url='https://github.com/makovkastar/FloatingActionButton/blob/master/LICENSE.MD'> <dependency>floatingactionbutton-1.3.0.aar</dependency> </license> <license name='No license found'> <dependency>support-annotations-23.1.0.jar</dependency> <dependency>support-v4-23.1.0.aar</dependency> <dependency>appcompat-v7-23.1.0.aar</dependency> <dependency>recyclerview-v7-21.0.3.aar</dependency> </license> <license name='Apache License, Version 2.0' url='http://opensource.org/licenses/Apache-2.0'> <dependency>gson-2.3.1.jar</dependency> <dependency>library-2.4.0.jar</dependency> </license> </licenses>
Copyright表記が欲しい場合やライセンス情報が見つからなかった場合
これらのライブラリは何々ライセンスで、何何ライセンスは以下よ、みたいなライセンス表示をしているアプリもありますが、ライセンス表示をするならCopyrightかきたいですよね。
でも、ライブラリのメタデータにライブラリの名前は入っていてもAuthorは入ってないとか、そもそも上記のスクリプトでライセンス情報が取れない場合があります。
仕方が無いので、上記のもの以上が必要な場合は、xmlを手がかりに手動で各ライブラリのGithubリポジトリ等に取りにいっています。
欲しい情報が pom.xml に載っている場合は、こちらのissueによると、下記の部分を参考に取得できるそうです。