@@ -50,6 +50,8 @@ import org.gradle.api.attributes.Bundling
5050import org.gradle.api.attributes.Category
5151import org.gradle.api.attributes.LibraryElements
5252import org.gradle.api.attributes.Usage
53+ import org.gradle.api.problems.Problems
54+ import org.gradle.api.problems.Severity
5355import org.gradle.api.provider.Provider
5456import org.gradle.api.tasks.Delete
5557import org.gradle.api.tasks.TaskProvider
@@ -71,6 +73,9 @@ abstract class PaperweightUser : Plugin<Project> {
7173 @get:Inject
7274 abstract val javaToolchainService: JavaToolchainService
7375
76+ @get:Inject
77+ abstract val problems: Problems
78+
7479 override fun apply (target : Project ) {
7580 target.plugins.apply (" java" )
7681
@@ -267,12 +272,17 @@ abstract class PaperweightUser : Plugin<Project> {
267272 ! configurations.getByName(DEV_BUNDLE_CONFIG ).isEmpty
268273 }
269274 if (hasDevBundle.isFailure || ! hasDevBundle.getOrThrow()) {
270- val message = " paperweight requires a development bundle to be added to the 'paperweightDevelopmentBundle' configuration, as" +
271- " well as a repository to resolve it from in order to function. Use the dependencies.paperweight extension to do this easily."
272- throw PaperweightException (
273- message,
274- hasDevBundle.exceptionOrNull()?.let { PaperweightException (" Failed to resolve dev bundle" , it) }
275- )
275+ val message = " Unable to resolve a dev bundle, which is required for paperweight to function."
276+ val ex = PaperweightException (message, hasDevBundle.exceptionOrNull())
277+ throw problems.reporter.throwing {
278+ severity(Severity .ERROR )
279+ id(" paperweight-userdev-cannot-resolve-dev-bundle" , message)
280+ solution(
281+ " Add a dev bundle to the 'paperweightDevelopmentBundle' configuration (the dependencies.paperweight extension can" +
282+ " help with this), and ensure there is a repository to resolve it from (the Paper repository is used by default)."
283+ )
284+ withException(ex)
285+ }
276286 }
277287 }
278288
0 commit comments