Giter Site home page Giter Site logo

sdtm1016 / gradle-license-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaredsburrows/gradle-license-plugin

0.0 3.0 0.0 179 KB

This plugin provides a task to generate a HTML license report of your project.

License: Apache License 2.0

Shell 1.24% Groovy 98.76%

gradle-license-plugin's Introduction

Gradle License Plugin

License Build Status Coverage Status Twitter Follow

This plugin provides a task to generate a HTML license report based on the configuration. (eg. licenseDebugReport for all debug dependencies in an Android project).

Applying this to an Android or Java project will generate a the license file(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/.

Download

Gradle:

repositories {
  jcenter()
}
  
compile "com.jaredsburrows:gradle-license-plugin:0.4.0"

Snapshot versions are available in the JFrog Artifactory repository: https://oss.jfrog.org/webapp/#/builds/gradle-license-plugin

Tasks

  • license${variant}Report for Android
  • licenseReport for Java

Generates a HTML report of the all open source licenses. (eg. licenseDebugReport for all debug dependencies in an Android project).

Example build.gradle:

dependencies {
  compile "com.android.support:design:25.1.0"
  compile "pl.droidsonroids.gif:android-gif-drawable:1.2.3"
}

HTML:

<html>
  <head>
    <style>body{font-family:sans-serif;}pre{background-color:#eee;padding:1em;white-space:pre-wrap;}</style>
    <title>Open source licenses</title>
  </head>
  <body>
    <h3>Notice for libraries:</h3>
    <ul>
      <li>
        <a href='#-989311426'>Android GIF Drawable Library</a>
      </li>
      <li>
        <a href='#1288288048'>Design</a>
      </li>
    </ul>
    <a name='-989311426' />
    <h3>The MIT License</h3>
    <pre>The MIT License, http://opensource.org/licenses/MIT</pre>
    <a name='1288288048' />
    <h3>The Apache Software License</h3>
    <pre>The Apache Software License, http://www.apache.org/licenses/LICENSE-2.0.txt</pre>
  </body>
</html>

JSON:

[
    {
        "project": "Android GIF Drawable Library",
        "developers": "Karol Wr\u00c3\u00b3tniak",
        "url": "https://github.com/koral--/android-gif-drawable.git",
        "year": null,
        "license": "The MIT License",
        "license_url": "http://opensource.org/licenses/MIT"
    },
    {
        "project": "Design",
        "developers": null,
        "url": null,
        "year": null,
        "license": "The Apache Software License",
        "license_url": "http://www.apache.org/licenses/LICENSE-2.0.txt"
    }
]

Usage

Create an open source dialog

public static class OpenSourceLicensesDialog extends DialogFragment {

  public OpenSourceLicensesDialog() {
  }

  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    final WebView webView = new WebView(getActivity());
    webView.loadUrl("file:///android_asset/open_source_licenses.html");

    return new AlertDialog.Builder(getActivity())
      .setTitle("Open Source Licenses")
      .setView(webView)
      .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
          dialog.dismiss();
        }
      }
    )
    .create();
  }
}

How to use it

public static void showOpenSourceLicenses(Activity activity) {
  final FragmentManager fm = activity.getFragmentManager();
  final FragmentTransaction ft = fm.beginTransaction();
  final Fragment prev = fm.findFragmentByTag("dialog_licenses");
  if (prev != null) {
    ft.remove(prev);
  }
  ft.addToBackStack(null);

  new OpenSourceLicensesDialog().show(ft, "dialog_licenses");
}

Source: https://github.com/google/iosched/blob/2531cbdbe27e5795eb78bf47d27e8c1be494aad4/android/src/main/java/com/google/samples/apps/iosched/util/AboutUtils.java#L52

Source: https://www.bignerdranch.com/blog/open-source-licenses-and-android/

gradle-license-plugin's People

Contributors

jaredsburrows avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.