Skip to content

Commit

Permalink
Merge branch 'release/4.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
chrimaeon committed Apr 3, 2022
2 parents 6554711 + 4333a4d commit de2c3e2
Show file tree
Hide file tree
Showing 33 changed files with 928 additions and 384 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"

- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
target-branch: "develop"
16 changes: 11 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,28 @@

### Security

## [4.3.0]
## [4.4.0]
### Added
- [SPDX License Identifier](https://spdx.org/licenses/) for various reports

### Changed
- add maven coordinates to Library model
- `version` is not part of the `mavenCoordinates` in the Library model
- Improved Markdown reporter
- HTML and Markdown reports merge licenses with a more sophisticated algorithm

### Deprecated

### Removed

### Fixed
- CSV Reporter reports all licenses not only the first one

### Security

## [4.3.0]
### Changed
- add maven coordinates to Library model
- `version` is not part of the `mavenCoordinates` in the Library model
- Improved Markdown reporter

## [4.2.0]
### Added
- XSD Schema for the XML reporter
Expand Down Expand Up @@ -69,4 +75,4 @@
## [3.1.0]
### Changed
- All public properties are now provided Properties
- Use Kotlin Serialization instead of Moshi
- Use Kotlin Serialization instead of Moshi
96 changes: 85 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,69 @@ This Gradle plugin provides tasks to generate a file with the licenses used from

## Usage

Using the plugins DSL
### Integration

```groovy
#### Using the plugins DSL

<details open="open">
<summary>Kotlin</summary>

```kotlin
plugins {
id "com.cmgapps.licenses" version "4.3.0"
id("com.cmgapps.licenses") version "4.4.0"
}
```
</details>

Using legacy plugin application
<details>
<summary>Groovy</summary>

```groovy
plugins {
id 'com.cmgapps.licenses' version '4.4.0'
}
```
</details>

#### Using legacy plugin application

<details open="open">
<summary>Kotlin</summary>

```kotlin
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.cmgapps:gradle-licenses-plugin:4.4.0")
}
}

apply(plugin = "com.cmgapps.licenses")
```
</details>

<details>
<summary>Groovy</summary>

```groovy
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath("com.cmgapps:gradle-licenses-plugin:4.3.0")
classpath 'com.cmgapps:gradle-licenses-plugin:4.4.0'
}
}
apply(plugin: "com.cmgapps.licenses")
apply plugin: 'com.cmgapps.licenses'
```
</details>

### Tasks

Expand Down Expand Up @@ -91,7 +131,7 @@ The plugin can output different formats.
}
```
* `JSON`
generates a Json file
generates a JSON file
* `XML`
generates a valid XML version 1.0 file
* `Text`
Expand All @@ -100,24 +140,58 @@ The plugin can output different formats.
generates a Markdown file
* `Custom`
add your own reporter as a lambda function
```groovy

<details open="open">
<summary>Kotlin</summary>

```kotlin
licenses {
custom {
enabled.set(true)
generate = { list -> list.collect { it.name }.join(', ') }
enabled = true
destination = buildDir.resolve("reports").resolve("licenses.txt")
generate { list -> list.map { it.name }.joinToString() }
}
}
```
</details>

<details>
<summary>Groovy</summary>

```groovy
licenses {
custom {
enabled = true
destination = file("$buildDir/reports/licenses/licenses.txt")
generate { list -> list.collect { it.name }.join(', ') }
}
}
```
</details>

#### Multi-project Builds

For multi-project build, you can add projects you want to collect license information from in the main project.

<details open="open">
<summary>Kotlin</summary>

```kotlin
licenses {
additionalProjects(":module2", ":module3")
}
```
</details>

<details>
<summary>Groovy</summary>

```groovy
licenses {
additionalProjects ':module2', ':module3'
}
```
</details>

## License

Expand Down
23 changes: 13 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
id("org.jetbrains.dokka") version Deps.Plugins.dokkaVersion
kotlin("plugin.serialization") version Deps.kotlinVersion
id("org.jetbrains.changelog") version Deps.Plugins.changelogPluginVersion
id("org.jetbrains.kotlinx.kover") version "0.4.4"
id("org.jetbrains.kotlinx.kover") version Deps.Plugins.koverVersion
}

repositories {
Expand Down Expand Up @@ -184,22 +184,27 @@ tasks {

register<JavaExec>("ktlintFormat") {
group = "Verification"
description = "Check Kotlin code style."
description = "Format Kotlin code style."
mainClass.set("com.pinterest.ktlint.Main")
classpath = ktlint
args = listOf("src/**/*.kt", "--format", "--reporter=plain", "--reporter=checkstyle,output=$buildDir/reports/ktlint.xml")
args = listOf(
"src/**/*.kt",
"--format",
)
}

val ktlint by registering(JavaExec::class) {
group = "Verification"
description = "Check Kotlin code style."
mainClass.set("com.pinterest.ktlint.Main")
classpath = ktlint
args = listOf("src/**/*.kt", "--reporter=plain", "--reporter=checkstyle,output=$buildDir/reports/ktlint.xml")
args = listOf(
"src/**/*.kt",
"--reporter=plain",
"--reporter=checkstyle,output=$buildDir/reports/ktlint.xml",
)
}



check {
dependsOn(functionalTest, ktlint)
}
Expand Down Expand Up @@ -250,7 +255,7 @@ tasks {

wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "7.3.3"
gradleVersion = "7.4.2"
}

val updateReadme by registering {
Expand All @@ -262,7 +267,7 @@ tasks {

doLast {
val content = readmeFile.readText()
val oldVersion = """id "com.cmgapps.licenses" version "(.*)"""".toRegex().find(content)?.let {
val oldVersion = """id\("com.cmgapps.licenses"\) version "(.*)"""".toRegex(RegexOption.MULTILINE).find(content)?.let {
it.groupValues[1]
} ?: error("Cannot find oldVersion")

Expand Down Expand Up @@ -307,15 +312,13 @@ dependencies {
testImplementation(Deps.jUnit) {
exclude(group = "org.hamcrest")
}
testImplementation(Deps.androidGradlePlugin)
testImplementation(Deps.hamcrest)
testImplementation(kotlinReflect)
testImplementation(Deps.mockitoKotlin)

"functionalTestImplementation"(Deps.jUnit) {
exclude(group = "org.hamcrest")
}
"functionalTestImplementation"(Deps.androidGradlePlugin)
"functionalTestImplementation"(Deps.kotlinMultiplatformPlugin)
"functionalTestImplementation"(Deps.hamcrest)
"functionalTestImplementation"(gradleTestKit())
Expand Down
13 changes: 7 additions & 6 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
*/

object Deps {
const val kotlinVersion = "1.6.10"
const val kotlinVersion = "1.6.20"

object Plugins {
const val dokkaVersion = "1.6.10"
const val changelogPluginVersion = "1.3.1"
const val pluginPublishVersion = "0.19.0"
const val versionsVersion = "0.40.0"
const val pluginPublishVersion = "0.21.0"
const val versionsVersion = "0.42.0"
const val koverVersion = "0.5.0"
}

const val androidGradlePlugin = "com.android.tools.build:gradle:7.1.2"
const val kotlinMultiplatformPlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
const val apacheCommonsCsv = "org.apache.commons:commons-csv:1.9.0"
const val mavenModel = "org.apache.maven:maven-model:3.8.4"
const val mavenArtifact = "org.apache.maven:maven-artifact:3.8.4"
const val mavenModel = "org.apache.maven:maven-model:3.8.5"
const val mavenArtifact = "org.apache.maven:maven-artifact:3.8.5"
const val jUnit = "org.junit.jupiter:junit-jupiter:5.8.2"
const val hamcrest = "org.hamcrest:hamcrest:2.2"
const val ktlint = "com.pinterest:ktlint:0.43.2"
const val ktlint = "com.pinterest:ktlint:0.45.1"
const val kotlinSerialization = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2"
const val mockitoKotlin = "org.mockito.kotlin:mockito-kotlin:4.0.0"
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 3 additions & 13 deletions pom.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
#
# Copyright (c) 2019. Christian Grach <christian.grach@cmgapps.com>
#
# 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.
# SPDX-License-Identifier: Apache-2.0
#
group=com.cmgapps
versionName=4.3.0
versionName=4.4.0
pomName=Gradle Licenses Plugin
pomArtifactId=gradle-licenses-plugin
pomDescription=Gradle plugin that provides a task to generate a license report of your project.
pomDescription=Gradle plugin that provides a task to generate a license report for the dependencies used in your project Java/Kotlin project.
connectionUrl=scm:git:git://github.com:chrimaeon/gradle-licenses-plugin.git
developerConnectionUrl=scm:git:git://github.com:chrimaeon/gradle-licenses-plugin.git
scmUrl=https://github.com/chrimaeon/gradle-licenses-plugin.git
Expand Down
8 changes: 6 additions & 2 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/sh

# ln -s -f ../../scripts/pre-commit .git/hooks/pre-commit

set -e

command -v ktlint >/dev/null 2>&1 || { echo >&2 "ktlint not found.\nAborting."; exit 2; }

FILES=$(git diff --cached --name-only | grep -i -E "\.kts?" || true)

if [ -n "$FILES" ]
then
ktlint "$FILES"
ktlint $FILES
else
echo "No file for ktlint"
fi

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.hamcrest.Matchers.`is`
import org.hamcrest.Matchers.matchesPattern
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable
import org.junit.jupiter.api.io.TempDir
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
Expand Down Expand Up @@ -60,7 +59,6 @@ class LicensePluginJavaShould {
.withPluginClasspath()
}

@DisabledIfEnvironmentVariable(named = "CIRCLECI", matches = "true")
@ParameterizedTest(name = "{displayName} - Gradle Version={0}")
@ValueSource(strings = ["6.8", "6.9", "7.0", "7.1", "7.2", "7.3", "7.4"])
fun `apply Licenses plugin to various Gradle versions`(version: String) {
Expand Down
Loading

0 comments on commit de2c3e2

Please sign in to comment.