Search in sources :

Example 1 with AppDependency

use of io.quarkus.bootstrap.model.AppDependency in project quarkus-test-framework by quarkus-qe.

the class QuarkusApplicationManagedResourceBuilder method initForcedDependencies.

public void initForcedDependencies(Dependency[] forcedDependencies) {
    if (forcedDependencies != null && forcedDependencies.length > 0) {
        requiresCustomBuild = true;
        this.forcedDependencies = Stream.of(forcedDependencies).map(d -> {
            String groupId = StringUtils.defaultIfEmpty(resolveProperty(d.groupId()), QUARKUS_GROUP_ID_DEFAULT);
            String version = StringUtils.defaultIfEmpty(resolveProperty(d.version()), Version.getVersion());
            AppArtifact artifact = new AppArtifact(groupId, d.artifactId(), version);
            // https://github.com/quarkusio/quarkus/commit/0c85b27c4046c894c181ffea367fca503d1c682c
            if (isQuarkusVersion2Dot3OrAbove()) {
                return ReflectionUtils.createInstance(AppDependency.class, artifact, DEPENDENCY_SCOPE_DEFAULT, new int[] { DEPENDENCY_DIRECT_FLAG });
            }
            return new AppDependency(artifact, DEPENDENCY_SCOPE_DEFAULT);
        }).collect(Collectors.toList());
    }
}
Also used : AppDependency(io.quarkus.bootstrap.model.AppDependency) AppArtifact(io.quarkus.bootstrap.model.AppArtifact)

Example 2 with AppDependency

use of io.quarkus.bootstrap.model.AppDependency 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)

Example 3 with AppDependency

use of io.quarkus.bootstrap.model.AppDependency in project quarkus by quarkusio.

the class ModelUtils method getUpdateCandidates.

/**
 * Filters out non-platform from application POM dependencies.
 *
 * @param deps POM model application dependencies
 * @param appDeps resolved application dependencies
 * @return dependencies that can be checked for updates
 */
public static List<AppDependency> getUpdateCandidates(List<Dependency> deps, List<AppDependency> appDeps, Set<String> groupIds) {
    final Map<AppArtifactKey, AppDependency> appDepMap = new LinkedHashMap<>(appDeps.size());
    for (AppDependency appDep : appDeps) {
        final AppArtifact appArt = appDep.getArtifact();
        appDepMap.put(new AppArtifactKey(appArt.getGroupId(), appArt.getArtifactId(), appArt.getClassifier()), appDep);
    }
    final List<AppDependency> updateCandidates = new ArrayList<>(deps.size());
    // it's critical to preserve the order of the dependencies from the pom
    for (Dependency dep : deps) {
        if (!groupIds.contains(dep.getGroupId()) || "test".equals(dep.getScope())) {
            continue;
        }
        final AppDependency appDep = appDepMap.remove(new AppArtifactKey(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier()));
        if (appDep == null) {
            // throw new AppCreatorException("Failed to locate dependency " + new AppArtifact(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), dep.getType(), dep.getVersion()) + " present in pom.xml among resolved application dependencies");
            continue;
        }
        updateCandidates.add(appDep);
    }
    for (AppDependency appDep : appDepMap.values()) {
        if (groupIds.contains(appDep.getArtifact().getGroupId())) {
            updateCandidates.add(appDep);
        }
    }
    return updateCandidates;
}
Also used : AppArtifactKey(io.quarkus.bootstrap.model.AppArtifactKey) AppDependency(io.quarkus.bootstrap.model.AppDependency) ArrayList(java.util.ArrayList) AppDependency(io.quarkus.bootstrap.model.AppDependency) Dependency(org.apache.maven.model.Dependency) AppArtifact(io.quarkus.bootstrap.model.AppArtifact) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

AppArtifact (io.quarkus.bootstrap.model.AppArtifact)3 AppDependency (io.quarkus.bootstrap.model.AppDependency)3 AppArtifactKey (io.quarkus.bootstrap.model.AppArtifactKey)2 ArrayList (java.util.ArrayList)2 AppModel (io.quarkus.bootstrap.model.AppModel)1 CapabilityContract (io.quarkus.bootstrap.model.CapabilityContract)1 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)1 LinkedHashMap (java.util.LinkedHashMap)1 Dependency (org.apache.maven.model.Dependency)1