Search in sources :

Example 1 with ProjectSourceRepo

use of org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo in project ballerina by ballerina-lang.

the class RepoTest method testProjectSourceRepo.

@Test
public void testProjectSourceRepo() {
    PackageID pkg = newPackageID("best_org", "this.pkg", "1.8.3");
    ProjectSourceRepo subject = new ProjectSourceRepo((PathConverter) null);
    Patten prospect = subject.calculate(pkg);
    Assert.assertEquals(prospect.toString(), "$/this.pkg/**~test~resources/*.bal");
}
Also used : PackageID(org.ballerinalang.model.elements.PackageID) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) ProjectSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo) Test(org.testng.annotations.Test)

Example 2 with ProjectSourceRepo

use of org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo in project ballerina by ballerina-lang.

the class BinaryFileWriter method writeExecutableBinary.

public void writeExecutableBinary(BLangPackage packageNode) {
    String fileName = getOutputFileName(packageNode, BLANG_EXEC_FILE_SUFFIX);
    writeExecutableBinary(packageNode, fileName);
    // Generate balo
    Path path = this.sourceDirectory.getPath();
    if (Files.isDirectory(path.resolve(ProjectDirConstants.DOT_BALLERINA_DIR_NAME))) {
        ProjectSourceRepo projectSourceRepo = new ProjectSourceRepo(path);
        Patten packageIDPattern = projectSourceRepo.calculate(packageNode.packageID);
        Stream<Path> pathStream = packageIDPattern.convert(projectSourceRepo.getConverterInstance());
        pathStream = Stream.concat(pathStream, packageIDPattern.sibling(path("Ballerina.md")).convert(projectSourceRepo.getConverterInstance()));
        String prjPath = projectSourceRepo.getConverterInstance().toString();
        ZipUtils.generateBalo(packageNode, prjPath, pathStream);
    }
}
Also used : Path(java.nio.file.Path) Patten(org.wso2.ballerinalang.compiler.packaging.Patten) ProjectSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo)

Example 3 with ProjectSourceRepo

use of org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo in project ballerina by ballerina-lang.

the class PackageLoader method genRepoHierarchy.

private RepoHierarchy genRepoHierarchy(Path sourceRoot) {
    Path balHomeDir = HomeRepoUtils.createAndGetHomeReposPath();
    Path projectHiddenDir = sourceRoot.resolve(".ballerina");
    RepoHierarchyBuilder.RepoNode[] systemArr = loadSystemRepos();
    Converter<Path> converter = sourceDirectory.getConverter();
    Repo remote = new RemoteRepo(URI.create("https://staging.central.ballerina.io:9090/"));
    Repo homeCacheRepo = new CacheRepo(balHomeDir);
    Repo homeRepo = new ZipRepo(balHomeDir);
    Repo projectCacheRepo = new CacheRepo(projectHiddenDir);
    Repo projectRepo = new ZipRepo(projectHiddenDir);
    RepoHierarchyBuilder.RepoNode homeCacheNode;
    if (offline) {
        homeCacheNode = node(homeCacheRepo, systemArr);
    } else {
        homeCacheNode = node(homeCacheRepo, node(remote, systemArr));
    }
    RepoHierarchyBuilder.RepoNode nonLocalRepos = node(projectRepo, node(projectCacheRepo, homeCacheNode), node(homeRepo, homeCacheNode));
    RepoHierarchyBuilder.RepoNode fullRepoGraph;
    if (converter != null) {
        Repo programingSource = new ProgramingSourceRepo(converter);
        Repo projectSource = new ProjectSourceRepo(converter);
        fullRepoGraph = node(programingSource, node(projectSource, nonLocalRepos));
    } else {
        fullRepoGraph = nonLocalRepos;
    }
    return RepoHierarchyBuilder.build(fullRepoGraph);
}
Also used : Path(java.nio.file.Path) ProgramingSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProgramingSourceRepo) ProjectSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo) RemoteRepo(org.wso2.ballerinalang.compiler.packaging.repo.RemoteRepo) Repo(org.wso2.ballerinalang.compiler.packaging.repo.Repo) ProgramingSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProgramingSourceRepo) ZipRepo(org.wso2.ballerinalang.compiler.packaging.repo.ZipRepo) CacheRepo(org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo) RepoHierarchyBuilder(org.wso2.ballerinalang.compiler.packaging.RepoHierarchyBuilder) CacheRepo(org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo) RemoteRepo(org.wso2.ballerinalang.compiler.packaging.repo.RemoteRepo) ZipRepo(org.wso2.ballerinalang.compiler.packaging.repo.ZipRepo) ProjectSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo)

Aggregations

ProjectSourceRepo (org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo)3 Path (java.nio.file.Path)2 Patten (org.wso2.ballerinalang.compiler.packaging.Patten)2 PackageID (org.ballerinalang.model.elements.PackageID)1 Test (org.testng.annotations.Test)1 RepoHierarchyBuilder (org.wso2.ballerinalang.compiler.packaging.RepoHierarchyBuilder)1 CacheRepo (org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo)1 ProgramingSourceRepo (org.wso2.ballerinalang.compiler.packaging.repo.ProgramingSourceRepo)1 RemoteRepo (org.wso2.ballerinalang.compiler.packaging.repo.RemoteRepo)1 Repo (org.wso2.ballerinalang.compiler.packaging.repo.Repo)1 ZipRepo (org.wso2.ballerinalang.compiler.packaging.repo.ZipRepo)1