Class BuildParameterBuilder
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface used to query a classpath for the given projection sources tags.static final class
Finds JARs by opening each JAR in the classpath and looking for "Smithy-Tags" in the META-INF/MANIFEST.MF file.static final class
Result class used to build source and projection JARs. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a configuration file to the builder.addConfigIfExists
(String pathToConfig) Adds a configuration file to the builder only if it exists.addExtraArgs
(String... args) Adds extra arguments to the CLI arguments before positional arguments.addSourcesIfExists
(Collection<String> sources) Adds a collection of "source" model files only if they exist.allowUnknownTraits
(boolean allowUnknownTraits) Ignores unknown traits when building models.build()
Computes the result object that is used when running smithy build.buildClasspath
(String buildClasspath) Sets the build classpath.discover
(boolean discover) Enables model discovery.libClasspath
(String libClasspath) Sets the lib classpath.Sets the optional output directory.Ensures that only the given plugin is built in each projection.projection
(String projection) Ensures that only the given projection is built.projectionSource
(String projectionSource) Sets the name of the projection being built as a source.projectionSourceTags
(String projectionSourceTags) Sets the tags to find in the build classpath when projecting a JAR.projectionSourceTags
(Collection<String> projectionSourceTags) Sets the tags to find in the build classpath when projecting a JAR.sources
(Collection<String> sources) Adds a collection of "source" model files.tagMatcher
(BuildParameterBuilder.ClassPathTagMatcher tagMatcher) Sets the implementation used to find JARs with the given tags.
-
Constructor Details
-
BuildParameterBuilder
public BuildParameterBuilder()
-
-
Method Details
-
projectionSource
Sets the name of the projection being built as a source.This means that the given projection is used to populate a build artifact (for example, a JAR being built by Gradle).
- Parameters:
projectionSource
- Projection name.- Returns:
- Returns the builder.
-
sources
Adds a collection of "source" model files.- Parameters:
sources
- Sources to add.- Returns:
- Returns the builder.
-
addSourcesIfExists
Adds a collection of "source" model files only if they exist.- Parameters:
sources
- Sources to add.- Returns:
- Returns the builder.
-
buildClasspath
Sets the build classpath.- Parameters:
buildClasspath
- Classpath to set.- Returns:
- Returns the builder.
-
libClasspath
Sets the lib classpath.- Parameters:
libClasspath
- Classpath to set.- Returns:
- Returns the builder.
-
projectionSourceTags
Sets the tags to find in the build classpath when projecting a JAR.Tags can only be provided if
projectionSource
has been set to something other than "source".- Parameters:
projectionSourceTags
- Comma separated list of projection tags.- Returns:
- Returns the builder.
-
projectionSourceTags
Sets the tags to find in the build classpath when projecting a JAR.Tags can only be provided if
projectionSource
has been set to something other than "source".- Parameters:
projectionSourceTags
- Projection tags.- Returns:
- Returns the builder.
-
tagMatcher
Sets the implementation used to find JARs with the given tags.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.
- Parameters:
tagMatcher
- Tag matching implementation.- Returns:
- Returns the builder.
-
addConfig
Adds a configuration file to the builder.- Parameters:
pathToConfig
- Path to the configuration file.- Returns:
- Returns the builder.
-
addConfigIfExists
Adds a configuration file to the builder only if it exists.This method is ignored if the file is null, empty, or does not exist.
- Parameters:
pathToConfig
- Path to the configuration file.- Returns:
- Returns the builder.
-
output
Sets the optional output directory.- Parameters:
output
- Optional output directory to set.- Returns:
- Returns the builder.
-
projection
Ensures that only the given projection is built. All other projections are skipped.This is not the same as calling
projectionSource
.- Parameters:
projection
- Projection to build, excluding others.- Returns:
- Returns the builder.
-
plugin
Ensures that only the given plugin is built in each projection. All other plugins are skipped.- Parameters:
plugin
- Plugin to build, excluding others.- Returns:
- Returns the builder.
-
discover
Enables model discovery.- Parameters:
discover
- Set to true to enable model discovery.- Returns:
- Returns the builder.
-
allowUnknownTraits
Ignores unknown traits when building models.- Parameters:
allowUnknownTraits
- Set to true to allow unknown traits.- Returns:
- Returns the builder.
-
addExtraArgs
Adds extra arguments to the CLI arguments before positional arguments.- Parameters:
args
- Arguments to add.- Returns:
- Returns the builder.
-
build
Computes the result object that is used when running smithy build.- Returns:
- Returns the computed result.
-