Search in sources :

Example 1 with PlatformImportsImpl

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

the class GradleApplicationModelBuilder method resolvePlatformImports.

private PlatformImports resolvePlatformImports(Project project, List<org.gradle.api.artifacts.Dependency> deploymentDeps) {
    final Configuration boms = project.getConfigurations().detachedConfiguration(deploymentDeps.toArray(new org.gradle.api.artifacts.Dependency[0]));
    final PlatformImportsImpl platformImports = new PlatformImportsImpl();
    boms.getResolutionStrategy().eachDependency(d -> {
        final String group = d.getTarget().getGroup();
        final String name = d.getTarget().getName();
        if (name.endsWith(BootstrapConstants.PLATFORM_DESCRIPTOR_ARTIFACT_ID_SUFFIX)) {
            platformImports.addPlatformDescriptor(group, name, d.getTarget().getVersion(), "json", d.getTarget().getVersion());
        } else if (name.endsWith(BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX)) {
            final DefaultDependencyArtifact dep = new DefaultDependencyArtifact();
            dep.setExtension("properties");
            dep.setType("properties");
            dep.setName(name);
            final DefaultExternalModuleDependency gradleDep = new DefaultExternalModuleDependency(group, name, d.getTarget().getVersion(), null);
            gradleDep.addArtifact(dep);
            for (ResolvedArtifact a : project.getConfigurations().detachedConfiguration(gradleDep).getResolvedConfiguration().getResolvedArtifacts()) {
                if (a.getName().equals(name)) {
                    try {
                        platformImports.addPlatformProperties(group, name, null, "properties", d.getTarget().getVersion(), a.getFile().toPath());
                    } catch (AppModelResolverException e) {
                        throw new GradleException("Failed to import platform properties " + a.getFile(), e);
                    }
                    break;
                }
            }
        }
    });
    boms.getResolvedConfiguration();
    return platformImports;
}
Also used : DefaultDependencyArtifact(org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact) ResolvedArtifact(org.gradle.api.artifacts.ResolvedArtifact) Configuration(org.gradle.api.artifacts.Configuration) ResolvedConfiguration(org.gradle.api.artifacts.ResolvedConfiguration) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) AppModelResolverException(io.quarkus.bootstrap.resolver.AppModelResolverException) GradleException(org.gradle.api.GradleException) PlatformImportsImpl(io.quarkus.bootstrap.model.PlatformImportsImpl) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) ArtifactDependency(io.quarkus.maven.dependency.ArtifactDependency) Dependency(io.quarkus.maven.dependency.Dependency) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency)

Example 2 with PlatformImportsImpl

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

the class BootstrapAppModelResolver method collectPlatformProperties.

private void collectPlatformProperties(ApplicationModelBuilder appBuilder, List<Dependency> managedDeps) throws AppModelResolverException {
    final PlatformImportsImpl platformReleases = new PlatformImportsImpl();
    for (Dependency d : managedDeps) {
        final Artifact artifact = d.getArtifact();
        final String extension = artifact.getExtension();
        final String artifactId = artifact.getArtifactId();
        if ("json".equals(extension) && artifactId.endsWith(BootstrapConstants.PLATFORM_DESCRIPTOR_ARTIFACT_ID_SUFFIX)) {
            platformReleases.addPlatformDescriptor(artifact.getGroupId(), artifactId, artifact.getClassifier(), extension, artifact.getVersion());
        } else if ("properties".equals(artifact.getExtension()) && artifactId.endsWith(BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX)) {
            platformReleases.addPlatformProperties(artifact.getGroupId(), artifactId, artifact.getClassifier(), extension, artifact.getVersion(), mvn.resolve(artifact).getArtifact().getFile().toPath());
        }
    }
    appBuilder.setPlatformImports(platformReleases);
}
Also used : PlatformImportsImpl(io.quarkus.bootstrap.model.PlatformImportsImpl) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) Dependency(org.eclipse.aether.graph.Dependency) ResolvableDependency(io.quarkus.maven.dependency.ResolvableDependency) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

PlatformImportsImpl (io.quarkus.bootstrap.model.PlatformImportsImpl)2 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)2 AppModelResolverException (io.quarkus.bootstrap.resolver.AppModelResolverException)1 ArtifactDependency (io.quarkus.maven.dependency.ArtifactDependency)1 Dependency (io.quarkus.maven.dependency.Dependency)1 ResolvableDependency (io.quarkus.maven.dependency.ResolvableDependency)1 Artifact (org.eclipse.aether.artifact.Artifact)1 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 Dependency (org.eclipse.aether.graph.Dependency)1 GradleException (org.gradle.api.GradleException)1 Configuration (org.gradle.api.artifacts.Configuration)1 ResolvedArtifact (org.gradle.api.artifacts.ResolvedArtifact)1 ResolvedConfiguration (org.gradle.api.artifacts.ResolvedConfiguration)1 DefaultDependencyArtifact (org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact)1 DefaultExternalModuleDependency (org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency)1