in src/main/java/software/amazon/smithy/gradle/SmithyPlugin.java [130:159]
private void addCliDependencies(Project project) {
Configuration cli;
if (project.getConfigurations().findByName("smithyCli") != null) {
cli = project.getConfigurations().getByName("smithyCli");
} else {
cli = project.getConfigurations().create("smithyCli")
.extendsFrom(project.getConfigurations().getByName("runtimeClasspath"));
}
// Prefer explicitly set dependency first.
DependencySet existing = cli.getAllDependencies();
if (existing.stream().anyMatch(d -> isMatchingDependency(d, "smithy-cli"))) {
project.getLogger().warn("(using explicitly configured Smithy CLI)");
return;
}
failIfRunningInMainSmithyRepo(project);
String cliVersion = detectCliVersionInDependencies(SmithyUtils.getClasspath(project, "runtimeClasspath"));
if (cliVersion != null) {
project.getLogger().warn("(detected Smithy CLI version {})", cliVersion);
} else {
// Finally, scan the buildScript dependencies for a smithy-model dependency. This
// should always be found because the Gradle plugin has a dependency on it.
cliVersion = scanForSmithyCliVersion(project);
}
project.getDependencies().add(cli.getName(), "software.amazon.smithy:smithy-cli:" + cliVersion);
}