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

Print report path #51

Closed
hasnainjaved opened this issue Jan 29, 2018 · 10 comments
Closed

Print report path #51

hasnainjaved opened this issue Jan 29, 2018 · 10 comments

Comments

@hasnainjaved
Copy link

Hello,

Is there a way to print out the path for the report file on the console ? Useful for CI/CD environments.
If not, is there a work around to print it out ?

Kind Regards .

@JLLeitschuh
Copy link
Owner

Umm... Currently no. I don't think we expose that. We could/should. This would probably be easiest to do if we were to make the Ktlint task extend something like SourceTask and then add our own custom fields to it like reportDirectory. That way API consumers could just read from that field.
@Tapchicoma thoughts?

@Tapchicoma
Copy link
Collaborator

@hasnainjaved can you provide examples of use-case?

Currently plugin always create reports in $project.buildDir/reports/ktlint. Can your CI/CD just grab all the files from that directory?

@Tapchicoma
Copy link
Collaborator

I don't see the point of adding this feature, but possible solution may be:
check for verbose flag value in extension and on true print "Ktlint report file: ${fileLocation}" to project.logger.warn

@hasnainjaved
Copy link
Author

@Tapchicoma since CI/CD servers don't have a GUI so grabbing the path from the console and pasting into a browser would be convenient eg. Maven's surefire plugin prints the path of the report in case of test failures. We are currently doing what you have suggested.

@JLLeitschuh Just printing the path would suffice.

@JLLeitschuh
Copy link
Owner

I don't think we should just print the directory. We should make it something that the user can retrieve as a method or field. Then they can do what they want with it.

@Tapchicoma
Copy link
Collaborator

@hasnainjaved just to clarify:

You are using some non-Gradle tool to post failed results back to PR as a comment? Not failed builds should not print report path?

Will some Gradle callback suit your goals?

@Tapchicoma
Copy link
Collaborator

@hasnainjaved is this issue still actual?

@eskatos
Copy link
Contributor

eskatos commented May 30, 2018

I'd say that in case of a linting failure it would be nice to have the report(s) path(s) in the exception message so that Gradle will display them in the build failure summary. This will make it work nicely even with --parallel and --continue and multiple tasks failure.

Then, logging the report(s) path(s) at e.g. info level should be enough for folks that would like to get the path always, they would simply have to use -i.

@Tapchicoma
Copy link
Collaborator

Related commit in KtLint: pinterest/ktlint@30ec67d

@Tapchicoma
Copy link
Collaborator

New released version of KtLint 0.24.0 prints report location in console:

"plain" report written to /home/user/app/build/reports/ktlint/ktlint-release.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants