Skip to content

Commit

Permalink
Merge pull request #863 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Apr 8, 2023
2 parents b5adde1 + bebaf72 commit 9bacd99
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 32 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

## Latest releases 🛠

- (Next Gen) Kotlin && Multiplatform && Plugin | [v10.6.1](https://github.com/mikepenz/AboutLibraries/tree/v10.6.1)
- (Next Gen) Kotlin && Multiplatform && Plugin | [v10.6.2](https://github.com/mikepenz/AboutLibraries/tree/v10.6.2)
- Kotlin && Gradle Plugin | [v8.9.4](https://github.com/mikepenz/AboutLibraries/tree/v8.9.4)

## Gradle Plugin
Expand Down Expand Up @@ -133,6 +133,8 @@ aboutLibraries {
duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.SIMPLE
// Enable pretty printing for the generated JSON file
prettyPrint = false
// Allows to only collect dependencies of specific variants during the `collectDependencies` step.
filterVariants = ["debug", "release"]
}
```

Expand Down Expand Up @@ -371,14 +373,15 @@ For other environments or for more advanced usages the plugin offers additional
# Export only for a specific variant: `release`
./gradlew app-desktop:exportLibraryDefinitions -PaboutLibraries.exportPath=src/main/resources/ -PaboutLibraries.exportVariant=release

# Export dependencies as CSV
# Export dependencies to CLI in CSV format
./gradlew exportLibraries
./gradlew exportLibraries${Variant}

# Outputs all dependencies with name, version and their identifier
./gradlew findLibraries

# Export all dependencies in a format helpful for compliance reports
# Exports all dependencies in a format helpful for compliance reports.
# By default writes `export.csv` and `export.txt` and `dependencies` folder in the root of the project.
./gradlew exportComplianceLibraries${Variant}

# List all funding options for included projects (as identified via the e.g.: GitHub API)
Expand Down
5 changes: 5 additions & 0 deletions app-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ compose {
kotlinCompilerPlugin.set(libs.versions.composeCompilerJb.get())
}

tasks.withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
Expand Down
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ aboutLibraries {
duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.SIMPLE
// Enable pretty printing for the generated JSON file
prettyPrint = true

// Allows to only collect dependencies of specific variants during the `collectDependencies` step.
// filterVariants = ["debug"]
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP=com.mikepenz
VERSION_NAME=10.6.1
VERSION_CODE=100601
VERSION_NAME=10.6.2
VERSION_CODE=100602

POM_URL=https://github.com/mikepenz/AboutLibraries
POM_SCM_URL=https://github.com/mikepenz/AboutLibraries
Expand Down
30 changes: 15 additions & 15 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ coreMinSdk = "19"
minSdk = "21"
targetSdk = "33"
# build
gradleBuild = "7.4.1"
gradleBuild = "7.4.2"
buildTools = "33.0.2"
# kotlin
dokka = "1.7.20"
kotlinCore = { require = "1.8.0" }
dokka = "1.8.10"
kotlinCore = { require = "1.8.10" }
kotlinCoroutines = { require = "1.6.4" }
kotlinxSerialization = "1.4.1"
kotlinxSerialization = "1.5.0"
# compose
compose = "1.3.3"
composeUi = "1.3.1" # foundation / materila
composeCompiler = "1.4.1"
composejb = "1.3.0"
composeCompilerJb = "1.4.0"
compose = "1.4.1"
composeUi = "1.4.1" # foundation / materila
composeCompiler = "1.4.4"
composejb = "1.3.1"
composeCompilerJb = "1.4.2"
# androidx
activity = "1.6.1"
activity = "1.7.0"
cardview = "1.0.0"
constraintLayout = "2.1.4"
core = "1.9.0"
lifecycle = { require = "2.5.1" }
core = "1.10.0"
lifecycle = { require = "2.6.1" }
navigation = "2.5.3"
recyclerView = "1.2.1"
recyclerView = "1.3.0"
# google
material = "1.8.0"
# other
accompanist = "0.28.0"
accompanist = "0.30.1"
fastAdapter = "5.7.0"
gradleMvnPublish = "0.24.0"
gradleMvnPublish = "0.25.1"
iconics = "5.3.3"
itemAnimators = "1.1.0"
ivy = "2.5.1"
Expand Down
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.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
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.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ abstract class AboutLibrariesCollectorTask : DefaultTask() {
@Input
val includePlatform = extension.includePlatform

@Input
val filterVariants = extension.filterVariants

/** holds the collected set of dependencies*/
@Internal
protected lateinit var collectedDependencies: CollectedContainer
Expand All @@ -29,7 +32,7 @@ abstract class AboutLibrariesCollectorTask : DefaultTask() {
*/
fun configure() {
project.evaluationDependsOnChildren()
collectedDependencies = DependencyCollector(includePlatform).collect(project)
collectedDependencies = DependencyCollector(includePlatform, filterVariants).collect(project)
}

@TaskAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ abstract class AboutLibrariesExtension {
* ```
*/
var prettyPrint: Boolean = false

/**
* Defines the variants to keep during the "collectDependencies" step.
*
* ```
* aboutLibraries {
* filterVariants = arrayOf("debug")
* }
* ```
*/
var filterVariants: Array<String> = emptyArray()
}

enum class StrictMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory
*/
class DependencyCollector(
private val includePlatform: Boolean = false,
private val filterVariants: Array<String> = emptyArray(),
) {
/**
* Generates the project dependency report structure
Expand All @@ -38,7 +39,8 @@ class DependencyCollector(
fun collect(project: Project): CollectedContainer {
LOGGER.info("Collecting dependencies")

val mutableCollectContainer: MutableMap<String, MutableMap<String, MutableSet<String>>> = mutableMapOf()
val mutableCollectContainer: MutableMap<String, MutableMap<String, MutableSet<String>>> =
sortedMapOf(compareBy<String> { it })

project.configurations
.filterNot { configuration ->
Expand All @@ -50,18 +52,26 @@ class DependencyCollector(

if (cn.endsWith("CompileClasspath", true)) {
val variant = cn.removeSuffix("CompileClasspath")
LOGGER.info("Collecting dependencies for compile time variant $variant from config: ${it.name}")
return@mapNotNull variant to it
if (filterVariants.isEmpty() || filterVariants.contains(variant)) {
LOGGER.info("Collecting dependencies for compile time variant $variant from config: ${it.name}")
return@mapNotNull variant to it
} else {
LOGGER.info("Skipping compile time variant $variant from config: ${it.name}")
}
} else if (cn.endsWith("RuntimeClasspath", true)) {
val variant = cn.removeSuffix("RuntimeClasspath")
LOGGER.info("Collecting dependencies for runtime variant $variant from config: ${it.name}")
return@mapNotNull variant to it
if (filterVariants.isEmpty() || filterVariants.contains(variant)) {
LOGGER.info("Collecting dependencies for runtime variant $variant from config: ${it.name}")
return@mapNotNull variant to it
} else {
LOGGER.info("Skipping compile time variant $variant from config: ${it.name}")
}
}

null
}
.forEach { (variant, configuration) ->
val variantSet = mutableCollectContainer.getOrPut(variant) { mutableMapOf() }
val variantSet = mutableCollectContainer.getOrPut(variant) { sortedMapOf(compareBy<String> { it }) }
val visitedDependencyNames = mutableSetOf<String>()
configuration
.resolvedConfiguration
Expand All @@ -70,9 +80,10 @@ class DependencyCollector(
.getResolvedArtifacts(visitedDependencyNames)
.forEach { resArtifact ->
val identifier = "${resArtifact.moduleVersion.id.group.trim()}:${resArtifact.name.trim()}"
val versions = variantSet.getOrPut(identifier) { HashSet() }
val versions = variantSet.getOrPut(identifier) { LinkedHashSet() }
versions.add(resArtifact.moduleVersion.id.version.trim())
}

}
return CollectedContainer(mutableCollectContainer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LibrariesProcessor(
LOGGER.info("All dependencies.size = ${collectedDependencies.size}")

val librariesList = ArrayList<Library>()
val licensesMap = HashMap<String, License>()
val licensesMap = sortedMapOf<String, License>(compareBy { it })
for (dependency in collectedDependencies) {
val groupArtifact = dependency.key.split(":")
val version = dependency.value.first()
Expand Down Expand Up @@ -135,7 +135,10 @@ class LibrariesProcessor(
}
}

return ResultContainer(librariesList.processDuplicates(duplicationMode, duplicationRule), licensesMap)
return ResultContainer(
librariesList.processDuplicates(duplicationMode, duplicationRule).sortedBy { it.uniqueId },
licensesMap
)
}

private fun parseDependency(artifactFile: File): Pair<Library, Set<License>>? {
Expand Down

0 comments on commit 9bacd99

Please sign in to comment.