Skip to content

Commit 25bc6bd

Browse files
committed
Require Gradle 8.12 and use Problems API to report dev bundle resolution failure
1 parent df5b8e9 commit 25bc6bd

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

buildSrc/src/main/kotlin/utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.gradle.plugin.devel.PluginDeclaration
1010
fun Configuration.compatibilityAttributes(objects: ObjectFactory) {
1111
attributes {
1212
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
13-
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named("8.11.1"))
13+
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named("8.12"))
1414
}
1515
}
1616

paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/PaperweightUser.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import org.gradle.api.attributes.Bundling
5050
import org.gradle.api.attributes.Category
5151
import org.gradle.api.attributes.LibraryElements
5252
import org.gradle.api.attributes.Usage
53+
import org.gradle.api.problems.Problems
54+
import org.gradle.api.problems.Severity
5355
import org.gradle.api.provider.Provider
5456
import org.gradle.api.tasks.Delete
5557
import 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

Comments
 (0)