diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5f6019bfd..f01bf9f733 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -133,6 +133,47 @@ jobs: if: github.event.pull_request.head.repo.full_name != github.repository run: ./gradlew ktlintCheck -q --no-daemon + modulecheck: + + runs-on: ubuntu-latest + if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' + + steps: + - name: check out with token (used by forks) + uses: actions/checkout@v2 + if: github.event.pull_request.head.repo.full_name != github.repository + + - name: check out with PAT (used by main repo) + uses: actions/checkout@v2 + if: github.event.pull_request.head.repo.full_name == github.repository + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + fetch-depth: 0 + + - name: Set up JDK + uses : actions/setup-java@v2 + with : + distribution : 'adopt' + java-version : '11' + cache: 'gradle' + + - name: ModuleCheck with auto-correct (used by main repo) + if: github.event.pull_request.head.repo.full_name == github.repository + run: ./gradlew moduleCheckAuto + + # If KtLint generated changes, commit and push those changes. + - name: commit changes (used by main repo) + if: github.event.pull_request.head.repo.full_name == github.repository + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply ModuleCheck fixes + commit_options: '--no-verify --signoff' + + - name: ModuleCheck check (used by forks) + if: github.event.pull_request.head.repo.full_name != github.repository + run: ./gradlew moduleCheck + versioning: runs-on: ubuntu-latest diff --git a/build.gradle.kts b/build.gradle.kts index ed3a0cbeba..bea7ab5529 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,14 @@ plugins { id("mcbuild.ktlint") id("mcbuild.test") id("mcbuild.website") + id("com.rickbusarow.module-check") version "0.12.0" +} + +moduleCheck { + deleteUnused = true + checks { + sortDependencies = true + } } tasks.named("ktlintFormat") { diff --git a/modulecheck-config/fake/build.gradle.kts b/modulecheck-config/fake/build.gradle.kts index 73a8c46790..e265e8148a 100644 --- a/modulecheck-config/fake/build.gradle.kts +++ b/modulecheck-config/fake/build.gradle.kts @@ -21,15 +21,16 @@ mcbuild { artifactId = "modulecheck-config-fake" anvil = true } -dependencies { - api(project(path = ":modulecheck-config:api")) +dependencies { api(libs.kotlin.compiler) api(libs.kotlinx.coroutines.core) api(libs.kotlinx.coroutines.jvm) api(libs.rickBusarow.dispatch.core) api(libs.semVer) + api(project(path = ":modulecheck-config:api")) + compileOnly(gradleApi()) implementation(libs.agp) diff --git a/modulecheck-plugin/build.gradle.kts b/modulecheck-plugin/build.gradle.kts index 906d7faf9a..dbb962a4e3 100644 --- a/modulecheck-plugin/build.gradle.kts +++ b/modulecheck-plugin/build.gradle.kts @@ -58,8 +58,8 @@ dependencies { implementation(libs.square.anvil.gradle) implementation(project(path = ":modulecheck-project:impl")) - implementation(project(path = ":modulecheck-utils")) implementation(project(path = ":modulecheck-rule:impl")) + implementation(project(path = ":modulecheck-utils")) testImplementation(libs.bundles.hermit) testImplementation(libs.bundles.jUnit) diff --git a/modulecheck-reporting/console/build.gradle.kts b/modulecheck-reporting/console/build.gradle.kts index e85b48f849..18b8804060 100644 --- a/modulecheck-reporting/console/build.gradle.kts +++ b/modulecheck-reporting/console/build.gradle.kts @@ -24,9 +24,9 @@ mcbuild { dependencies { - api(project(path = ":modulecheck-rule:api")) api(project(path = ":modulecheck-api")) api(project(path = ":modulecheck-reporting:logging")) + api(project(path = ":modulecheck-rule:api")) implementation(project(path = ":modulecheck-parsing:gradle")) diff --git a/modulecheck-rule/impl/build.gradle.kts b/modulecheck-rule/impl/build.gradle.kts index 7021f6a78a..ba1267ab28 100644 --- a/modulecheck-rule/impl/build.gradle.kts +++ b/modulecheck-rule/impl/build.gradle.kts @@ -32,14 +32,14 @@ dependencies { api(project(path = ":modulecheck-rule:api")) api(project(path = ":modulecheck-utils")) - implementation(project(path = ":modulecheck-dagger")) - compileOnly(gradleApi()) implementation(libs.agp) implementation(libs.groovy) implementation(libs.kotlin.reflect) + implementation(project(path = ":modulecheck-dagger")) + testImplementation(libs.bundles.hermit) testImplementation(libs.bundles.jUnit) testImplementation(libs.bundles.kotest) diff --git a/settings.gradle.kts b/settings.gradle.kts index dc1d9b027b..8fd751697c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,6 +19,13 @@ pluginManagement { mavenCentral() google() mavenLocal() + maven { + url = uri("https://oss.sonatype.org/content/repositories/snapshots/") + content { + includeGroup("com.rickbusarow.module-check") + includeGroup("com.rickbusarow.modulecheck") + } + } } @Suppress("UnstableApiUsage") includeBuild("build-logic")