Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev -> main #1018

Merged
merged 14 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

## Latest releases 🛠

- Kotlin 2.x && Multiplatform && Compose && Plugin | [v11.2.2](https://github.com/mikepenz/AboutLibraries/tree/v11.2.2)
- Kotlin 2.x && Multiplatform && Compose && Plugin | [v11.2.3](https://github.com/mikepenz/AboutLibraries/tree/v11.2.3)

## Gradle Plugin

Expand Down Expand Up @@ -118,7 +118,8 @@ aboutLibraries {
// Full license text for license IDs mentioned here will be included, even if no detected dependency uses them.
additionalLicenses = ["mit", "mpl_2_0"]
// Allows to exclude some fields from the generated meta data field.
excludeFields = ["developers", "funding"]
// If the class name is specified, the field is only excluded for that class; without a class name, the exclusion is global.
excludeFields = ["License.name", "developers", "funding"]
// Enable inclusion of `platform` dependencies in the library report
includePlatform = true
// Define the strict mode, will fail if the project uses licenses not allowed
Expand Down
7 changes: 7 additions & 0 deletions app-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Usage

### Generate Dependency Information

```bash
./gradlew :app-test:exportLibraryDefinitions -PaboutLibraries.exportPath=files/
```
21 changes: 21 additions & 0 deletions app-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
kotlin("multiplatform")
id("com.mikepenz.aboutlibraries.plugin")
}

kotlin {
jvm()

sourceSets {
jvmMain {
dependencies {
// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
implementation("javax.annotation:javax.annotation-api:1.3.2")
}
}
}
}

aboutLibraries {
fetchRemoteLicense = true
}
105 changes: 105 additions & 0 deletions app-test/files/aboutlibraries.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GROUP=com.mikepenz

VERSION_NAME=11.2.2
VERSION_CODE=110202
VERSION_NAME=11.2.3
VERSION_CODE=110203
POM_URL=https://github.com/mikepenz/AboutLibraries
POM_SCM_URL=https://github.com/mikepenz/AboutLibraries
POM_SCM_CONNECTION=scm:git@github.com:mikepenz/AboutLibraries.git
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ compileSdk = "34"
minSdk = "21"
targetSdk = "34"
# build
gradleBuild = "8.5.0"
gradleBuild = "8.5.2"
# kotlin
dokka = "1.9.20"
kotlinCore = { require = "2.0.0" }
kotlinCore = { require = "2.0.20" }
kotlinCoroutines = { require = "1.8.1" }
kotlinxSerialization = "1.6.3"
kotlinxSerialization = "1.7.1"
kotlinxCollections = "0.3.7"
# compose
compose = "1.6.8"
compose-plugin = "1.6.11"
composeUi = "1.6.8" # foundation / material
# androidx
activity = "1.9.0"
activity = "1.9.1"
cardview = "1.0.0"
constraintLayout = "2.1.4"
core = "1.13.1"
lifecycle = { require = "2.8.2" }
lifecycle = { require = "2.8.4" }
navigation = "2.7.7"
recyclerView = "1.3.2"
# google
material = "1.12.0"
# other
accompanist = "0.34.0"
fastAdapter = "5.7.0"
gradleMvnPublish = "0.28.0"
gradleMvnPublish = "0.29.0"
iconics = "5.4.0"
itemAnimators = "1.1.0"
ivy = "2.5.2"
Expand Down
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Binary file modified plugin-build/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion plugin-build/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 4 additions & 1 deletion plugin-build/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions plugin-build/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ abstract class AboutLibrariesExtension {
/**
* Defines fields which will be excluded during the serialisation of the metadata output file.
*
* Any field as included in the [com.mikepenz.aboutlibraries.plugin.mapping.Library] can theoretically be excluded.
* It is possible to qualify the field names by specifying the class name (e.g. "License.name").
* Permissible qualifiers are "ResultContainer", "Library", "Developer", "Organization", "Funding", "Scm",
* "License" and "MetaData".
* Unqualified field names (e.g. "description") are applied to the entire output.
*
* ```
* aboutLibraries {
* excludeFields = arrayOf("description", "tag")
* excludeFields = arrayOf("License.name", "ResultContainer.metadata", "description", "tag")
* }
* ```
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mikepenz.aboutlibraries.plugin.model

import com.mikepenz.aboutlibraries.plugin.mapping.Library
import com.mikepenz.aboutlibraries.plugin.mapping.License
import com.mikepenz.aboutlibraries.plugin.mapping.*
import com.mikepenz.aboutlibraries.plugin.util.PartialObjectConverter
import groovy.json.JsonGenerator
import groovy.json.JsonOutput
import java.io.File
Expand All @@ -26,10 +26,35 @@ class MetaData(
)

fun ResultContainer.writeToDisk(outputFile: File, excludeFields: Array<String>, prettyPrint: Boolean) {
val fieldNames = mutableListOf("artifactId", "groupId", "artifactFolder").also {
it.addAll(excludeFields)
val allowedExclusionQualifiers = setOf(
ResultContainer::class.simpleName,
Library::class.simpleName,
Developer::class.simpleName,
Organization::class.simpleName,
Funding::class.simpleName,
Scm::class.simpleName,
License::class.simpleName,
MetaData::class.simpleName,
)
val excludedQualifiedFieldNames = mutableSetOf(
"${Library::class.simpleName}.${Library::artifactId.name}",
"${Library::class.simpleName}.${Library::groupId.name}",
"${Library::class.simpleName}.${Library::artifactFolder.name}"
)
val excludedUnqualifiedFieldNames = mutableSetOf<String>()
excludeFields.forEach { excludedField ->
val segments = excludedField.split(".")
if (segments.size == 2 && allowedExclusionQualifiers.contains(segments.first())) {
excludedQualifiedFieldNames.add(excludedField)
} else {
excludedUnqualifiedFieldNames.add(excludedField)
}
}
val jsonGenerator = JsonGenerator.Options().excludeNulls().excludeFieldsByName(fieldNames).build()
val jsonGenerator = JsonGenerator.Options()
.excludeNulls()
.excludeFieldsByName(excludedUnqualifiedFieldNames)
.addConverter(PartialObjectConverter(excludedQualifiedFieldNames))
.build()
PrintWriter(OutputStreamWriter(outputFile.outputStream(), StandardCharsets.UTF_8), true).use {
it.write(jsonGenerator.toJson(this).let { json -> if (prettyPrint) JsonOutput.prettyPrint(json) else json })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mikepenz.aboutlibraries.plugin.util

import groovy.json.DefaultJsonGenerator
import groovy.json.JsonGenerator
import org.codehaus.groovy.runtime.DefaultGroovyMethods

/**
* A converter for [JsonGenerator], which allows properties to be excluded from the output.
* The way it works is identical to the serialization of objects in [DefaultJsonGenerator].
* @property excludedQualifiedPropertyNames The qualified name (class name + property name)
* of the properties that should be excluded from serialization.
*/
class PartialObjectConverter(
private val excludedQualifiedPropertyNames: Set<String>,
) : JsonGenerator.Converter {

private val targetClassNames: Set<String> = excludedQualifiedPropertyNames.mapTo(mutableSetOf()) { field ->
field.substringBeforeLast('.')
}

private val excludedPropertyNames = setOf("class", "declaringClass", "metaClass")

override fun handles(type: Class<*>?): Boolean {
return type != null && targetClassNames.contains(type.simpleName)
}

override fun convert(value: Any, key: String?): Any {
return DefaultGroovyMethods.getProperties(value).filterKeys { propertyName ->
propertyName !in excludedPropertyNames && "${value::class.simpleName}.$propertyName" !in excludedQualifiedPropertyNames
}
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include ':aboutlibraries-compose-m3'
include ':app'
include ':app-desktop'
include ':app-wasm'
include ':app-test'

includeBuild("plugin-build") {
dependencySubstitution {
Expand Down
Loading