Skip to content

Commit

Permalink
Fix use of layout.buildDirectory (#949)
Browse files Browse the repository at this point in the history
This is a DirectoryProperty, which in a few places was used or carried
forward as a String without being appropriately converted first.

That resulted in the use and creation of a project-root directory called
`gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, `
which was then used by the `generateJarInfo` and `generateLicenseReport`
tasks.

This fixes it.
  • Loading branch information
jobarr-amzn authored Oct 1, 2024
1 parent c5562bf commit 492323f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ val githubRepositoryUrl = "https://github.com/amazon-ion/ion-java/"
val isReleaseVersion: Boolean = !version.toString().endsWith("SNAPSHOT")
// Workflows triggered by a new release always have a tag ref.
val isReleaseWorkflow: Boolean = (System.getenv("GITHUB_REF") ?: "").startsWith("refs/tags/")
val generatedResourcesDir = "${layout.buildDirectory}/generated/main/resources"
val generatedResourcesDir = layout.buildDirectory.dir("generated/main/resources")

sourceSets {
main {
Expand All @@ -112,7 +112,7 @@ licenseReport {
// though ion-java does not depend on ion-java-cli. By default, the license report generator includes
// the current project (ion-java) and all its subprojects.
projects = arrayOf(project)
outputDir = "${layout.buildDirectory}/reports/licenses"
outputDir = layout.buildDirectory.dir("reports/licenses").get().asFile.path
renderers = arrayOf(InventoryMarkdownReportRenderer(), TextReportRenderer())
// Dependencies use inconsistent titles for Apache-2.0, so we need to specify mappings
filters = arrayOf(
Expand Down Expand Up @@ -473,7 +473,7 @@ tasks {
* for why this is done with a properties file rather than the Jar manifest.
*/
val generateJarInfo by creating<Task> {
val propertiesFile = File("$generatedResourcesDir/${project.name}.properties")
val propertiesFile = generatedResourcesDir.get().file("${project.name}.properties").asFile
doLast {
propertiesFile.parentFile.mkdirs()
val properties = Properties()
Expand Down

0 comments on commit 492323f

Please sign in to comment.