Class BuildParameterBuilder
- java.lang.Object
-
- software.amazon.smithy.cli.BuildParameterBuilder
-
public final class BuildParameterBuilder extends java.lang.ObjectThis builder can be used to build up a Smithy CLI command to run `smithy build`.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
projectionSourceis 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
projectionSourceis 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.projectionSourceTagscan 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
Nested Classes Modifier and Type Class Description static interfaceBuildParameterBuilder.ClassPathTagMatcherInterface used to query a classpath for the given projection sources tags.static classBuildParameterBuilder.JarFileClassPathTagMatcherFinds JARs by opening each JAR in the classpath and looking for "Smithy-Tags" in the META-INF/MANIFEST.MF file.static classBuildParameterBuilder.ResultResult class used to build source and projection JARs.
-
Constructor Summary
Constructors Constructor Description BuildParameterBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuildParameterBuilderaddConfig(java.lang.String pathToConfig)Adds a configuration file to the builder.BuildParameterBuilderaddConfigIfExists(java.lang.String pathToConfig)Adds a configuration file to the builder only if it exists.BuildParameterBuilderaddExtraArgs(java.lang.String... args)Adds extra arguments to the CLI arguments before positional arguments.BuildParameterBuilderaddSourcesIfExists(java.util.Collection<java.lang.String> sources)Adds a collection of "source" model files only if they exist.BuildParameterBuilderallowUnknownTraits(boolean allowUnknownTraits)Ignores unknown traits when building models.BuildParameterBuilder.Resultbuild()Computes the result object that is used when running smithy build.BuildParameterBuilderbuildClasspath(java.lang.String buildClasspath)Sets the build classpath.BuildParameterBuilderdiscover(boolean discover)Enables model discovery.BuildParameterBuilderlibClasspath(java.lang.String libClasspath)Sets the lib classpath.BuildParameterBuilderoutput(java.lang.String output)Sets the optional output directory.BuildParameterBuilderplugin(java.lang.String plugin)Ensures that only the given plugin is built in each projection.BuildParameterBuilderprojection(java.lang.String projection)Ensures that only the given projection is built.BuildParameterBuilderprojectionSource(java.lang.String projectionSource)Sets the name of the projection being built as a source.BuildParameterBuilderprojectionSourceTags(java.lang.String projectionSourceTags)Sets the tags to find in the build classpath when projecting a JAR.BuildParameterBuilderprojectionSourceTags(java.util.Collection<java.lang.String> projectionSourceTags)Sets the tags to find in the build classpath when projecting a JAR.BuildParameterBuildersources(java.util.Collection<java.lang.String> sources)Adds a collection of "source" model files.BuildParameterBuildertagMatcher(BuildParameterBuilder.ClassPathTagMatcher tagMatcher)Sets the implementation used to find JARs with the given tags.
-
-
-
Method Detail
-
projectionSource
public BuildParameterBuilder projectionSource(java.lang.String 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
public BuildParameterBuilder sources(java.util.Collection<java.lang.String> sources)
Adds a collection of "source" model files.- Parameters:
sources- Sources to add.- Returns:
- Returns the builder.
-
addSourcesIfExists
public BuildParameterBuilder addSourcesIfExists(java.util.Collection<java.lang.String> sources)
Adds a collection of "source" model files only if they exist.- Parameters:
sources- Sources to add.- Returns:
- Returns the builder.
-
buildClasspath
public BuildParameterBuilder buildClasspath(java.lang.String buildClasspath)
Sets the build classpath.- Parameters:
buildClasspath- Classpath to set.- Returns:
- Returns the builder.
-
libClasspath
public BuildParameterBuilder libClasspath(java.lang.String libClasspath)
Sets the lib classpath.- Parameters:
libClasspath- Classpath to set.- Returns:
- Returns the builder.
-
projectionSourceTags
public BuildParameterBuilder projectionSourceTags(java.lang.String projectionSourceTags)
Sets the tags to find in the build classpath when projecting a JAR.Tags can only be provided if
projectionSourcehas been set to something other than "source".- Parameters:
projectionSourceTags- Comma separated list of projection tags.- Returns:
- Returns the builder.
-
projectionSourceTags
public BuildParameterBuilder projectionSourceTags(java.util.Collection<java.lang.String> projectionSourceTags)
Sets the tags to find in the build classpath when projecting a JAR.Tags can only be provided if
projectionSourcehas been set to something other than "source".- Parameters:
projectionSourceTags- Projection tags.- Returns:
- Returns the builder.
-
tagMatcher
public BuildParameterBuilder tagMatcher(BuildParameterBuilder.ClassPathTagMatcher 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
public BuildParameterBuilder addConfig(java.lang.String pathToConfig)
Adds a configuration file to the builder.- Parameters:
pathToConfig- Path to the configuration file.- Returns:
- Returns the builder.
-
addConfigIfExists
public BuildParameterBuilder addConfigIfExists(java.lang.String pathToConfig)
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
public BuildParameterBuilder output(java.lang.String output)
Sets the optional output directory.- Parameters:
output- Optional output directory to set.- Returns:
- Returns the builder.
-
projection
public BuildParameterBuilder projection(java.lang.String 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
public BuildParameterBuilder plugin(java.lang.String 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
public BuildParameterBuilder discover(boolean discover)
Enables model discovery.- Parameters:
discover- Set to true to enable model discovery.- Returns:
- Returns the builder.
-
allowUnknownTraits
public BuildParameterBuilder allowUnknownTraits(boolean allowUnknownTraits)
Ignores unknown traits when building models.- Parameters:
allowUnknownTraits- Set to true to allow unknown traits.- Returns:
- Returns the builder.
-
addExtraArgs
public BuildParameterBuilder addExtraArgs(java.lang.String... args)
Adds extra arguments to the CLI arguments before positional arguments.- Parameters:
args- Arguments to add.- Returns:
- Returns the builder.
-
build
public BuildParameterBuilder.Result build()
Computes the result object that is used when running smithy build.- Returns:
- Returns the computed result.
-
-