From 46f7091736be5330e8562d7ebee630e4a803a3e6 Mon Sep 17 00:00:00 2001 From: micronaut-build <65172877+micronaut-build@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:36:31 +0100 Subject: [PATCH] Sonatype Scan Gradle Plugin (#405) https://github.com/sonatype-nexus-community/scan-gradle-plugin --- .github/renovate.json | 22 +++++++++++++------ .github/workflows/gradle.yml | 7 ++++++ buildSrc/build.gradle | 1 + ...t.build.internal.jackson-xml-module.gradle | 11 ++++++++++ gradle/libs.versions.toml | 2 ++ gradlew | 3 +-- 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 09c2a598..99eeec10 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,24 +1,32 @@ { "extends": [ - "config:base" + "config:recommended" + ], + "addLabels": [ + "type: dependency-upgrade" ], - "addLabels": ["type: dependency-upgrade"], "schedule": [ - "after 10pm every day" + "after 10pm" ], "prHourlyLimit": 1, "prConcurrentLimit": 20, "timezone": "Europe/Prague", "packageRules": [ { - "matchPackagePatterns": ["actions.*"], "dependencyDashboardApproval": true, - "matchUpdateTypes": ["patch"], + "matchUpdateTypes": [ + "patch" + ], "matchCurrentVersion": "!/^0/", - "automerge": true + "automerge": true, + "matchPackageNames": [ + "/actions.*/" + ] }, { - "matchUpdateTypes": ["patch"], + "matchUpdateTypes": [ + "patch" + ], "matchCurrentVersion": "!/^0/", "automerge": true } diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 571e79a2..32d879ad 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -30,6 +30,8 @@ jobs: PREDICTIVE_TEST_SELECTION: "${{ github.event_name == 'pull_request' && 'true' || 'false' }}" SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OSS_INDEX_USERNAME: ${{ secrets.OSS_INDEX_USERNAME }} + OSS_INDEX_PASSWORD: ${{ secrets.OSS_INDEX_PASSWORD }} steps: # https://github.com/actions/virtual-environments/issues/709 - name: "🗑 Free disk space" @@ -58,6 +60,11 @@ jobs: run: | [ -f ./setup.sh ] && ./setup.sh || [ ! -f ./setup.sh ] + - name: "🚔 Sonatype Scan" + id: sonatypescan + run: | + ./gradlew ossIndexAudit --no-parallel --info + - name: "🛠 Build with Gradle" id: gradle run: | diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 56c8e7a7..398b29f7 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -9,4 +9,5 @@ repositories { dependencies { implementation libs.gradle.micronaut + implementation(libs.sonatype.scan) } diff --git a/buildSrc/src/main/groovy/io.micronaut.build.internal.jackson-xml-module.gradle b/buildSrc/src/main/groovy/io.micronaut.build.internal.jackson-xml-module.gradle index 54aeeeb6..41a5385a 100644 --- a/buildSrc/src/main/groovy/io.micronaut.build.internal.jackson-xml-module.gradle +++ b/buildSrc/src/main/groovy/io.micronaut.build.internal.jackson-xml-module.gradle @@ -1,4 +1,15 @@ plugins { id "io.micronaut.build.internal.jackson-xml-base" id "io.micronaut.build.internal.module" + id("org.sonatype.gradle.plugins.scan") } +String ossIndexUsername = System.getenv("OSS_INDEX_USERNAME") ?: project.properties["ossIndexUsername"] +String ossIndexPassword = System.getenv("OSS_INDEX_PASSWORD") ?: project.properties["ossIndexPassword"] +boolean sonatypePluginConfigured = ossIndexUsername != null && ossIndexPassword != null +if (sonatypePluginConfigured) { + ossIndexAudit { + username = ossIndexUsername + password = ossIndexPassword + } +} + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ac9168a0..0315b3c2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ groovy = "4.0.13" spock = "2.3-groovy-4.0" jaxb-api = "2.3.1" kotlin = "1.9.25" +sonatype-scan = "3.0.0" [libraries] micronaut-core = { module = 'io.micronaut:micronaut-core-bom', version.ref = 'micronaut' } @@ -19,6 +20,7 @@ junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } gradle-micronaut = { module = "io.micronaut.gradle:micronaut-gradle-plugin", version.ref = "micronaut-gradle-plugin" } +sonatype-scan = { module = "org.sonatype.gradle.plugins:scan-gradle-plugin", version.ref = "sonatype-scan" } [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } diff --git a/gradlew b/gradlew index f5feea6d..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum