Buck: buck project
Support Ukraine. Help Provide Humanitarian Aid to Ukraine.

buck project

This command generates the configuration files for an IDE to work with the project. This command creates files in-place in the repository, which is unlike other Buck commands whose output is removed by buck clean. As a result, it is a good idea to add these generated files to the list of ignored files by your choice of source control. IDE-specific details are discussed in each section below.

You can use this command by itself to generate a project for the entire repository.

buck project

You can also use this command to build a project slice (a project that represents a subset of the repository). You can pass any number of build targets or build target patterns to the command. The constructed project slice will contain the specified targets and their dependencies. This is useful for large repositories.

buck project //java/...

Common Parameters

  • --ide Specifies which IDE to create the project for. When using a project slice, Buck tries to determine what type of IDE to use automatically based on the build targets provided. Sometimes it is not possible to determine the type of IDE. You can specify the default ide in the [project] section of your .buckconfig file.
  • --without-tests Indicates that Buck should build a project slice without tests (the default is to include tests on *_library and *_binary rules).
  • --without-dependencies-tests Indicates that Buck should build a project slice with the tests of the specified targets only.
  • --exclude-artifacts Don't include references to the artifacts created by compiling a target in the module representing that target. This can improve indexing times, but will mean generated code does not show up in the ide. For example R files for Android.
  • --remove-unused-ij-libraries After generating an IntelliJ project remove all IntelliJ libraries that are not used in the project.

Supported IDEs

IntelliJ

This command processes all of the build files whose targets were specified and uses them to generate the configuration files for an IDE. The generated files include:

  • .idea/libraries/*.xml, each of which defines a library in IntelliJ. A library always corresponds to a prebuilt_jar.
  • .iml files, each of which defines a module in IntelliJ. A module can depend on other modules, as well as libraries. It should be noted that although Buck allows multiple build targets per build file, IntelliJ's modules are only defined at the directory level. This means that you may find IntelliJ flagging compilation errors because of missing dependencies of classes outside of your project slice, but which happen to be in the same directory as classes within the slice.
  • .idea/modules.xml, which lists all of the IntelliJ modules in the project.

Xcode

This command processes each apple_binary, apple_bundle, and apple_library specified, and uses them to generate the files and directories that Xcode needs. The generated folders include:

  • For each build target, an *.xcworkspace directory that represents the workspace and contains one or more schemes.
  • For each build target and its dependencies, an *.xcodeproj directory that represents the project. These generated projects are only buildable within the generated workspace.

Parameters

  • --combined-project Indicates that Buck should build a single monoproject for all build targets specified.
  • --project-schemes Enables the generation of separate schemes for all projects included in the generated workspace. Each project's scheme is constrained to the set of build and test targets that are members or deps of the associated project. You can specify the default value using by adding project_schemes = true to the[project] section of your .buckconfig file.

Go IDEs

Go IDEs, such as Visual Studio Code and GoLand, use the go build command to build Go code. This command requires a proper layout of source code under GOPATH. However, Buck puts generated code in buck-out, which go build does not understand. The project command copies generated Go packages from buck-out and arranges them in the same layout as their import paths.

Parameters

  • --project_path The directory to copy the generated code to. If not specified, the project command copies it to \/\/vendor, or \/\/src/vendor if it exists.