From 55507b3f35dbde5776e6c2360845254871dcd0ef Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 6 Jan 2021 17:34:24 +0100 Subject: [PATCH] Add license check --- build-plugins/build.gradle | 3 +- .../cloudogu/scm/IntegrationTestPlugin.groovy | 2 +- .../com/cloudogu/scm/JavaModulePlugin.groovy | 40 +++++++++++++++++++ build.gradle | 10 ++--- scm-packaging/deb/build.gradle | 19 +++++++++ scm-packaging/docker/build.gradle | 20 +++++++++- scm-packaging/helm/build.gradle | 24 +++++++++++ scm-packaging/release-yaml/build.gradle | 16 ++++++++ scm-packaging/rpm/build.gradle | 19 +++++++++ scm-packaging/unix/build.gradle | 20 ++++++++++ scm-packaging/windows/build.gradle | 19 +++++++++ scm-ui/build.gradle | 36 ++++++++++++++++- 12 files changed, 218 insertions(+), 10 deletions(-) diff --git a/build-plugins/build.gradle b/build-plugins/build.gradle index 0df72a977b..0e74929379 100644 --- a/build-plugins/build.gradle +++ b/build-plugins/build.gradle @@ -33,7 +33,8 @@ apply from: file( '../gradle/dependencies.gradle' ) dependencies { implementation gradleApi() implementation 'com.github.node-gradle:gradle-node-plugin:2.2.4' - + implementation 'gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.15.0' + implementation libraries.guava implementation libraries.jettyServer implementation libraries.jettyWebapp diff --git a/build-plugins/src/main/groovy/com/cloudogu/scm/IntegrationTestPlugin.groovy b/build-plugins/src/main/groovy/com/cloudogu/scm/IntegrationTestPlugin.groovy index ac8fb8fb78..32fcc94986 100644 --- a/build-plugins/src/main/groovy/com/cloudogu/scm/IntegrationTestPlugin.groovy +++ b/build-plugins/src/main/groovy/com/cloudogu/scm/IntegrationTestPlugin.groovy @@ -30,7 +30,7 @@ import org.gradle.api.Project class IntegrationTestPlugin implements Plugin { - void apply(Project project) { + void apply(Project project) { def extension = project.extensions.create("scmServer", ScmServerExtension, project) project.tasks.register('write-server-config', WriteServerConfigTask) { diff --git a/build-plugins/src/main/groovy/com/cloudogu/scm/JavaModulePlugin.groovy b/build-plugins/src/main/groovy/com/cloudogu/scm/JavaModulePlugin.groovy index e427266868..9e3c339c76 100644 --- a/build-plugins/src/main/groovy/com/cloudogu/scm/JavaModulePlugin.groovy +++ b/build-plugins/src/main/groovy/com/cloudogu/scm/JavaModulePlugin.groovy @@ -23,6 +23,7 @@ */ package com.cloudogu.scm +import com.hierynomus.gradle.license.tasks.LicenseCheck import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.jvm.toolchain.JavaLanguageVersion @@ -30,6 +31,8 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion class JavaModulePlugin implements Plugin { void apply(Project project) { + project.plugins.apply("com.github.hierynomus.license") + project.afterEvaluate { project.java { toolchain { @@ -40,6 +43,43 @@ class JavaModulePlugin implements Plugin { options.release = 8 } } + + project.license { + header project.rootProject.file('LICENSE.txt') + strictCheck true + + mapping { + tsx = 'SLASHSTAR_STYLE' + ts = 'SLASHSTAR_STYLE' + java = 'SLASHSTAR_STYLE' + gradle = 'SLASHSTAR_STYLE' + } + + exclude "**/*.mustache" + exclude "**/*.json" + exclude "**/*.ini" + exclude "**/mockito-extensions/*" + exclude "**/*.txt" + exclude "**/*.md" + exclude "**/*.gz" + exclude "**/*.zip" + exclude "**/*.smp" + exclude "**/*.asc" + exclude "**/*.png" + exclude "**/*.jpg" + exclude "**/*.gif" + exclude "**/*.dump" + } + + project.tasks.register("licenseBuild", LicenseCheck) { + source = project.fileTree(dir: ".").include("build.gradle", "settings.gradle", "gradle.properties") + enabled = true + } + + project.tasks.getByName("license").configure { + dependsOn("licenseBuild") + enabled = true + } } } diff --git a/build.gradle b/build.gradle index 9ae4cdd8d2..ca6650a967 100644 --- a/build.gradle +++ b/build.gradle @@ -32,11 +32,11 @@ subprojects { url 'https://packages.scm-manager.org/repository/public/' } } - - apply from: rootProject.file( 'gradle/dependencies.gradle' ) } -apply from: rootProject.file( 'gradle/dependencies.gradle' ) +allprojects { + apply from: rootProject.file('gradle/dependencies.gradle') +} dependencies { constraints { @@ -129,11 +129,11 @@ project.ext { if (buildNumber != null) { snapshotVersion += "-${buildNumber}" } - dockerTag = version.replace('SNAPSHOT', snapshotVersion) + dockerTag = version.replace('SNAPSHOT', snapshotVersion) } else { expandedVersion = project.version expandedVersionWithDot = project.version dockerRepository = 'docker.io/scmmanager/scm-manager' - dockerTag = version.replace('SNAPSHOT', snapshotVersion) + dockerTag = version.replace('SNAPSHOT', snapshotVersion) } } diff --git a/scm-packaging/deb/build.gradle b/scm-packaging/deb/build.gradle index 62b7d03aa3..b95ad62468 100644 --- a/scm-packaging/deb/build.gradle +++ b/scm-packaging/deb/build.gradle @@ -26,6 +26,7 @@ import org.gradle.util.VersionNumber plugins { id 'nebula.ospackage' version '8.4.1' id 'org.scm-manager.packaging' + id 'com.github.hierynomus.license-base' version '0.15.0' } configurations { @@ -159,3 +160,21 @@ artifacts { builtBy distribution } } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + exclude '**/build/**' + include '**/src/**' + include 'build.gradle' + include 'Vagrantfile' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-packaging/docker/build.gradle b/scm-packaging/docker/build.gradle index 82649734cf..3ae3724a8e 100644 --- a/scm-packaging/docker/build.gradle +++ b/scm-packaging/docker/build.gradle @@ -25,12 +25,12 @@ plugins { id 'com.bmuschko.docker-remote-api' version '6.6.1' id 'org.scm-manager.packaging' + id 'com.github.hierynomus.license-base' version '0.15.0' } import org.gradle.util.VersionNumber import com.bmuschko.gradle.docker.tasks.image.* - configurations { server webapp @@ -102,3 +102,21 @@ artifacts { builtBy distribution } } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + exclude '**/build/**' + include '**/src/**' + include 'build.gradle' + include 'Dockerfile' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-packaging/helm/build.gradle b/scm-packaging/helm/build.gradle index 8a3e7cbe25..01b2b627c4 100644 --- a/scm-packaging/helm/build.gradle +++ b/scm-packaging/helm/build.gradle @@ -25,6 +25,7 @@ plugins { id 'org.unbroken-dome.helm' version '1.4.0' id 'org.scm-manager.packaging' + id 'com.github.hierynomus.license-base' version '0.15.0' } configurations { @@ -70,3 +71,26 @@ artifacts { builtBy distribution } } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + // TODO + // we get a strange build error with the license header, + // so we remove it for now + exclude '**/Chart.yaml' + + exclude '**/build/**' + exclude '**/*.txt' + include '**/src/**' + include 'build.gradle' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-packaging/release-yaml/build.gradle b/scm-packaging/release-yaml/build.gradle index 14c8f90258..352e433bfd 100644 --- a/scm-packaging/release-yaml/build.gradle +++ b/scm-packaging/release-yaml/build.gradle @@ -24,6 +24,7 @@ plugins { id 'org.scm-manager.packaging' + id 'com.github.hierynomus.license-base' version '0.15.0' } configurations { @@ -44,3 +45,18 @@ dependencies { task distribution(type: ReleaseYaml) { configuration = configurations.packageYaml } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + include 'build.gradle' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-packaging/rpm/build.gradle b/scm-packaging/rpm/build.gradle index 799c1f87d3..45e8b6848e 100644 --- a/scm-packaging/rpm/build.gradle +++ b/scm-packaging/rpm/build.gradle @@ -48,6 +48,7 @@ buildscript { plugins { id 'nebula.ospackage' version '8.4.1' id 'org.scm-manager.packaging' + id 'com.github.hierynomus.license-base' version '0.15.0' } configurations { @@ -178,3 +179,21 @@ artifacts { builtBy distribution } } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + exclude '**/build/**' + include '**/src/**' + include 'build.gradle' + include 'Vagrantfile' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-packaging/unix/build.gradle b/scm-packaging/unix/build.gradle index 89b6031156..2a5ea0683f 100644 --- a/scm-packaging/unix/build.gradle +++ b/scm-packaging/unix/build.gradle @@ -26,6 +26,7 @@ import org.gradle.util.VersionNumber plugins { id 'org.scm-manager.packaging' id 'signing' + id 'com.github.hierynomus.license-base' version '0.15.0' } configurations { @@ -107,3 +108,22 @@ artifacts { signing { sign configurations.unixPkg } + + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + exclude '**/build/**' + exclude '**/*.txt' + include '**/src/**' + include 'build.gradle' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-packaging/windows/build.gradle b/scm-packaging/windows/build.gradle index 25b965bdf7..23c2f36e79 100644 --- a/scm-packaging/windows/build.gradle +++ b/scm-packaging/windows/build.gradle @@ -27,6 +27,7 @@ plugins { id "de.undercouch.download" version "4.1.1" id 'org.scm-manager.packaging' id 'signing' + id 'com.github.hierynomus.license-base' version '0.15.0' } configurations { @@ -111,3 +112,21 @@ artifacts { signing { sign configurations.windowsPkg } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + gradle = 'SLASHSTAR_STYLE' + } + + exclude '**/build/**' + exclude '**/*.txt' + include '**/src/**' + include 'build.gradle' +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +} diff --git a/scm-ui/build.gradle b/scm-ui/build.gradle index b8f6b80607..632d4af5a7 100644 --- a/scm-ui/build.gradle +++ b/scm-ui/build.gradle @@ -4,7 +4,7 @@ * Copyright (c) 2020-present Cloudogu GmbH and Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the 'Software'), to deal + * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is @@ -13,7 +13,7 @@ * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER @@ -22,8 +22,10 @@ * SOFTWARE. */ + plugins { id 'com.github.node-gradle.node' version '2.2.4' + id 'com.github.hierynomus.license-base' version '0.15.0' } node { @@ -134,3 +136,33 @@ task setVersion(type: YarnTask) { args = ['run', 'set-version', project.version] dependsOn('yarn_install') } + +license { + header rootProject.file("LICENSE.txt") + strictCheck true + + mapping { + tsx = 'SLASHSTAR_STYLE' + ts = 'SLASHSTAR_STYLE' + gradle = 'SLASHSTAR_STYLE' + } + + exclude '**/node_modules/**' + exclude '**/build/**' + exclude '**/.gradle/**' + exclude '**/*.json' + exclude '**/*.jpg' + exclude '**/*.png' + exclude '**/*.gif' + exclude '**/*.svg' + exclude '**/*.ico' + exclude '**/*.md' + exclude '**/*.mustache' + exclude '**/*.snap' + exclude '**/*.iml' + +} + +task license(type: com.hierynomus.gradle.license.tasks.LicenseCheck) { + source = fileTree('.') +}