Skip to content

Commit

Permalink
Allow inferring the version from Gradle when using config cache.
Browse files Browse the repository at this point in the history
Oddly it seems to work now, not sure what issue I was having before.

Closes #57
  • Loading branch information
modmuss50 committed Sep 7, 2024
1 parent 506f4f3 commit 5052238
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
11 changes: 0 additions & 11 deletions src/main/kotlin/me/modmuss50/mpp/ModPublishExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import org.gradle.api.ExtensiblePolymorphicDomainObjectContainer
import org.gradle.api.NamedDomainObjectProvider
import org.gradle.api.PolymorphicDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.configuration.BuildFeatures
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.TaskProvider
import java.lang.IllegalStateException
import java.nio.file.Path
import javax.inject.Inject
import kotlin.reflect.KClass

abstract class ModPublishExtension(val project: Project) : PublishOptions {
Expand All @@ -33,9 +30,6 @@ abstract class ModPublishExtension(val project: Project) : PublishOptions {
abstract val dryRun: Property<Boolean>
val platforms: ExtensiblePolymorphicDomainObjectContainer<Platform> = project.objects.polymorphicDomainObjectContainer(Platform::class.java)

@get:Inject
protected abstract val buildFeatures: BuildFeatures

init {
dryRun.convention(false)
maxRetries.convention(3)
Expand Down Expand Up @@ -217,11 +211,6 @@ abstract class ModPublishExtension(val project: Project) : PublishOptions {

// Returns the project version as a string, or throws if not set.
private fun getProjectVersion(): String {
// TODO remove this when there is a config caching friendly way to get the version
if (buildFeatures.getConfigurationCache().getActive().get()) {
throw IllegalStateException("Cannot infer project version when configuration cache, please set the version explicitly in the publishMods block.")
}

val version = project.version

if (version == Project.DEFAULT_VERSION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ModrinthTest : IntegrationTest {
val result = gradleTest()
.buildScript(
"""
version = "1.0.0"
publishMods {
changelog = "Hello!"
version = "1.0.0"
type = BETA
// Common options that can be re-used between diffrent modrinth tasks
Expand Down

0 comments on commit 5052238

Please sign in to comment.