use of io.quarkus.bootstrap.model.CapabilityContract in project quarkus by quarkusio.
the class BootstrapUtils method convert.
public static AppModel convert(ApplicationModel appModel) {
if (appModel instanceof AppModel) {
return (AppModel) appModel;
}
final AppModel.Builder builder = new AppModel.Builder();
final ResolvedDependency resolvedArtifact = appModel.getAppArtifact();
final AppArtifact appArtifact = new AppArtifact(resolvedArtifact.getGroupId(), resolvedArtifact.getArtifactId(), resolvedArtifact.getClassifier(), resolvedArtifact.getType(), resolvedArtifact.getVersion(), appModel.getApplicationModule(), resolvedArtifact.getScope(), resolvedArtifact.getFlags());
if (appModel.getAppArtifact().isResolved()) {
appArtifact.setPaths(PathsCollection.from(appModel.getAppArtifact().getResolvedPaths()));
}
builder.setAppArtifact(appArtifact);
builder.setCapabilitiesContracts(appModel.getExtensionCapabilities().stream().map(c -> new CapabilityContract(c.getExtension(), new ArrayList<>(c.getProvidesCapabilities()), new ArrayList<>(c.getRequiresCapabilities()))).collect(Collectors.toMap(CapabilityContract::getExtension, Function.identity())));
builder.setPlatformImports(appModel.getPlatforms());
appModel.getDependencies().forEach(d -> {
final AppArtifact a = new AppArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion(), d.getWorkspaceModule(), d.getScope(), d.getFlags());
a.setPaths(d.getResolvedPaths() == null ? PathsCollection.of() : PathsCollection.from(d.getResolvedPaths()));
builder.addDependency(new AppDependency(a, d.getScope(), d.getFlags()));
});
appModel.getLowerPriorityArtifacts().forEach(k -> builder.addLesserPriorityArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
appModel.getParentFirst().forEach(k -> builder.addParentFirstArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
appModel.getRunnerParentFirst().forEach(k -> builder.addRunnerParentFirstArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
appModel.getReloadableWorkspaceDependencies().forEach(k -> builder.addLocalProjectArtifact(new AppArtifactKey(k.getGroupId(), k.getArtifactId(), k.getClassifier(), k.getType())));
return builder.build();
}
Aggregations