Last active
November 28, 2025 16:02
-
-
Save oowekyala/2d4e90e3de846e683dc5eea9194129ac to your computer and use it in GitHub Desktop.
PMD justfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Justfile | |
| # Convenience recipes for developers of PMD | |
| # | |
| # Just documentation: https://github.com/casey/just | |
| commonBuildOpts := "-Dmaven.javadoc.skip -Dkotlin.compiler.incremental -Dmaven.source.skip -Pcentral-portal-snapshots" | |
| # Regenerate sources for the Java module | |
| genJavaAst: | |
| rm -f pmd-java/target/last-generated-timestamp-* | |
| mvnd generate-sources -pl pmd-java | |
| # Regenerate sources for all modules | |
| reGenAllSources *FLAGS: | |
| rm -rf pmd-*/target/generated-sources | |
| rm -f pmd-*/target/last-generated-timestamp-* | |
| mvnd generate-sources -fae {{FLAGS}} | |
| cleanEverything: | |
| mvnd clean | |
| # Install a single module, written without pmd prefix (eg `just install core`) | |
| install MOD *FLAGS: | |
| mvnd install {{commonBuildOpts}} -pl "pmd-{{MOD}}" {{FLAGS}} | |
| alias i := install | |
| # Clean install every module into the local repository. | |
| cleanInstallEverything *FLAGS: | |
| mvnd clean install {{commonBuildOpts}} -fae {{FLAGS}} | |
| # Install every module into the local repository. | |
| installEverything *FLAGS: | |
| mvnd install {{commonBuildOpts}} -fae {{FLAGS}} | |
| testCore *FLAGS: | |
| mvnd test {{commonBuildOpts}} -pl pmd-core {{FLAGS}} | |
| testJava *FLAGS: | |
| mvnd test {{commonBuildOpts}} -pl pmd-java {{FLAGS}} | |
| # Install pmd-java and its dependencies | |
| installJavaAndDeps *FLAGS: (installJava '-am' FLAGS) | |
| # Install just pmd-java | |
| installJava *FLAGS: | |
| mvnd install {{commonBuildOpts}} -pl pmd-java {{FLAGS}} | |
| # Print name of modules that changed w.r.t the baseline. | |
| [private] | |
| changedModules BASELINE="main": | |
| #!/bin/env zsh | |
| changed=$(git diff --name-only {{BASELINE}} '*.java' '*.xml') | |
| changed=(${(f)changed}) | |
| typeset -Ua projects # array-unique | |
| projects=(${changed%%/*}) # remove all but first segment | |
| projects=(${(M)projects:#pmd-*}) # filter only maven modules | |
| echo "${(j.,.)projects}" # join with comma | |
| # Lint modules that changed w.r.t the baseline. | |
| lintChanged BASELINE="main": | |
| #!/bin/env zsh | |
| changed=$(just changedModules {{BASELINE}}) | |
| echo "Linting ${changed}" | |
| just lintAll -pl "${changed}" | |
| # Lint projects (specified without the pmd prefix), eg `just lint java` or `just lint core` | |
| @lint *projects="java": | |
| just lintAll -pl $(just expand_mod_list {{projects}}) | |
| [private] | |
| expand_mod_list *projects: | |
| #!/bin/env zsh | |
| projects=({{projects}}) # fill ZSH variable | |
| projects=(${projects/#/pmd-}) # prepend pmd- | |
| projects="${(j.,.)projects}" # join with comma | |
| echo "$projects" | |
| # Lint all modules | |
| # Note: cpd-check is not included, only a report is generated | |
| lintAll *FLAGS: | |
| #!/bin/env zsh | |
| mvnd pmd:{pmd,check,cpd}@{pmd-main,pmd-test} checkstyle:check \ | |
| -Pcentral-portal-snapshots -Dpmd.skip=false -Dcpd.skip=false -Dcheckstyle.skip=false -fae {{FLAGS}} | |
| # Delete local branches that have been merged into main | |
| deleteMergedBranches: | |
| git branch --merged main | grep -E -v "(^\*|main)" | xargs -r git branch -d | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment