Another thing: I want to use the Problems API to a...
# community-support
a
Another thing: I want to use the Problems API to add a warning, but it doesn't log any message to console. This means when signing fails for dev-publish users basically only see the 'signatory not configured' failure, and it's hard to discover the softer warning which would help. Why aren't Problems API warnings printed to the console? Is there a way to make them move visible? Or should dev-publish use error-level warnings instead? Or dev-publish should log warnings to the console and via Problems API?
v
On which Gradle version are you?
Copy code
interface ProblemsProvider {
    @get:Inject
    val problems: Problems
}
tasks.register("foo") {
    val problemReporter = objects.newInstance<ProblemsProvider>().problems.reporter
    doLast {
        problemReporter.report(
            ProblemId.create(
                "foo",
                "Foo",
                ProblemGroup.create("bar", "Bar")
            )
        ) {
            solution("Do something")
        }
    }
}
=>
Copy code
> Task :foo
Problem found: Foo (id: bar:foo)
    Possible solution: Do something.

[Incubating] Problems report is available at: file:///.../showcase/build/reports/problems/problems-report.html
Ah, I usually always run with
org.gradle.warning.mode=all
. With
fail
,
summary
, or
none
it is not printed to console but only rendered in the problems report.
So I'd say no, don't print it to console manually. If you use
problemReporter.report
then it is just a warning and thus only displayed if a user decides to display warnings. If you use
problemReporter.throwing
it is an error that also will fail the build and is always displayed.
The rendering to console is there since 9.3.0, so at most I would use an
if
to render to console manually additionally if Gradle version is below 9.3.0.
And with rendering manually I mean using
logger.warn
so that at least
-q
can suppress the warning. If you render it unconditionally in 9.3+, then users that enabled warning display will get the warning twice.