Skip to content

Commit

Permalink
Apply dependency analysis plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Feb 16, 2023
1 parent a1aeb4c commit 0ea1923
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/check-dependency-versions.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
@file:Import("workflow-with-copyright.main.kts")

import it.krzeminski.githubactions.actions.actions.CheckoutV3
import it.krzeminski.githubactions.actions.actions.SetupJavaV3
import it.krzeminski.githubactions.actions.actions.SetupJavaV3.Distribution.Temurin
import it.krzeminski.githubactions.actions.burrunan.GradleCacheActionV1
import it.krzeminski.githubactions.domain.RunnerType.WindowsLatest
import it.krzeminski.githubactions.domain.triggers.Cron
Expand Down Expand Up @@ -54,6 +56,13 @@ workflowWithCopyright(
name = "Checkout",
action = CheckoutV3()
)
uses(
name = "Setup Java 11",
action = SetupJavaV3(
javaVersion = "11",
distribution = Temurin
)
)
uses(
name = "Check Dependency Versions",
action = GradleCacheActionV1(
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/check-dependency-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ jobs:
name: Checkout
uses: actions/checkout@v3
- id: step-2
name: Setup Java 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- id: step-3
name: Check Dependency Versions
uses: burrunan/gradle-cache-action@v1
with:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/test.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import it.krzeminski.githubactions.actions.actions.CacheRestoreV3
import it.krzeminski.githubactions.actions.actions.CacheSaveV3
import it.krzeminski.githubactions.actions.actions.CheckoutV3
import it.krzeminski.githubactions.actions.actions.SetupJavaV3
import it.krzeminski.githubactions.actions.actions.SetupJavaV3.Distribution.Temurin
import it.krzeminski.githubactions.actions.burrunan.GradleCacheActionV1
import it.krzeminski.githubactions.actions.vampire.SetupWslV1
import it.krzeminski.githubactions.actions.vampire.SetupWslV1.Distribution
Expand Down Expand Up @@ -150,6 +152,13 @@ workflowWithCopyright(
name = "Checkout",
action = CheckoutV3()
)
uses(
name = "Setup Java 11",
action = SetupJavaV3(
javaVersion = "11",
distribution = Temurin
)
)
uses(
name = "Build",
action = GradleCacheActionV1(
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ jobs:
name: Checkout
uses: actions/checkout@v3
- id: step-2
name: Setup Java 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- id: step-3
name: Build
uses: burrunan/gradle-cache-action@v1
with:
Expand All @@ -59,7 +65,7 @@ jobs:
--info
--stacktrace
--scan
- id: step-3
- id: step-4
name: Save built artifacts to cache
uses: actions/cache/save@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

plugins {
id(libs.plugins.convention.versions.get().pluginId)
id(libs.plugins.convention.dependencies.get().pluginId)
id(libs.plugins.convention.node.get().pluginId)
id(libs.plugins.convention.github.actions.get().pluginId)
id(libs.plugins.convention.readme.get().pluginId)
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ version = 2.0.1-SNAPSHOT
description = A GitHub action to install and setup a Linux distribution for the Windows Subsystem for Linux (WSL)

org.gradle.caching = true

dependency.analysis.print.build.health = true
kotlin.js.ir.output.granularity = whole-program
53 changes: 52 additions & 1 deletion gradle/build-logic/build-logic.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ plugins {
`kotlin-dsl`
alias(libs.plugins.kotlin.serialization)
id(libs.plugins.convention.dependency.updates.report.aggregation.get().pluginId)
alias(libs.plugins.dependency.analysis)
}

dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(plugin(libs.plugins.versions))
implementation(plugin(libs.plugins.dependency.analysis))
implementation(plugin(libs.plugins.release))
implementation(plugin(libs.plugins.grgit))
implementation(plugin(libs.plugins.github))
implementation(plugin(libs.plugins.kotlin.js))
implementation(":dependency-updates-report-aggregation")
implementation(libs.build.inject)
implementation(libs.build.github.api)
implementation(platform(libs.build.kotlinx.serialization.bom))
implementation(libs.build.kotlinx.serialization.core)
implementation(libs.build.kotlinx.serialization.json)
implementation(libs.build.kaml)
implementation(embeddedKotlin("compiler-embeddable"))
}
Expand All @@ -50,6 +52,55 @@ tasks.compileKotlin {
}
}

dependencyAnalysis {
dependencies {
bundle("com.autonomousapps.dependency-analysis.gradle.plugin") {
includeDependency("com.autonomousapps.dependency-analysis:com.autonomousapps.dependency-analysis.gradle.plugin")
includeDependency("com.autonomousapps:dependency-analysis-gradle-plugin")
}
bundle("com.github.ben-manes.versions.gradle.plugin") {
includeDependency("com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin")
includeDependency("com.github.ben-manes:gradle-versions-plugin")
}
bundle("net.researchgate.release.gradle.plugin") {
includeDependency("net.researchgate.release:net.researchgate.release.gradle.plugin")
includeDependency("net.researchgate:gradle-release")
}
bundle("net.wooga.github.gradle.plugin") {
includeDependency("net.wooga.github:net.wooga.github.gradle.plugin")
includeDependency("gradle.plugin.net.wooga.gradle:atlas-github")
}
bundle("org.ajoberstar.grgit.gradle.plugin") {
includeDependency("org.ajoberstar.grgit:org.ajoberstar.grgit.gradle.plugin")
includeDependency("org.ajoberstar.grgit:grgit-core")
}
bundle("org.jetbrains.kotlin.js.gradle.plugin") {
includeDependency("org.jetbrains.kotlin.js:org.jetbrains.kotlin.js.gradle.plugin")
includeDependency("org.jetbrains.kotlin:kotlin-gradle-plugin-api")
includeDependency("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
issues {
all {
onAny {
// the "implementation(files(...)) is reported as false-positive unused
// and cannot be suppressed, so we cannot let the task fail currently
//severity("fail")
}
onUsedTransitiveDependencies {
// false positive
exclude(":dependency-updates-report-aggregation")
}
}
}
}

tasks.configureEach {
if (name == "buildHealth") {
dependsOn(gradle.includedBuilds.map { it.task(":buildHealth") })
}
}

fun plugin(plugin: Provider<PluginDependency>) = plugin.map {
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version.requiredVersion}"
}
2 changes: 2 additions & 0 deletions gradle/build-logic/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
# limitations under the License.

org.gradle.caching = true

dependency.analysis.print.build.health = true
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.security.MessageDigest

plugins {
id("net.kautler.dependency-updates-report-aggregation")
id("com.autonomousapps.dependency-analysis")
}

val majorVersion by extra("$version".substringBefore('.'))
Expand Down Expand Up @@ -76,3 +77,19 @@ tasks.dependencyUpdates {
add(group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8")
}
}

dependencyAnalysis {
issues {
all {
onAny {
severity("fail")
}
}
}
}

tasks.configureEach {
if (name == "buildHealth") {
dependsOn(gradle.includedBuilds.map { it.task(":buildHealth") })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import kotlin.LazyThreadSafetyMode.NONE

plugins {
// needed for accessing majorVersion
id("net.kautler.versions")
id("net.kautler.dependencies")
id("org.ajoberstar.grgit")
id("net.wooga.github")
}
Expand Down Expand Up @@ -100,7 +100,7 @@ val releaseTagName by lazy(NONE) {
releasePlugin.tagName()!!
}

val github by lazy(NONE) {
internal val github by lazy(NONE) {
GitHub.connectUsingOAuth(extra["github.token"] as String)!!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.security.MessageDigest

plugins {
// needed for accessing majorVersion
id("net.kautler.versions")
id("net.kautler.dependencies")
`lifecycle-base`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
`kotlin-dsl`
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.versions)
alias(libs.plugins.dependency.analysis)
}

dependencies {
Expand All @@ -29,6 +30,22 @@ dependencies {
implementation(libs.build.kotlinx.serialization.json)
}

dependencyAnalysis {
dependencies {
bundle("com.github.ben-manes.versions.gradle.plugin") {
includeDependency("com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin")
includeDependency("com.github.ben-manes:gradle-versions-plugin")
}
}
issues {
all {
onAny {
severity("fail")
}
}
}
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
allWarningsAsErrors = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
# limitations under the License.

org.gradle.caching = true

dependency.analysis.print.build.health = true
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ actions-io = "1.1.2"
actions-tool-cache = "2.0.1"
build-dukat = "0.5.7"
build-github-api = "1.117"
build-gradle-plugin-dependency-analysis = "1.19.0"
build-gradle-plugin-github = "1.4.0"
build-gradle-plugin-grgit = "4.1.1"
build-gradle-plugin-release = "2.8.1"
build-gradle-plugin-versions = "0.36.0"
build-inject = "1"
build-kaml = "0.51.0"
build-kotlin = "1.8.10"
build-kotlinx-serialization = "1.4.1"
Expand All @@ -46,6 +48,7 @@ actions-http-client = { module = "actions:http-client", version.ref = "actions-h
actions-io = { module = "actions:io", version.ref = "actions-io" }
actions-tool-cache = { module = "actions:tool-cache", version.ref = "actions-tool-cache" }
build-github-api = { module = "org.kohsuke:github-api", version.ref = "build-github-api" }
build-inject = { module = "javax.inject:javax.inject", version.ref = "build-inject" }
build-kaml = { module = "com.charleskorn.kaml:kaml", version.ref = "build-kaml" }
build-kotlinx-serialization-bom = { module = "org.jetbrains.kotlinx:kotlinx-serialization-bom", version.ref = "build-kotlinx-serialization" }
build-kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core" }
Expand All @@ -63,13 +66,14 @@ workflows-kotlin-main-kts = { module = "org.jetbrains.kotlin:kotlin-main-kts", v
workflows-kotlin-scripting-compiler = { module = "org.jetbrains.kotlin:kotlin-scripting-compiler", version.ref = "workflows-kotlin" }

[plugins]
convention-dependencies = { id = "net.kautler.dependencies", version = "?" }
convention-dependency-updates-report-aggregation = { id = "net.kautler.dependency-updates-report-aggregation", version = "?" }
convention-github_actions = { id = "net.kautler.github_actions", version = "?" }
convention-ncc-packer = { id = "net.kautler.ncc_packer", version = "?" }
convention-node = { id = "net.kautler.node", version = "?" }
convention-publishing = { id = "net.kautler.publishing", version = "?" }
convention-readme = { id = "net.kautler.readme", version = "?" }
convention-versions = { id = "net.kautler.versions", version = "?" }
dependency-analysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "build-gradle-plugin-dependency-analysis" }
github = { id = "net.wooga.github", version.ref = "build-gradle-plugin-github" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "build-gradle-plugin-grgit" }
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import org.gradle.api.initialization.resolve.RepositoriesMode.PREFER_SETTINGS

pluginManagement {
require(JavaVersion.current().isJava11Compatible) {
"This build requires Gradle to be run with at least Java 11"
}

includeBuild("gradle/build-logic")
repositories {
mavenCentral()
Expand Down

0 comments on commit 0ea1923

Please sign in to comment.