-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Artifact is not re-created when it was manually removed #342
Comments
There is some metadata associated with each rule saved in buck-out, Buck always assumes the metadata and the built artefacts in buck-out are in a consistent state, so modifying the files in buck-out manually will break Buck in weird ways. Why are you deleting the jar file? Is there a particular use case? |
Let's say we have some The magic Python script
Probably |
Unfortunately there isn't.
Buck assumes all rules declare all their inputs and only depend on them. We're about to introduce more advanced caching that absolutely depends on this. Having side effects in rules will always cause problems for Buck. |
Thanks for the clarification. |
I added a Python script to overcome this design limitation and replay Buck command manually: [1]. One improvement for this specific use case would be to add support for '--resolve-macros' option to
invocation. @shs96c any comments on this requirement? @sdwilsh suggested to ask you before filing a feature request ;-) |
I don't think that script is a good idea: what it's working around is not a design limitation as much as it's a design prerequisite. If you need to do side effects together with the build it's better to do them at the end of the build, outside of Buck, rather than during the build inside the rule executions. |
I see your point. In this specific case, we are using But let's say that some one would like to contribute built-in Buck rule for Maven deployment, with So let's assume somehow you are able to configure it to either push to local or remote Maven repository. Let's call the outcome of this operation, the file is under "$HOME/.m2/repository/..." or on Google storage bucket, or whatever as a "side effect", because we left I'm curious how this
So that a simple use case like this can be done from within Buck:
So that the last Or are you saying, that |
It either has to be implemented outside of Buck, or as a separate command. You mention I can see a There's also been some discussion of adding an attribute for maven coordinates on In that vein, you could add a maven coordinate to a I think the main thing here is we absolutely do not want side effects during the build. We can however introduce new operations that depend on building that have side effects. Or new operations that have side effects that have to be run manually before building, and whose effects must be controlled explicitly by the user, so that they can check the results into source control, or do anything they want with them. But the build itself must remain pure. |
There's someone working on maven interop right now (we should see some diffs land soon). We'll probably either extend "buck install" or add a new command to handle pushing artifacts to maven central. If you're interested in hacking on it, I think the first step would be to add an optional "maven_coord", "binary_sha1" and "source_sha1" to "prebuilt_jar" and allow us to (optionally) download the jar by adding "remote_file" rules into the action graph if necessary. There's still some thinking to be done on minimizing the number of artifacts that we'd push to a maven repo --- naively, you can imagine one artifact per buck target, but that would be a nightmare to maintain, and I'd not want to have to handle versioning :) Conceptually, Buck is a build tool, rather than SDLC tool. More concretely, "buck build" is just for the assembly of artifacts: side-effects break the functional model it's based on. Other phases of an artifact's lifecycle are handled by separate commands, and support side-effects. For example, things like deploying or running commands are handled by "buck install", "buck run" and "buck test" respectively. |
Buck extensively uses caching and storing metadata in buck-out directory, so that it's not possible per design to re-trigger the execution of custom rule, without wiping out the whole buck-out directory. See also the discussion on this issue: [1]. The implementation of Maven deployment as a custom build rule with a side effect is wrong approach to start with. It was only done as a workaround, because buck doesn't offer `install` or `publish` command that must not be free of side effects like it's the case with `build` command. Having side effects with `build` command breaks bucks model. As workaround for now add standalone Python script, that re-uses Buck api_{deploy|install} targets, resolves $(location <target>) macros and executes the deployment by calling mvn.py utility directly: $ tools/maven/api.py {deploy,install} Dry run mode is supported as well: $ tools/maven/api.py -n {deploy,install} [1] facebook/buck#342 Change-Id: I7fb86ad6967a1fa1e7ac842ba5e0e8cf0103b773
So I disabled watchman for now, and have a simple
java_library()
rule with jar outcome, as described in #341:Running it creates the artifact
buck-out/gen/plugins/foo/lib__foo__output/foo.jar
:However, when this artifact is removed for some reasons, I would expect Buck invocation re-creates it, but it doesn't happen:
Even when I remove the cache entry for this target, it's not re-created:
The only known way to recover from here is to run
buck clean
:The text was updated successfully, but these errors were encountered: