在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jaredsburrows/gradle-license-plugin开源软件地址(OpenSource Url):https://github.com/jaredsburrows/gradle-license-plugin开源编程语言(OpenSource Language):Groovy 71.2%开源软件介绍(OpenSource Introduction):Gradle License PluginThis plugin provides a task to generate a HTML license report based on the
configuration. (eg. Applying this to an Android or Java project will generate the license
file( Also, for Android projects the license HTML file will be copied to DownloadRelease: with plugins { }plugins {
id("com.jaredsburrows.license") version "0.9.0"
} with buildscript { }buildscript {
repositories {
mavenCentral()
google() // For Android projects
}
dependencies {
classpath 'com.jaredsburrows:gradle-license-plugin:0.9.0'
}
}
apply plugin: 'com.android.application' // or 'java-library'
apply plugin: 'com.jaredsburrows.license' Release versions are available in the Sonatype's release repository. Snapshot: with plugins { }plugins {
id("com.jaredsburrows.license") version "0.9.1-SNAPSHOT"
} with buildscript { }buildscript {
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
google() // For Android projects
}
dependencies {
classpath 'com.jaredsburrows:gradle-license-plugin:0.9.1-SNAPSHOT'
}
}
apply plugin: 'com.android.application' // or 'java-library'
apply plugin: 'com.jaredsburrows.license' Snapshot versions are available in the Sonatype's snapshots repository. Tasks
Generates a HTML report of the all open source licenses. (eg. Example 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
} Example Outputs:CSV Example (full):
HTML Example (license descriptions are minimized):<html>
<head>
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; 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 Example (full):[
{
"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 Text Example (full):
ConfigurationThe 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 apply plugin: "com.jaredsburrows.license"
licenseReport {
generateCsvReport = false
generateHtmlReport = true
generateJsonReport = false
generateTextReport = false
// These options are ignored for Java projects
copyCsvReportToAssets = false
copyHtmlReportToAssets = true
copyJsonReportToAssets = false
copyTextReportToAssets = false
useVariantSpecificAssetDirs = false
} The The Usage ExampleCreate an open source dialogKotlinimport android.app.Dialog
import android.os.Bundle
import android.webkit.WebView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
class OpenSourceLicensesDialog : DialogFragment() {
fun showLicenses(activity: AppCompatActivity) {
val fragmentManager = activity.getSupportFragmentManager()
val fragmentTransaction = fragmentManager.beginTransaction()
val previousFragment = fragmentManager.findFragmentByTag("dialog_licenses")
if (previousFragment != null) {
fragmentTransaction.remove(previousFragment)
}
fragmentTransaction.addToBackStack(null)
show(fragmentManager, "dialog_licenses")
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val webView = WebView(requireActivity())
webView.loadUrl("file:///android_asset/open_source_licenses.html")
return Builder(requireActivity())
.setTitle("Open Source Licenses")
.setView(webView)
.setPositiveButton("OK",
DialogInterface.OnClickListener { dialog: DialogInterface, which: Int -> dialog.dismiss() })
.create()
}
} Javaimport android.app.Dialog;
import android.os.Bundle;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
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 void showLicenses(AppCompatActivity activity) {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment previousFragment = fragmentManager.findFragmentByTag("dialog_licenses");
if (previousFragment != null) {
fragmentTransaction.remove(previousFragment);
}
fragmentTransaction.addToBackStack(null);
show(fragmentManager, "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("OK", (dialog, which) -> dialog.dismiss())
.create();
}
} How to use itKotlinOpenSourceLicensesDialog().showLicenses(this) Javanew OpenSourceLicensesDialog().showLicenses(this); Source: https://www.bignerdranch.com/blog/open-source-licenses-and-android/ License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论