Search in sources :

Example 1 with AppModel

use of io.quarkus.bootstrap.model.AppModel 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();
}
Also used : AppArtifactKey(io.quarkus.bootstrap.model.AppArtifactKey) AppDependency(io.quarkus.bootstrap.model.AppDependency) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) CapabilityContract(io.quarkus.bootstrap.model.CapabilityContract) ArrayList(java.util.ArrayList) AppArtifact(io.quarkus.bootstrap.model.AppArtifact) AppModel(io.quarkus.bootstrap.model.AppModel)

Aggregations

AppArtifact (io.quarkus.bootstrap.model.AppArtifact)1 AppArtifactKey (io.quarkus.bootstrap.model.AppArtifactKey)1 AppDependency (io.quarkus.bootstrap.model.AppDependency)1 AppModel (io.quarkus.bootstrap.model.AppModel)1 CapabilityContract (io.quarkus.bootstrap.model.CapabilityContract)1 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)1 ArrayList (java.util.ArrayList)1