Fix local dependency globbing (#496)

This fixes an issue where globbing resources within a local dependency
fails to match anything.
This commit is contained in:
Daniel Chao
2024-05-16 08:36:37 -07:00
committed by GitHub
parent a5c13e325a
commit 5f4d475d84
2 changed files with 20 additions and 4 deletions

View File

@@ -661,7 +661,7 @@ public final class ModuleKeys {
return projectDepsManager;
}
private @Nullable Path getLocalPath(Dependency dependency) {
private @Nullable Path getLocalPath(Dependency dependency, PackageAssetUri packageAssetUri) {
if (!(dependency instanceof LocalDependency localDependency)) {
return null;
}
@@ -669,6 +669,13 @@ public final class ModuleKeys {
getProjectDepsResolver().getProjectDir(), packageAssetUri);
}
private @Nullable Path getLocalPath(Dependency dependency) {
if (!(dependency instanceof LocalDependency)) {
return null;
}
return getLocalPath(dependency, packageAssetUri);
}
@Override
public ResolvedModuleKey resolve(SecurityManager securityManager)
throws IOException, SecurityManagerException {
@@ -693,7 +700,7 @@ public final class ModuleKeys {
var packageAssetUri = PackageAssetUri.create(baseUri);
var dependency =
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
var path = getLocalPath(dependency);
var path = getLocalPath(dependency, packageAssetUri);
if (path != null) {
securityManager.checkResolveModule(path.toUri());
return FileResolver.listElements(path);
@@ -710,7 +717,7 @@ public final class ModuleKeys {
var packageAssetUri = PackageAssetUri.create(elementUri);
var dependency =
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
var path = getLocalPath(dependency);
var path = getLocalPath(dependency, packageAssetUri);
if (path != null) {
securityManager.checkResolveModule(path.toUri());
return FileResolver.hasElement(path);

View File

@@ -32,7 +32,16 @@ examples {
}
}
["glob-import local project"] {
new {}
new {
["@project2/penguin.pkl"] {
bird {
name = "Penguin"
favoriteFruit {
name = "Ice Fruit"
}
}
}
}
}
["glob-import using dependency notation"] {
Set("@birds/catalog/Ostritch.pkl", "@birds/catalog/Swallow.pkl")