WireRun(sourcePath: List<Location>, protoPath: List<Location> = listOf(), treeShakingRoots: List<String> = listOf("*"), treeShakingRubbish: List<String> = listOf(), since: String? = null, until: String? = null, targets: List<Target>, proto3Preview: Boolean = false)
An invocation of the Wire compiler. Each invocation performs the following operations:
.proto files directly from the file system or from archive files (ie. .jar
and .zip files). This will also load imported .proto files from either the sourcePath
or protoPath. The collection of loaded type declarations is called a schema.The sourcePath and protoPath lists contain locations that are of the following forms:
.proto files..proto files. Typically this is a directory
ending in src/main/proto..zip and .jar archives that contain a tree of .proto files. Typically this
is a .jar file from a Maven repository.When one .proto message imports another, the import is resolved from the base of each location
and archive. If the build is in the unfortunate situation where an import could be resolved by
multiple files, whichever was listed first takes precedence.
Although the content and structure of sourcePath and protoPath are the same, only types defined in sourcePath are used to generate sources.
Matching Packages, Types, and MembersThe treeShakingRoots, treeShakingRubbish, Target.includes and Target.excludes lists contain strings that select proto types and members. Strings in these lists are in one of these forms:
.*, like squareup.dinosaurs.*. This matches types defined in the
package and its descendant packages. A lone asterisk * matches all packages.squareup.dinosaurs.Dinosaur. Types may be messages, enums,
or services.squareup.dinosaurs.Dinosaur#name. These are type names
followed by # followed by a member name. Members may be message fields, enum constants, or
service RPCs.It is an error to specify mutually-redundant values in any of these lists. For example, the list
[squareup.dinosaurs, squareup.dinosaurs.Dinosaur] is invalid because the second element is
already matched by the first.
Every element in each lists must apply to at least one declaration. Otherwise that option is unnecessary and a possible typo.
ComposabilityThere are many moving parts in this system! For most applications it is safe to use sourcePath and targets only. The other options are for the benefit of large and modular applications.
These .proto files are used for checking dependencies only. It is assumed that the sources for
these protos are generated elsewhere.
Tree shaking can be used to create a small-as-possible generated footprint even if the source declarations are large. This works like ProGuard and other code shrinking compilers: it allows you to benefit from a shared codebase without creating a large artifact.
If your project is already using generated Java, it’s difficult to switch to generated Kotlin. Instead of switching everything over at once you can use multiple targets to switch over incrementally. Targets consume their types; subsequent targets get whatever types are left over.