Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle: make sure platforms and enforced platforms are applied to the deployment classpath #19307

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.quarkus.gradle.builder;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -68,14 +69,16 @@ private static Configuration classpathConfig(Project project, LaunchMode mode) {
return project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
}

private static Configuration deploymentClasspathConfig(Project project, LaunchMode mode) {
private static Configuration deploymentClasspathConfig(Project project, LaunchMode mode,
Collection<org.gradle.api.artifacts.Dependency> platforms) {

Configuration deploymentConfiguration = project.getConfigurations().findByName(DEPLOYMENT_CONFIGURATION);
if (deploymentConfiguration != null) {
project.getConfigurations().remove(deploymentConfiguration);
}

deploymentConfiguration = project.getConfigurations().create(DEPLOYMENT_CONFIGURATION)
.withDependencies(ds -> ds.addAll(platforms))
.extendsFrom(project.getConfigurations().getByName(ApplicationDeploymentClasspathBuilder
.toDeploymentConfigurationName(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME)));
if (LaunchMode.TEST.equals(mode)) {
Expand Down Expand Up @@ -118,15 +121,15 @@ public Object buildAll(String modelName, ModelParameter parameter, Project proje
final ResolvedConfiguration resolvedConfiguration = classpathConfig.getResolvedConfiguration();
collectDependencies(resolvedConfiguration, mode, project, appDependencies);

Configuration deploymentConfig = deploymentClasspathConfig(project, mode);
Configuration deploymentConfig = deploymentClasspathConfig(project, mode, deploymentDeps);
final List<Dependency> extensionDependencies = collectExtensionDependencies(deploymentConfig);

ArtifactCoords appArtifactCoords = new ArtifactCoordsImpl(project.getGroup().toString(), project.getName(),
project.getVersion().toString());

return new QuarkusModelImpl(
new WorkspaceImpl(appArtifactCoords, getWorkspace(project.getRootProject(), mode, appArtifactCoords)),
new LinkedList<>(appDependencies.values()),
new ArrayList<>(appDependencies.values()),
extensionDependencies,
deploymentDeps.stream().map(QuarkusModelBuilder::toEnforcedPlatformDependency)
.filter(Objects::nonNull).collect(Collectors.toList()),
Expand Down Expand Up @@ -209,18 +212,15 @@ private WorkspaceModule getWorkspaceModule(Project project, LaunchMode mode, boo
}

private List<Dependency> collectExtensionDependencies(Configuration deploymentConfiguration) {
final List<Dependency> platformDependencies = new LinkedList<>();

final List<Dependency> extensionDependencies = new ArrayList<>();
final ResolvedConfiguration rc = deploymentConfiguration.getResolvedConfiguration();
for (ResolvedArtifact a : rc.getResolvedArtifacts()) {
if (!isDependency(a)) {
continue;
if (isDependency(a)) {
extensionDependencies.add(toDependency(a));
}
final Dependency dependency = toDependency(a);
platformDependencies.add(dependency);
}

return platformDependencies;
return extensionDependencies;
}

private void collectDependencies(ResolvedConfiguration configuration,
Expand Down