mpetuska / npm-publish

Gradle plugin for NPM package publishing. Allows for arbitrary publishing as well as seamless integration with Kotlin JS/MPP plugins.
https://npm-publish.petuska.dev
Apache License 2.0
126 stars 10 forks source link

3.4.0 still has issues with configuration cache #145

Closed andylamax closed 1 year ago

andylamax commented 1 year ago

The publish block looks like that

Tested with kotlin: 1.8.22, 1.9.0
gradle: 8.2,8.2.1
npmPublish {
    organization.set("picortex")
    registries {
        register("github") {
            uri.set("https://npm.pkg.github.com/") // DO NOT REMOVE THE TRAILING SLASH
            authToken.set(System.getenv("GH_TOKEN"))
        }

        register("andylamax") {
            uri.set("http://localhost:1040")
            authToken.set("andylamax")
        }

        register("piCortex") {
            uri.set("http://${picortex.versions.server.ip.get()}:1040")
            authToken.set("andylamax")
        }
    }

    packages {
        val js by getting {
            version.set("${project.version}")
            packageName.set("react")
            readme.set(file("README.md"))
            packageJson {
                types.set("index.d.ts")

                repository {
                    type.set("git")
                    url.set("https://github.com/picortex/picortex.git")
                }

                devDependencies {
                    set("@types/react", kotlinw.versions.react.types.get())
                }
            }
        }
    }
}

When i run ./gradlew publishJsPackageToPicortex, the error becomes

Could not load the value of field `owner` of `dev.petuska.npm.publish.config.RegistryKt$configure$4` bean found in field `capturedArgs` of `java.lang.invoke.SerializedLambda` bean found in field `transformer` of `org.gradle.api.internal.provider.TransformBackedProvider` bean found in field `right` of `org.gradle.api.internal.provider.OrElseProvider` bean found in field `provider` of `org.gradle.api.internal.provider.TransformBackedProvider` bean found in field `provider` of `org.gradle.api.internal.provider.MappingProvider` bean found in field `provider` of `org.gradle.api.internal.provider.MappingProvider` bean found in field `__dry__` of task `:picortex-sdk-react:publishJsPackageToPiCortexRegistry` of type `dev.petuska.npm.publish.task.NpmPublishTask`
mpetuska commented 1 year ago

Thanks for the bugreport. Could you try again with this modified buildconfig?

npmPublish {
    organization.set("picortex")
    registries {
        register("github") {
            uri.set("https://npm.pkg.github.com/") // DO NOT REMOVE THE TRAILING SLASH
            authToken.set(providers.environment("GH_TOKEN"))
        }

        register("andylamax") {
            uri.set("http://localhost:1040")
            authToken.set("andylamax")
        }

        register("piCortex") {
            uri.set(picortex.versions.server.ip.map{ "http://$it:1040"})
            authToken.set("andylamax")
        }
    }

    packages {
        val js by getting {
            version.set("${project.version}")
            packageName.set("react")
            readme.set(file("README.md"))
            packageJson {
                types.set("index.d.ts")

                repository {
                    type.set("git")
                    url.set("https://github.com/picortex/picortex.git")
                }

                devDependencies {
                    set("@types/react", kotlinw.versions.react.types.get())
                }
            }
        }
    }
}
andylamax commented 1 year ago

tried it with

npmPublish {
    organization.set("picortex")
    registries {
        register("github") {
            uri.set("https://npm.pkg.github.com/") // DO NOT REMOVE THE TRAILING SLASH
            //authToken.set(System.getenv("GH_TOKEN"))
            authToken.set(providers.environmentVariable("GH_TOKEN"))
        }

        register("andylamax") {
            uri.set("http://localhost:1040")
            authToken.set("andylamax")
        }

        register("piCortex") {
            //uri.set("http://${picortex.versions.server.ip.get()}:1040")
            uri.set(picortex.versions.server.ip.map { URI.create("http://$it:1040") })
            authToken.set("andylamax")
        }
    }

    packages {
        val js by getting {
            version.set("${project.version}")
            packageName.set("react")
            readme.set(file("README.md"))
            packageJson {
                types.set("index.d.ts")

                repository {
                    type.set("git")
                    url.set("https://github.com/picortex/picortex.git")
                }

                devDependencies {
                    set("@types/react", kotlinw.versions.react.types.get())
                }
            }
        }
    }
}

but still got

Could not load the value of field `owner` of `dev.petuska.npm.publish.config.RegistryKt$configure$4` bean found in field `capturedArgs` of `java.lang.invoke.SerializedLambda` bean found in field `transformer` of `org.gradle.api.internal.provider.TransformBackedProvider` bean found in field `right` of `org.gradle.api.internal.provider.OrElseProvider` bean found in field `provider` of `org.gradle.api.internal.provider.TransformBackedProvider` bean found in field `provider` of `org.gradle.api.internal.provider.MappingProvider` bean found in field `provider` of `org.gradle.api.internal.provider.MappingProvider` bean found in field `__dry__` of task `:picortex-sdk-react:publishJsPackageToPiCortexRegistry` of type `dev.petuska.npm.publish.task.NpmPublishTask`.
mpetuska commented 1 year ago

Ok thanks. That's plenty for me to go on for now.