Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #523: Add extraMvnOptions support to diff.groovy #538

Merged
merged 1 commit into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions checkstyle-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ will be analyzed by Checkstyle during report generation.
This option is useful for Windows users where they are restricted to maximum directory depth
(optional, default is false).

**extraMvnRegressionOptions** (xm) - this option can be used to supply extra command line arguments
to maven during the Checkstyle regression run. For example, if you want to skip site generation, you
would add `--extraMvnRegressionOptions "-Dmaven.site.skip=true"` to `diff.groovy` execution.

## Outputs

When the script finishes its work the following directory structure will be created
Expand Down
19 changes: 17 additions & 2 deletions checkstyle-tester/diff.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def getCliOptions(args) {
+ ' as a shorter version to prevent long paths. (optional, default is false)')
m(longOpt: 'mode', args: 1, required: false, argName: 'mode', 'The mode of the tool:' \
+ ' \'diff\' or \'single\'. (optional, default is \'diff\')')
xm(longOpt: 'extraMvnRegressionOptions', args: 1, required: false, 'Extra arguments to pass to Maven' \
+ 'for Checkstyle Regression run (optional, ex: -Dmaven.prop=true)')
}
return cli.parse(args)
}
Expand All @@ -76,6 +78,7 @@ def areValidCliOptions(cliOptions) {
def localGitRepo = new File(cliOptions.localGitRepo)
def patchBranch = cliOptions.patchBranch
def baseBranch = cliOptions.baseBranch
def extraMvnRegressionOptions = cliOptions.extraMvnRegressionOptions

if (toolMode && !('diff'.equals(toolMode) || 'single'.equals(toolMode))) {
err.println "Error: Invalid mode: \'$toolMode\'. The mode should be \'single\' or \'diff\'!"
Expand Down Expand Up @@ -185,8 +188,16 @@ def generateCheckstyleReport(cfg) {
def checkstyleVersion = getCheckstyleVersionFromPomXml("$cfg.localGitRepo/pom.xml", 'version')

executeCmd("mvn -e --batch-mode -Pno-validations clean install", cfg.localGitRepo)
executeCmd("""groovy launch.groovy --listOfProjects $cfg.listOfProjects
--config $cfg.checkstyleCfg --ignoreExceptions --ignoreExcludes --checkstyleVersion $checkstyleVersion""")

command = """groovy launch.groovy --listOfProjects $cfg.listOfProjects
--config $cfg.checkstyleCfg --ignoreExceptions --ignoreExcludes
--checkstyleVersion $checkstyleVersion"""

if (cfg.extraMvnRegressionOptions == true) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strangely, this is required, since if (cfg.extraMvnRegressionOptions) does not work as intended. I assume this is because groovy is not strongly typed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@nrmancuso nrmancuso Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference that I can see is that we are accessing cfg's fields and opposed to actually passing arguments to generateCheckstyleReport()? Should I investigate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not that big a deal.

command.concat("--extraMvnOptions " + cfg.extraMvnRegressionOptions)
}
executeCmd(command)

println "Moving Checkstyle report into $cfg.destDir ..."
moveDir("reports", cfg.destDir)

Expand Down Expand Up @@ -480,11 +491,13 @@ class Config {
def tmpMasterReportsDir
def tmpPatchReportsDir
def diffDir
def extraMvnRegressionOptions

Config(cliOptions) {
localGitRepo = new File(cliOptions.localGitRepo)
shortFilePaths = cliOptions.shortFilePaths
listOfProjects = cliOptions.listOfProjects
extraMvnRegressionOptions = cliOptions.extraMvnRegressionOptions

mode = cliOptions.mode
if (!mode) {
Expand Down Expand Up @@ -531,6 +544,7 @@ class Config {
checkstyleCfg: baseConfig,
listOfProjects: listOfProjects,
destDir: tmpMasterReportsDir,
extraMvnRegressionOptions: extraMvnRegressionOptions,
]
}

Expand All @@ -541,6 +555,7 @@ class Config {
checkstyleCfg: patchConfig,
listOfProjects: listOfProjects,
destDir: tmpPatchReportsDir,
extraMvnRegressionOptions: extraMvnRegressionOptions,
]
}

Expand Down