This plugin provides a task to generate a HTML license report based on theconfiguration. (eg. licenseDebugReport
for all debug dependencies in an Android project).
Applying this to an Android or Java project will generate the licensefile(open_source_licenses.html
) in the <project>/build/reports/licenses/
.
Also, for Android projects the license HTML file will be copied to <project>/src/main/assets/
.
Release:
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.jaredsburrows:gradle-license-plugin:0.8.90'
}
}
apply plugin: 'com.android.application' // or 'java-library'
apply plugin: 'com.jaredsburrows.license'
Release versions are available in the Sonatype's release repository.
Snapshot:
buildscript {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
google()
}
dependencies {
classpath 'com.jaredsburrows:gradle-license-plugin:0.8.91-SNAPSHOT'
}
}
apply plugin: 'com.android.application' // or 'java-library'
apply plugin: 'com.jaredsburrows.license'
Snapshot versions are available in the Sonatype's snapshots repository.
license${variant}Report
for AndroidlicenseReport
for JavaGenerates a HTML report of the all open source licenses. (eg. licenseDebugReport
for all debug dependencies in an Android project).
Example build.gradle
:
dependencies {
implementation 'com.android.support:design:26.1.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
implementation 'wsdl4j:wsdl4j:1.5.1' // Very old library with no license info available
}
CSV (minimized example):
project,description,version,developers,url,year,licenses,license urls,dependency
Design,null,26.1.0,null,null,null,The Apache Software License,http://www.apache.org/licenses/LICENSE-2.0.txt,com.android.support:design:26.1.0
HTML (minimized example):
<html>
<head>
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; display: inline-block }</style>
<title>Open source licenses</title>
</head>
<body>
<h3>Notice for packages:</h3>
<ul>
<li>
<a href="#0">WSDL4J (1.5.1)</a>
<dl>
<dt>Copyright © 20xx The original author or authors</dt>
</dl>
</li>
<a name="0"></a>
<pre>No license found</pre>
<br>
<hr>
<li><a href="#1783810846">Android GIF Drawable Library (1.2.3)</a>
<dl>
<dt>Copyright © 20xx Karol Wrótniak</dt>
</dl>
</li>
<a name="1783810846"></a>
<pre>mit.txt here</pre>
<br>
<hr>
<li><a href="#1934118923">Design (26.1.0)</a>
<dl>
<dt>Copyright © 20xx The original author or authors</dt>
</dl>
</li>
<a name="1934118923"></a>
<pre>apache-2.0.txt here</pre>
<br>
<hr>
</ul>
</body>
</html>
Note, if no license information is found in the POM for a project, "No License Found" will be used.Those will be listed first.Other missing information is provided as default values that can be corrected from other sources.Projects are grouped by license name and the license text is only provided once.Projects with multiple licenses are grouped as if those licenses were a single combined license.
JSON (full example):
[
{
"project": "Android GIF Drawable Library",
"description": "Views and Drawable for displaying animated GIFs for Android",
"version": "1.2.3",
"developers": [
"Karol Wrótniak"
],
"url": "https://github.com/koral--/android-gif-drawable",
"year": null,
"licenses": [
{
"license": "The MIT License",
"license_url": "http://opensource.org/licenses/MIT"
}
],
"dependency": "pl.droidsonroids.gif:android-gif-drawable:1.2.3"
},
{
"project": "Design",
"description": null,
"version": "26.1.0",
"developers": [],
"url": null,
"year": null,
"licenses": [
{
"license": "The Apache Software License",
"license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
],
"dependency": "com.android.support:design:26.1.0"
},
{
"project": "WSDL4J",
"description": "Java stub generator for WSDL",
"version": "1.5.1",
"developers": [],
"url": "http://sf.net/projects/wsdl4j",
"year": null,
"licenses": [],
"dependency": "wsdl4j:wsdl4j:1.5.1"
}
]
Note, if no license information is found for a component, the licenses
element in the JSON output will be an empty array.
The plugin can be configured to generate specific reports and automatically copy the reports to the assets directory (Android projects only). The default behaviours are:
To override the defaults, add the licenseReport
configuration closure to the build script.
apply plugin: "com.jaredsburrows.license"
licenseReport {
generateCsvReport = false
generateHtmlReport = false
generateJsonReport = true
// These options are ignored for Java projects
copyHtmlReportToAssets = false
copyHtmlReportToAssets = true
copyJsonReportToAssets = false
}
The copyHtmlReportToAssets
option in the above example would have no effect since the HTML report is disabled.
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
public final class OpenSourceLicensesDialog extends DialogFragment {
public OpenSourceLicensesDialog() {
}
public static void showLicenses(Activity activity) {
FragmentManager fragmentManager = activity.getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment previousFragment = fragmentManager.findFragmentByTag("dialog_licenses");
if (previousFragment != null) {
fragmentTransaction.remove(previousFragment);
}
fragmentTransaction.addToBackStack(null);
show(fragmentTransaction, "dialog_licenses");
}
@Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
WebView webView = new WebView(requireActivity());
webView.loadUrl("file:///android_asset/open_source_licenses.html");
return new AlertDialog.Builder(requireActivity())
.setTitle("Open Source Licenses")
.setView(webView)
.setPositiveButton(R.string.ok, (dialog, which) -> dialog.dismiss())
.create();
}
}
new OpenSourceLicensesDialog().showLicenses(fragmentTransaction, "dialog_licenses");
Source: https://www.bignerdranch.com/blog/open-source-licenses-and-android/
Copyright (C) 2016 Jared Burrows
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
gradle-android-javadoc-plugin Gradle plugin that generates Java Documentation from an Android Gradle project. Set up app/build.gradle or library/build.gradle buildscript { repositories { mavenCentral(
android { ...... buildTypes { debug { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } r
这是一个使用gradle上传到Jcenter的一个示例 具体步骤 这里写的已经非常明白了 并且提供了多个示例 https://github.com/bintray/gradle-bintray-plugin 本文源码 上传到jcenter至少需要四个文件,除了打包的jar之外, 还需要pom和javadoc,source,否则是通不过jcenter审核的。 下面是博客引文 有时你或许会想发布自己的
Adapt — remix, transform and build upon the material for any purpose, even commercially. Under the following terms: Attribution — You must give appropriate credit, provide a link to the license, and i
描述: 标识你的代码采用何种软件许可协议。 语法 @license <identifier> 概述 @license标签标识你的代码采用何种软件许可协议。 你可以用任何文本来明确您所使用的许可证。如果您的代码使用一个标准的开源许可,考虑使用 Software Package Data Exchange (SPDX)许可列表中合适的标识符。 一些JavaScript处理工具,如谷歌的 Closure
这是一个 Maven 的插件,该插件管理Maven项目的许可证及其依赖项(更新文件头,下载依赖项许可证,检查第三方许可证等)。 如 LICENSE.TXT 和 THIRD-PARTY.TXT。
License key is validated in an offline mode. No connection is made to any server. Starting with version 7.0.0, we require you to pass the license key in the Settings object in each instance of Handson
介绍 Github 官方专门制作了一个网站choosealicense帮助大家选择合适的开源License。 MIT 最自由,简直就是没有任何限制,任何人都可以售卖我的软件,甚至可以用我的名字促销。 BSD 和 Apache 协议也很自由,跟 MIT 的区别分别是不允许用作者本人名义促销和保护作者版权。 GPL 可以说最霸道,对代码的修改部分也必须是 GPL 的,同时基于 GPL 代码而开发的代码
smart-license 是一款用于安全加固的开源项目。主要服务于非开源产品、商业软件、具备试用功能的付费软件等,为软件提供授权制的使用方式。 适用场景: 非开源产品、商业软件、收费软件。 限制产品的传播性,每个客户拥有专属 License。 同一款软件发行包根据 License 的不同提供不同的服务能力。 限定软件授权时效 License运行流程 License申请流程 找回License 使