All Projects → jaredsburrows → Gradle License Plugin

jaredsburrows / Gradle License Plugin

Licence: apache-2.0
Gradle plugin that provides a task to generate a HTML license report of your project.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

Projects that are alternatives of or similar to Gradle License Plugin

Comcast.github.io
The main Open Source portal for Comcast
Stars: ✭ 36 (-85.37%)
Mutual labels:  source, open, open-source
Randomix
🎲 An open source app to choose randomly between numbers, answers, options and so on.
Stars: ✭ 24 (-90.24%)
Mutual labels:  source, open
Apskaita5
Open source accounting system designed for Lithuania
Stars: ✭ 20 (-91.87%)
Mutual labels:  source, open
Opentomb
An open-source Tomb Raider 1-5 engine remake
Stars: ✭ 1,035 (+320.73%)
Mutual labels:  source, open
Openrgb
Open source RGB lighting control that doesn't depend on manufacturer software. Supports Windows, Linux, MacOS. Issue tracker is on GitLab: https://gitlab.com/CalcProgrammer1/OpenRGB
Stars: ✭ 464 (+88.62%)
Mutual labels:  source, open
Laravel Open Source Projects
A Web Artisan list of categorized OPEN SOURCE PROJECTS built with Laravel PHP Framework.
Stars: ✭ 676 (+174.8%)
Mutual labels:  open, open-source
Sneakerbot
Stars: ✭ 33 (-86.59%)
Mutual labels:  source, open
vly1
v1 Voluntarily application - deprecated
Stars: ✭ 14 (-94.31%)
Mutual labels:  open, source
Montreal
A directory of companies, people, and projects that are Open Source and from Montréal.
Stars: ✭ 77 (-68.7%)
Mutual labels:  source, open
Openwallet Android
The first truly free, libre, and open source light wallet for multiple cryptocurrencies (Bitcoin, Ethereum, Ripple, etc).
Stars: ✭ 86 (-65.04%)
Mutual labels:  source, open
Joustmania
Raspberry Pi Jousting at its finest
Stars: ✭ 91 (-63.01%)
Mutual labels:  source, open
Gradle Static Analysis Plugin
Easy setup of static analysis tools for Android and Java projects.
Stars: ✭ 398 (+61.79%)
Mutual labels:  gradle, open-source
Gradle Android Command Plugin
Handy commands for testing Android on CI
Stars: ✭ 349 (+41.87%)
Mutual labels:  gradle, open-source
Vancouver
Open Source People, Projects, and Companies in Vancouver
Stars: ✭ 23 (-90.65%)
Mutual labels:  source, open
reverse-enginnering
open source repository
Stars: ✭ 29 (-88.21%)
Mutual labels:  open, source
Copyright Header
© Copyright Header is a utility to manipulate software licenses on source code.
Stars: ✭ 168 (-31.71%)
Mutual labels:  open-source, license
open-source-flash
Petition to open source Flash and Shockwave spec
Stars: ✭ 7,380 (+2900%)
Mutual labels:  open, source
vlsi-release-plugins
A set of plugins to simplify Gradle release tasks
Stars: ✭ 30 (-87.8%)
Mutual labels:  gradle, license
Webuild
📝 Robot-handpicked list of open events and open source for designers, developers and makers in Singapore
Stars: ✭ 62 (-74.8%)
Mutual labels:  open, open-source
Gradle Build Properties Plugin
Keep your secrets secret. External build properties support for your Gradle scripts.
Stars: ✭ 110 (-55.28%)
Mutual labels:  gradle, open-source

Gradle License Plugin

License Build 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 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

Release:

buildscript {
  repositories {
    jcenter()
    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 JFrog Bintray repository.

Snapshot:

buildscript {
  repositories {
    maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' }
    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 JFrog Artifactory repository.

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 {
  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 &copy; 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 &copy; 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 &copy; 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 licence 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.

Configuration

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:

  • Java projects: Generate HTML, JSON and CSV reports.
  • Android projects: Generate HTML, JSON and CSV reports, and copy the HTML report to the assets directory.

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.

Usage

Create an open source dialog

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();
  }
}

How to use it

new OpenSourceLicensesDialog().showLicenses(fragmentTransaction, "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/

License

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].