private void runTaskWithClasspath(
            BuildOptions buildOptions,
            SmithyBuildConfig smithyBuildConfig,
            Command.Env env,
            Consumer<ClassLoader> consumer
    ) {
        Set<String> dependencies = smithyBuildConfig.getMaven()
                .map(MavenConfig::getDependencies)
                .orElse(Collections.emptySet());

        String dependencyMode = EnvironmentVariable.SMITHY_DEPENDENCY_MODE.get();
        boolean useIsolation = false;
        switch (dependencyMode) {
            case "forbid":
                if (!dependencies.isEmpty()) {
                    throw new DependencyResolverException(String.format(
                            "%s is set to 'forbid', but the following Maven dependencies are defined in "
                                    + "smithy-build.json: %s. Dependencies are forbidden in this configuration.",
                            EnvironmentVariable.SMITHY_DEPENDENCY_MODE,
                            dependencies));
                }
                break;
            case "ignore":
                if (!dependencies.isEmpty()) {
                    LOGGER.warning(() -> String.format(
                            "%s is set to 'ignore', and the following Maven dependencies are defined in "
                                    + "smithy-build.json: %s. If the build fails, then you may need to manually configure "
                                    + "the classpath.",
                            EnvironmentVariable.SMITHY_DEPENDENCY_MODE,
                            dependencies));
                }
                break;
            case "standard":
                useIsolation = !dependencies.isEmpty();
                break;
            default:
                throw new CliError(String.format("Unknown %s setting: '%s'",
                        EnvironmentVariable.SMITHY_DEPENDENCY_MODE,
                        dependencyMode));
        }

        if (useIsolation) {
            long start = System.nanoTime();
            List<Path> files = resolveDependencies(buildOptions,
                    smithyBuildConfig,
                    env,
                    smithyBuildConfig.getMaven().get());
            long end = System.nanoTime();
            LOGGER.fine(() -> "Dependency resolution time in ms: " + ((end - start) / 1000000));
            new IsolatedRunnable(files, env.classLoader(), consumer).run();
            LOGGER.fine(() -> "Command time in ms: " + ((System.nanoTime() - end) / 1000000));
        } else {
            consumer.accept(env.classLoader());
        }
    }
A {@code CommandAction} that runs a wrapped action within a custom classpath.
smithy-cli/src/main/java/software/amazon/smithy/cli/commands/ClasspathAction.java