Copilot commented on code in PR #429: URL: https://github.com/apache/grails-static-website/pull/429#discussion_r2873442485
########## pages/.well-known/atproto-did: ########## @@ -0,0 +1 @@ +did:plc:5ad34hau6u4tw25cuh3cewwl Review Comment: This file under `pages/` won’t be published by the current build: `RenderSiteTask.parsePages` only processes `.html` pages, and deployment copies `build/dist` (not `pages/`). Since the DID is already generated into `build/dist/.well-known/atproto-did` by `BskyAtProtoDidTask`, this committed file is redundant and can be misleading—consider removing it or updating the build to explicitly copy raw `.well-known/*` files from `pages/` if that’s the intent. ```suggestion This file under pages/.well-known/ is not used by the current build. The deployable DID file is generated into build/dist/.well-known/atproto-did by BskyAtProtoDidTask. ``` ########## buildSrc/src/main/groovy/website/gradle/tasks/BskyAtProtoDidTask.groovy: ########## @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package website.gradle.tasks + +import groovy.transform.CompileStatic +import org.gradle.api.Project +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.tasks.CacheableTask +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.TaskProvider +import org.yaml.snakeyaml.Yaml +import website.gradle.GrailsWebsiteExtension + +@CompileStatic +@CacheableTask +abstract class BskyAtProtoDidTask extends GrailsWebsiteTask { + + @Internal + final String description = 'Generates the .well-known/atproto-did file for Bsky' + + public static final String NAME = 'genBskyAtProtoDid' + + @InputFile + @PathSensitive(PathSensitivity.RELATIVE) + abstract RegularFileProperty getSocial() + + @OutputFile + abstract RegularFileProperty getBskyAtProtoDid() + + static TaskProvider<BskyAtProtoDidTask> register( + Project project, + GrailsWebsiteExtension siteExt, + String name = NAME + ) { + project.tasks.register(name, BskyAtProtoDidTask) { + it.social.set(siteExt.social) + it.bskyAtProtoDid.set(siteExt.bskyAtProtoDid) + } + } + + @TaskAction + void generateAtProtoDid() { + bskyAtProtoDid.get().asFile.tap { + parentFile.mkdirs() + text = getBskyAtProtoDidText() + } + } + + private Map getSocialProperties() { + File socialFile = social.get().asFile + new Yaml().load(socialFile.newDataInputStream()) as Map + } + + private String getBskyAtProtoDidText() { + socialProperties['bsky']['did'] + } Review Comment: `getBskyAtProtoDidText()` will currently throw a `NullPointerException` (or write an unexpected value) if `social.yml` is missing `bsky` or `did`. Consider validating the parsed YAML structure and failing with a clear `GradleException` that explains which key is missing/invalid. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
