Skip to content

Commit

Permalink
Fix dependency resolution error in mixed cluster type projects
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Nov 13, 2023
1 parent e0261a7 commit 533c936
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class RestTestBasePlugin implements Plugin<Project> {
private static final String EXTRACTED_PLUGINS_CONFIGURATION = "extractedPlugins";
private static final Attribute<String> CONFIGURATION_ATTRIBUTE = Attribute.of("test-cluster-artifacts", String.class);
private static final String FEATURES_METADATA_CONFIGURATION = "featuresMetadataDeps";
private static final String DEFAULT_DISTRO_FEATURES_METADATA_CONFIGURATION = "defaultDistrofeaturesMetadataDeps";
private static final String TESTS_FEATURES_METADATA_PATH = "tests.features.metadata.path";

private final ProviderFactory providerFactory;
Expand Down Expand Up @@ -126,6 +127,21 @@ public void apply(Project project) {
});
});

Configuration defaultDistroFeatureMetadataConfig = project.getConfigurations()
.create(DEFAULT_DISTRO_FEATURES_METADATA_CONFIGURATION, c -> {
c.setCanBeConsumed(false);
c.setCanBeResolved(true);
c.attributes(
a -> a.attribute(
ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE,
HistoricalFeaturesMetadataPlugin.FEATURES_METADATA_TYPE
)
);
c.defaultDependencies(
d -> d.add(project.getDependencies().project(Map.of("path", ":distribution", "configuration", "featuresMetadata")))
);
});

// For plugin and module projects, register the current project plugin bundle as a dependency
project.getPluginManager().withPlugin("elasticsearch.esplugin", plugin -> {
if (GradleUtils.isModuleProject(project.getPath())) {
Expand Down Expand Up @@ -188,8 +204,9 @@ public Void call(Object... args) {
);

// If we are using the default distribution we need to register all module feature metadata
featureMetadataConfig.getDependencies()
.add(project.getDependencies().project(Map.of("path", ":distribution", "configuration", "featuresMetadata")));
task.getInputs().files(defaultDistroFeatureMetadataConfig).withPathSensitivity(PathSensitivity.NONE);
nonInputSystemProperties.systemProperty(TESTS_FEATURES_METADATA_PATH, defaultDistroFeatureMetadataConfig::getAsPath);

return null;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.CharBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -2237,7 +2238,7 @@ protected Map<NodeFeature, Version> getHistoricalFeatures() {
historicalFeaturesMap.put(new NodeFeature(entry.getKey()), Version.fromString(entry.getValue()));
}
} catch (IOException e) {
throw new RuntimeException(e);
throw new UncheckedIOException(e);
}
}

Expand Down

0 comments on commit 533c936

Please sign in to comment.