Search in sources :

Example 1 with PackageSourceEntry

use of org.ballerinalang.repository.PackageSourceEntry in project ballerina by ballerina-lang.

the class JarIntegrationTest method balInsideJar.

@Test
public void balInsideJar() throws IOException {
    Patten balPatten = new Patten(path("very"), Patten.WILDCARD_SOURCE);
    JarRepo repo = new JarRepo(tempJar.toUri());
    Converter<Path> subject = repo.getConverterInstance();
    List<PackageSourceEntry> sources = balPatten.convertToSources(subject, null).collect(Collectors.toList());
    Assert.assertEquals(sources.size(), 1);
    Assert.assertEquals(sources.get(0).getCode(), BAL_CONTENT);
}
Also used : Path(java.nio.file.Path) PackageSourceEntry(org.ballerinalang.repository.PackageSourceEntry) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) JarRepo(org.wso2.ballerinalang.compiler.packaging.repo.JarRepo) Test(org.testng.annotations.Test)

Example 2 with PackageSourceEntry

use of org.ballerinalang.repository.PackageSourceEntry in project ballerina by ballerina-lang.

the class RepoHierarchy method resolve.

public Resolution resolve(PackageID pkg) {
    log1(pkg);
    for (int i = 0; i < repos.length; i++) {
        Repo repo = repos[i];
        Patten patten = repo.calculate(pkg);
        if (patten != Patten.NULL) {
            Converter converter = repo.getConverterInstance();
            List<PackageSourceEntry> paths = patten.convertToSources(converter, pkg).collect(Collectors.toList());
            log2(repo, patten, paths);
            if (!paths.isEmpty()) {
                return new Resolution(getChildHierarchyForRepo(i), paths);
            }
        } else {
            log3(repo);
        }
    }
    log4();
    return Resolution.NOT_FOUND;
}
Also used : Repo(org.wso2.ballerinalang.compiler.packaging.repo.Repo) PackageSourceEntry(org.ballerinalang.repository.PackageSourceEntry) Converter(org.wso2.ballerinalang.compiler.packaging.converters.Converter)

Aggregations

PackageSourceEntry (org.ballerinalang.repository.PackageSourceEntry)2 Path (java.nio.file.Path)1 Test (org.testng.annotations.Test)1 Patten (org.wso2.ballerinalang.compiler.packaging.Patten)1 Converter (org.wso2.ballerinalang.compiler.packaging.converters.Converter)1 JarRepo (org.wso2.ballerinalang.compiler.packaging.repo.JarRepo)1 Repo (org.wso2.ballerinalang.compiler.packaging.repo.Repo)1