use of org.wso2.ballerinalang.compiler.packaging.Patten 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);
}
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class URIConverter method finalize.
public Stream<PackageSourceEntry> finalize(URI u, PackageID packageID) {
String orgName = packageID.getOrgName().getValue();
String pkgName = packageID.getName().getValue();
Path destDirPath = HomeRepoUtils.createAndGetHomeReposPath().resolve(Paths.get("repo", orgName, pkgName));
createDirectory(destDirPath);
try {
String fullPkgPath = orgName + "/" + pkgName;
executor.execute(pullBalxLocation, u.toString(), destDirPath.toString(), fullPkgPath, File.separator);
// TODO Simplify using ZipRepo
Patten pattern = new Patten(Patten.WILDCARD_DIR, Patten.path(pkgName + ".zip"), Patten.path("src"), Patten.WILDCARD_SOURCE);
return pattern.convertToSources(new ZipConverter(destDirPath), packageID);
} catch (Exception ignore) {
}
return Stream.of();
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PushUtils method resolvePkgPathInRemoteRepo.
/**
* Get URI of the package from the remote repo.
*
* @param packageID packageID object
* @return full URI path of the package relative to the remote repo
*/
private static String resolvePkgPathInRemoteRepo(PackageID packageID) {
Repo<URI> remoteRepo = new RemoteRepo(URI.create("https://staging.central.ballerina.io:9090/"));
Patten patten = remoteRepo.calculate(packageID);
if (patten == Patten.NULL) {
throw new BLangCompilerException("Couldn't find package " + packageID.toString());
}
Converter<URI> converter = remoteRepo.getConverterInstance();
List<URI> uris = patten.convert(converter).collect(Collectors.toList());
if (uris.isEmpty()) {
throw new BLangCompilerException("Couldn't find package " + packageID.toString());
}
return uris.get(0).toString();
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PathConverterIntegrationTest method testBalSearch.
@Test
public void testBalSearch() {
Patten patten = new Patten(path("very"), Patten.WILDCARD_SOURCE);
PathConverter subject = new PathConverter(tempDirectory);
Stream<Path> pathStream = patten.convert(subject);
List<Path> paths = pathStream.collect(Collectors.toList());
Assert.assertEquals(paths.size(), 1);
Assert.assertEquals(paths.get(0).toString(), tempFile.toString());
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PattenTest method testReduction.
@Test
public void testReduction() {
Converter<String> mock = mockResolver("root-dir", (a, b) -> a + " > " + b, null, null);
Patten subject = new Patten(path("hello", "world"));
List<String> strings = subject.convert(mock).collect(Collectors.toList());
Assert.assertEquals(strings, Collections.singletonList("root-dir > hello > world"));
}
Aggregations