Skip to content

Commit

Permalink
Move DownloadService name to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Nov 17, 2023
1 parent daab4fa commit 1d88d33
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PaperweightCore : Plugin<Project> {

val ext = target.extensions.create(PAPERWEIGHT_EXTENSION, PaperweightCoreExtension::class, target)

target.gradle.sharedServices.registerIfAbsent("download", DownloadService::class) {}
target.gradle.sharedServices.registerIfAbsent(DOWNLOAD_SERVICE_NAME, DownloadService::class) {}

target.tasks.register<Delete>("cleanCache") {
group = "paper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ const val IVY_REPOSITORY = "$PAPER_PATH/ivyRepository"

const val RELOCATION_EXTENSION = "relocation"

const val DOWNLOAD_SERVICE_NAME = "paperweightDownloadService"

fun paperSetupOutput(name: String, ext: String) = "$SETUP_CACHE/$name.$ext"
fun Task.paperTaskOutput(ext: String) = paperTaskOutput(name, ext)
fun paperTaskOutput(name: String, ext: String) = "$TASK_CACHE/$name.$ext"
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ inline fun <reified T : Task> TaskContainer.configureTask(name: String, noinline

@Suppress("UNCHECKED_CAST")
val Project.download: Provider<DownloadService>
get() = gradle.sharedServices.registrations.getByName("download").service as Provider<DownloadService>
get() = gradle.sharedServices.registrations.getByName(DOWNLOAD_SERVICE_NAME).service as Provider<DownloadService>

fun commentRegex(): Regex {
return Regex("\\s*#.*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PaperweightPatcher : Plugin<Project> {

val patcher = target.extensions.create(PAPERWEIGHT_EXTENSION, PaperweightPatcherExtension::class, target)

target.gradle.sharedServices.registerIfAbsent("download", DownloadService::class) {}
target.gradle.sharedServices.registerIfAbsent(DOWNLOAD_SERVICE_NAME, DownloadService::class) {}

target.tasks.register<Delete>("cleanCache") {
group = "paperweight"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class PaperweightUser : Plugin<Project> {
null
}

target.gradle.sharedServices.registerIfAbsent("download", DownloadService::class) {}
target.gradle.sharedServices.registerIfAbsent(DOWNLOAD_SERVICE_NAME, DownloadService::class) {}

val cleanAll = target.tasks.register<Delete>("cleanAllPaperweightUserdevCaches") {
group = "paperweight"
Expand Down

0 comments on commit 1d88d33

Please sign in to comment.