private static String expand(SourceLocation sourceLocation, String variable) {
            // TODO: Add support for SMITHY_VERSION.
            if (variable.equals("SMITHY_ROOT_DIR")) {
                return SmithyBuildUtils.getCurrentWorkingDirectory().toString();
            }

            String replacement = Optional.ofNullable(System.getProperty(variable))
                    .orElseGet(() -> System.getenv(variable));

            if (replacement == null) {
                throw new SmithyBuildException(String.format(
                        "Unable to expand variable `" + variable + "` to an environment variable or system "
                                + "property: %s",
                        sourceLocation));
            }

            return replacement;
        }
Expands ${NAME} values inside of strings to a {@code System} property
or an environment variable.
smithy-build/src/main/java/software/amazon/smithy/build/model/SmithyBuildUtils.java