public final class BuildParameterBuilder
extends java.lang.Object
This builder will take into account the "lib" and "build" classpaths
that points to JAR files when determining which JARs are added as sources
and which JARs are added as part of model discovery. This is determined
based on the value provided for projectionSource
.
If projectionSource
is not set or set to "source", then classes
will be loaded using the lib and build classpath. However, models are
discovered only using the lib classpath, ensuring that consumers of the
generated JAR can find the required models using only the declared
dependencies of this package.
If projectionSource
is not set to something other than
"source", then we build the model and discover models using only the build
classpath. This provides a layer of isolation between the sources that
created a projection from the downstream consumers of the projected model.
projectionSourceTags
can be provided to find JARs in the build
classpath that have a META-INF/MANIFEST.MF "Smithy-Tags" value that matches
one or more of the provided tags. This is used to select which models from
your dependencies should be considered "sources" so that they show up in
the JAR you're projecting.
Modifier and Type | Class and Description |
---|---|
static interface |
BuildParameterBuilder.ClassPathTagMatcher
Interface used to query a classpath for the given projection sources tags.
|
static class |
BuildParameterBuilder.JarFileClassPathTagMatcher
Finds JARs by opening each JAR in the classpath and looking for
"Smithy-Tags" in the META-INF/MANIFEST.MF file.
|
static class |
BuildParameterBuilder.Result
Result class used to build source and projection JARs.
|
Constructor and Description |
---|
BuildParameterBuilder() |
Modifier and Type | Method and Description |
---|---|
BuildParameterBuilder |
addConfig(java.lang.String pathToConfig)
Adds a configuration file to the builder.
|
BuildParameterBuilder |
addConfigIfExists(java.lang.String pathToConfig)
Adds a configuration file to the builder only if it exists.
|
BuildParameterBuilder |
addExtraArgs(java.lang.String... args)
Adds extra arguments to the CLI arguments before positional arguments.
|
BuildParameterBuilder |
addSourcesIfExists(java.util.Collection<java.lang.String> sources)
Adds a collection of "source" model files only if they exist.
|
BuildParameterBuilder |
allowUnknownTraits(boolean allowUnknownTraits)
Ignores unknown traits when building models.
|
BuildParameterBuilder.Result |
build()
Computes the result object that is used when running smithy build.
|
BuildParameterBuilder |
buildClasspath(java.lang.String buildClasspath)
Sets the build classpath.
|
BuildParameterBuilder |
discover(boolean discover)
Enables model discovery.
|
BuildParameterBuilder |
libClasspath(java.lang.String libClasspath)
Sets the lib classpath.
|
BuildParameterBuilder |
output(java.lang.String output)
Sets the optional output directory.
|
BuildParameterBuilder |
plugin(java.lang.String plugin)
Ensures that only the given plugin is built in each projection.
|
BuildParameterBuilder |
projection(java.lang.String projection)
Ensures that only the given projection is built.
|
BuildParameterBuilder |
projectionSource(java.lang.String projectionSource)
Sets the name of the projection being built as a source.
|
BuildParameterBuilder |
projectionSourceTags(java.util.Collection<java.lang.String> projectionSourceTags)
Sets the tags to find in the build classpath when projecting a JAR.
|
BuildParameterBuilder |
projectionSourceTags(java.lang.String projectionSourceTags)
Sets the tags to find in the build classpath when projecting a JAR.
|
BuildParameterBuilder |
sources(java.util.Collection<java.lang.String> sources)
Adds a collection of "source" model files.
|
BuildParameterBuilder |
tagMatcher(BuildParameterBuilder.ClassPathTagMatcher tagMatcher)
Sets the implementation used to find JARs with the given tags.
|
public BuildParameterBuilder projectionSource(java.lang.String projectionSource)
This means that the given projection is used to populate a build artifact (for example, a JAR being built by Gradle).
projectionSource
- Projection name.public BuildParameterBuilder sources(java.util.Collection<java.lang.String> sources)
sources
- Sources to add.public BuildParameterBuilder addSourcesIfExists(java.util.Collection<java.lang.String> sources)
sources
- Sources to add.public BuildParameterBuilder buildClasspath(java.lang.String buildClasspath)
buildClasspath
- Classpath to set.public BuildParameterBuilder libClasspath(java.lang.String libClasspath)
libClasspath
- Classpath to set.public BuildParameterBuilder projectionSourceTags(java.lang.String projectionSourceTags)
Tags can only be provided if projectionSource
has been set to
something other than "source".
projectionSourceTags
- Comma separated list of projection tags.public BuildParameterBuilder projectionSourceTags(java.util.Collection<java.lang.String> projectionSourceTags)
Tags can only be provided if projectionSource
has been set to
something other than "source".
projectionSourceTags
- Projection tags.public BuildParameterBuilder tagMatcher(BuildParameterBuilder.ClassPathTagMatcher tagMatcher)
A default implementation that loads JARs is automatically used if an explicit implementation is not specified. You probably only need to provide a custom implementation for testing.
tagMatcher
- Tag matching implementation.public BuildParameterBuilder addConfig(java.lang.String pathToConfig)
pathToConfig
- Path to the configuration file.public BuildParameterBuilder addConfigIfExists(java.lang.String pathToConfig)
This method is ignored if the file is null, empty, or does not exist.
pathToConfig
- Path to the configuration file.public BuildParameterBuilder output(java.lang.String output)
output
- Optional output directory to set.public BuildParameterBuilder projection(java.lang.String projection)
This is not the same as calling projectionSource
.
projection
- Projection to build, excluding others.public BuildParameterBuilder plugin(java.lang.String plugin)
plugin
- Plugin to build, excluding others.public BuildParameterBuilder discover(boolean discover)
discover
- Set to true to enable model discovery.public BuildParameterBuilder allowUnknownTraits(boolean allowUnknownTraits)
allowUnknownTraits
- Set to true to allow unknown traits.public BuildParameterBuilder addExtraArgs(java.lang.String... args)
args
- Arguments to add.public BuildParameterBuilder.Result build()