public void execute()

in src/main/java/software/amazon/smithy/gradle/tasks/SmithyBuildJar.java [163:222]


    public void execute() {
        // Configure the task from the extension if things aren't already setup.
        SmithyExtension extension = SmithyUtils.getSmithyExtension(getProject());

        if (projection == null) {
            getLogger().debug("Setting SmithyBuildJar projection from extension: {}", extension.getProjection());
            setProjection(extension.getProjection());
        }

        // Merge tags from the extension into the task.
        projectionSourceTags.addAll(extension.getProjectionSourceTags());

        // Merge or overwrite?
        if (smithyBuildConfigs == null) {
            setSmithyBuildConfigs(extension.getSmithyBuildConfigs());
            getLogger().debug("Setting SmithyBuildJar smithyBuildConfigs from extension: {}", smithyBuildConfigs);
        }

        writeHeading("Running smithy build");

        // Clear out the directories when rebuilding.
        getProject().delete(getSmithyResourceStagingDir().getParentFile().getParentFile());

        BuildParameterBuilder builder = new BuildParameterBuilder();
        // Note: the runtime classpath extends from the compile classpath.
        builder.libClasspath(SmithyUtils.getClasspath(getProject(), RUNTIME_CLASSPATH).getAsPath());
        builder.buildClasspath(SmithyUtils.getBuildscriptClasspath(getProject()).getAsPath());
        builder.projectionSource(getProjection());
        builder.projectionSourceTags(getProjectionSourceTags());
        builder.allowUnknownTraits(getAllowUnknownTraits());

        if (getOutputDirectory() != null) {
            builder.output(getOutputDirectory().getAbsolutePath());
        }

        getSmithyBuildConfigs().forEach(config -> builder.addConfigIfExists(config.getAbsolutePath()));

        if (!getModels().isEmpty()) {
            builder.addSourcesIfExists(getModels().getFiles().stream()
                    .map(File::getAbsolutePath)
                    .collect(Collectors.toList()));
        }

        builder.discover(true);

        BuildParameterBuilder.Result result = builder.build();
        Object[] jars = result.classpath.split(System.getProperty("path.separator"));
        SmithyUtils.executeCli(getProject(), result.args, getProject().files(jars));

        // Copy generated files where they're needed and register source sets.
        try {
            createSourceSets(getOutputDirectory().toPath());
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }

        if (getProject().getTasks().getByName("jar").getEnabled()) {
            copyModelsToStaging();
        }
    }