Skip to content

Commit

Permalink
Fix some configuration cache violations (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish authored Mar 19, 2024
1 parent 4fec997 commit 287df22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sourceSets {
}

group 'net.neoforged.gradleutils'
version '3.0.0-alpha.11'
version '3.0.0-alpha.12'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ abstract class GradleUtilsExtension {
this.gitInfo = objects.mapProperty(String, String)
.convention(rawInfo.map { it.gitInfo })

final possibleSecring = providers.gradleProperty('signing.secretKeyRingFile')
shouldSign.convention(project.provider { (System.getenv('GPG_PRIVATE_KEY') || System.getenv('GPG_SUBKEY')) || possibleSecring.getOrNull() })
shouldSign.convention(
providers.environmentVariable('GPG_PRIVATE_KEY')
.orElse(providers.environmentVariable('GPG_SUBKEY'))
.orElse(providers.gradleProperty('signing.secretKeyRingFile'))
.map { true }
.orElse(false)
)

// Set up reporting of published maven artifacts
def reportingServiceProvider = project.getGradle().getSharedServices().registerIfAbsent(
Expand All @@ -95,20 +100,22 @@ abstract class GradleUtilsExtension {
}
)
project.tasks.withType(AbstractPublishToMaven).configureEach {
configureRecordMavenPublication(it, reportingServiceProvider)
configureRecordMavenPublication(it, reportingServiceProvider, providers)
}
}

/*
* Reconfigures a publish task to record its published publication in the shared build service for
* generating report at the end of the build.
*/
private static void configureRecordMavenPublication(AbstractPublishToMaven configureTask, Provider<ReportMavenPublications> serviceProvider) {
private static void configureRecordMavenPublication(AbstractPublishToMaven configureTask, Provider<ReportMavenPublications> serviceProvider, ProviderFactory providerFactory) {
configureTask.usesService(serviceProvider)
Provider<String> groupId = providerFactory.provider {configureTask.publication.groupId}
Provider<String> artifactId = providerFactory.provider {configureTask.publication.artifactId}
Provider<String> version = providerFactory.provider {configureTask.publication.version}
configureTask.doLast("recordPublication") { task ->
def publication = ((AbstractPublishToMaven) task).publication
def reportingService = serviceProvider.get()
reportingService.record(publication.groupId, publication.artifactId, publication.version)
reportingService.record(groupId.get(), artifactId.get(), version.get())
}
}

Expand Down

0 comments on commit 287df22

Please sign in to comment.