Skip to content

Declare YamlConfigWriterTask output so it can be used from other tasks.#159

Merged
runningcode merged 1 commit into
runningcode:masterfrom
CristianGM:declare-yaml-writer-output
Aug 14, 2020
Merged

Declare YamlConfigWriterTask output so it can be used from other tasks.#159
runningcode merged 1 commit into
runningcode:masterfrom
CristianGM:declare-yaml-writer-output

Conversation

@CristianGM

Copy link
Copy Markdown
Contributor

I wanted to declare the inputs to (so it would be able to check if it's up-to-date) but:
Caused by: org.gradle.internal.snapshot.ValueSnapshottingException: Could not serialize value of type FlankGradleExtension

In any case this is useful so the yaml can be used as an input for FlankExecutionTask (one of many)

private val fladleDir = projectLayout.fladleDir.get().asFile

@OutputFile
val fladleConfigFile: File = fladleDir.resolve("flank.yml")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to make this simply a property so that it can be lazily evaluated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't creating a File almost free? It's only when you try to access it that it involves the IO.
I can make it lazy but I don't see the point (maybe I'm missing something)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"almost" :D


private val yamlWriter = YamlWriter()

private val fladleDir = projectLayout.fladleDir.get().asFile

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary for this PR, just something to be aware of this will cause overlapping outputs when using multiple configs. I wanted to fix this with: #147
We could create a directory based on the config name to solve this.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be annotated with @Internal? (check if there are build warnings around this)

@CristianGM CristianGM Aug 14, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Internal is not needed because private fields don't generate getters.

I usually make the output configurable, but I'm trying to do the minimum changes to the current behavior or I would make a very big PR.

I like to do something like:

@get:OutputDirectory
val outputDir: DirectoryProperty = objectFactory.directoryProperty().convention(layout.buildDirectory.dir("fladle"))

(the example is with a Directory because I copy&pasted from other plugin I maintain, but in this case it could be simply a file)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i like your approach of making this minimal, we can always fix the other stuff later. thanks!

@runningcode
runningcode merged commit a79aab9 into runningcode:master Aug 14, 2020
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 this pull request may close these issues.

2 participants