Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle caching #24

Open
Rattlyy opened this issue Jan 30, 2025 · 0 comments · May be fixed by #26
Open

Gradle caching #24

Rattlyy opened this issue Jan 30, 2025 · 0 comments · May be fixed by #26

Comments

@Rattlyy
Copy link

Rattlyy commented Jan 30, 2025

Porting here the issue from the old repo. I tried merging the code but I saw some changes, i'll attach my patch here.

Subject: [PATCH] fix configuration cache for paper plugin
---
Index: src/main/kotlin/net/minecrell/pluginyml/GeneratePluginDescription.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/kotlin/net/minecrell/pluginyml/GeneratePluginDescription.kt b/src/main/kotlin/net/minecrell/pluginyml/GeneratePluginDescription.kt
--- a/src/main/kotlin/net/minecrell/pluginyml/GeneratePluginDescription.kt	(revision b79c47a1ce38a48e26ed98cbf862181dbd4fcb90)
+++ b/src/main/kotlin/net/minecrell/pluginyml/GeneratePluginDescription.kt	(revision fdfdda783e63c6ca3a29aeae7a6982ce4c1ed056)
@@ -35,16 +35,13 @@
 import com.fasterxml.jackson.module.kotlin.registerKotlinModule
 import org.gradle.api.DefaultTask
 import org.gradle.api.NamedDomainObjectCollection
-import org.gradle.api.artifacts.repositories.MavenArtifactRepository
 import org.gradle.api.artifacts.repositories.UrlArtifactRepository
 import org.gradle.api.artifacts.result.ResolvedComponentResult
 import org.gradle.api.file.DirectoryProperty
+import org.gradle.api.provider.ListProperty
+import org.gradle.api.provider.MapProperty
 import org.gradle.api.provider.Property
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.Nested
-import org.gradle.api.tasks.Optional
-import org.gradle.api.tasks.OutputDirectory
-import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.*
 
 abstract class GeneratePluginDescription : DefaultTask() {
 
@@ -54,6 +51,9 @@
     @get:Input
     abstract val librariesJsonFileName: Property<String>
 
+    @get:Input
+    abstract val repos: MapProperty<String, String>
+
     @get:Input
     @get:Optional
     abstract val librariesRootComponent: Property<ResolvedComponentResult>
@@ -74,8 +74,12 @@
 
         val module = SimpleModule()
         @Suppress("UNCHECKED_CAST") // Too stupid to figure out the generics here...
-        module.addSerializer(StdDelegatingSerializer(NamedDomainObjectCollection::class.java,
-            NamedDomainObjectCollectionConverter as Converter<NamedDomainObjectCollection<*>, *>))
+        module.addSerializer(
+            StdDelegatingSerializer(
+                NamedDomainObjectCollection::class.java,
+                NamedDomainObjectCollectionConverter as Converter<NamedDomainObjectCollection<*>, *>
+            )
+        )
         module.addSerializer(StdDelegatingSerializer(UrlArtifactRepository::class.java, UrlArtifactRepositoryConverter))
 
         val mapper = ObjectMapper(factory)
@@ -86,9 +90,8 @@
         mapper.writeValue(outputDirectory.file(fileName).get().asFile, pluginDescription)
 
         if (pluginDescription.generateLibrariesJson) {
-            val repos = this.project.repositories.withType(MavenArtifactRepository::class.java)
             val dependencies = librariesRootComponent.orNull.collectLibraries()
-            val pluginLibraries = PluginLibraries(repos, dependencies)
+            val pluginLibraries = PluginLibraries(repos.get(), dependencies)
 
             val jsonMapper = ObjectMapper()
                 .registerKotlinModule()
@@ -110,7 +113,7 @@
     }
 
     data class PluginLibraries(
-        val repositories: NamedDomainObjectCollection<MavenArtifactRepository>,
+        val repositories: Map<String, String>,
         val dependencies: List<String>
     )
 
Index: src/main/kotlin/net/minecrell/pluginyml/PlatformPlugin.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/kotlin/net/minecrell/pluginyml/PlatformPlugin.kt b/src/main/kotlin/net/minecrell/pluginyml/PlatformPlugin.kt
--- a/src/main/kotlin/net/minecrell/pluginyml/PlatformPlugin.kt	(revision b79c47a1ce38a48e26ed98cbf862181dbd4fcb90)
+++ b/src/main/kotlin/net/minecrell/pluginyml/PlatformPlugin.kt	(revision fdfdda783e63c6ca3a29aeae7a6982ce4c1ed056)
@@ -26,6 +26,7 @@
 
 import org.gradle.api.Plugin
 import org.gradle.api.Project
+import org.gradle.api.artifacts.repositories.MavenArtifactRepository
 import org.gradle.api.artifacts.result.ResolvedComponentResult
 import org.gradle.api.plugins.JavaPlugin
 import org.gradle.api.tasks.SourceSet
@@ -34,7 +35,8 @@
 import org.gradle.kotlin.dsl.register
 import org.gradle.kotlin.dsl.withType
 
-abstract class PlatformPlugin<T : PluginDescription>(private val platformName: String, private val fileName: String) : Plugin<Project> {
+abstract class PlatformPlugin<T : PluginDescription>(private val platformName: String, private val fileName: String) :
+    Plugin<Project> {
 
     protected abstract fun createExtension(project: Project): T
 
@@ -59,6 +61,10 @@
                 fileName.set(this@PlatformPlugin.fileName)
                 librariesJsonFileName.set("$prefix-libraries.json")
                 librariesRootComponent.set(libraries.incoming.resolutionResult.root)
+                repos.set(
+                    project.repositories.withType(MavenArtifactRepository::class.java)
+                        .associate { Pair(it.name, it.url.toString()) }
+                )
                 outputDirectory.set(generatedResourcesDirectory)
                 pluginDescription.set(provider {
                     setDefaults(project, description)
@rainbowdashlabs rainbowdashlabs linked a pull request Jan 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant