Skip to content

Instantly share code, notes, and snippets.

@sebastienblanc
Created March 2, 2017 09:39
Show Gist options
  • Save sebastienblanc/a0b2db41e4991eb8b5d0186341b45d86 to your computer and use it in GitHub Desktop.
Save sebastienblanc/a0b2db41e4991eb8b5d0186341b45d86 to your computer and use it in GitHub Desktop.
private List<SpringBootDependencyDTO> initDependencies() throws IOException {
List<SpringBootDependencyDTO> list = new ArrayList<>();
Map data;
// use http client to call start.spring.io that creates the project
OkHttpClient client = createOkHttpClient();
Request request = new Request.Builder().url(springBootInitializrURL.getValue()).build();
Response response = client.newCall(request).execute();
data = jsonToMap(response.body().string());
Map dependencies = (Map) data.get("dependencies");
List deps = (List) dependencies.get("values");
for (Object dep : deps) {
Map group = (Map) dep;
String groupName = (String) group.get("name");
List content = (List) group.get("values");
for (Object row : content) {
Map item = (Map) row;
String id = (String) item.get("id");
String name = (String) item.get("name");
String description = (String) item.get("description");
list.add(new SpringBootDependencyDTO(groupName, id, name, description));
// are we at apache camel, then inject other Camel modules that are not in the spring-boot-application yet
if ("camel".equals(id)) {
SpringBootDependencyDTO dto = new SpringBootDependencyDTO(groupName, "camel-zipkin-starter", "Apache Camel Zipkin", "Distributed tracing with an existing Zipkin installation with Apache Camel.");
String version = SpringBootVersionHelper.getVersion("camel.version");
dto.setMavenCoord("org.apache.camel", "camel-zipkin", version);
list.add(dto);
}
}
}
// and then add the fabric8 group
String version = SpringBootVersionHelper.getVersion("fabric8.spring.cloud.kubernetes.version");
SpringBootDependencyDTO dto = new SpringBootDependencyDTO("Fabric8", "spring-cloud-kubernetes", "Spring Cloud Kubernetes", "Kubernetes integration with Spring Cloud");
dto.setMavenCoord("io.fabric8", "spring-cloud-starter-kubernetes-all", version);
list.add(dto);
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment