private String scanForSmithyCliVersion()

in src/main/java/software/amazon/smithy/gradle/SmithyPlugin.java [190:209]


    private String scanForSmithyCliVersion(Project project) {
        // Finally, scan the buildScript dependencies for a smithy-model dependency. This
        // should be found because the Gradle plugin has a dependency on it.
        for (File jar : project.getBuildscript().getConfigurations().getByName("classpath")) {
            String name = jar.toString();
            int smithyCliPosition = name.lastIndexOf("smithy-cli-");
            if (smithyCliPosition > -1 && name.endsWith(".jar")) {
                String cliVersion = name.substring(
                        smithyCliPosition + "smithy-cli-".length(), name.length() - ".jar".length());
                project.getLogger().warn("(scanned and found a Smithy CLI version {}. "
                                         + "You will need to add an explicit dependency on smithy-model "
                                         + "if publishing a JAR)", cliVersion);
                return cliVersion;
            }
        }

        // This should never happen since the smithy plugin has a dependency on smithy-cli.
        throw new GradleException("Unable to determine a smithy-cli dependency version. Please add an "
                                  + "explicit dependency on smithy-model.");
    }