khalilou88 / jnxplus

Nx plugins that adds Java/Kotlin monorepo support to Nx workspace using Gradle and Maven
MIT License
56 stars 14 forks source link

How to use maven-checkstyle-plugin? #509

Open khalilou88 opened 9 months ago

khalilou88 commented 9 months ago

To use linters, jnxplus plugins downland jars from checkstyle and ktlint from github releases. I thought this technique was stable but we still receive issues.

I want to try the following technique and see if it's fit nx monorepo:

https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html

To lint a project, we can use run-task from jnxplus.

khalilou88 commented 6 months ago

1- Create a lib for checkstyle linting: build-tools-checkstyle

2- add maven-checkstyle-plugin to root pom.xml

3- add target config to nx.json

    "maven-checkstyle-lint": {
      "cache": true,
      "dependsOn": [
        {
          "projects": ["build-tools-checkstyle"], 
          "target": "build"
        }
      ]
    }

4- add target to project.json

    "maven-checkstyle-lint": {
      "executor": "@jnxplus/nx-maven:run-task",
      "options": {
        "task": "checkstyle:check"
      }
    }
khalilou88 commented 6 months ago

code is here https://github.com/khalilou88/jnxplus-examples