use of org.wso2.ballerinalang.compiler.packaging.Patten 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");
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class RepoTest method testCacheRepo.
@Test
public void testCacheRepo() {
PackageID pkg = newPackageID("nice_org", "any.pkg", "10.2.3");
CacheRepo subject = new CacheRepo((PathConverter) null);
Patten patten = subject.calculate(pkg);
Assert.assertEquals(patten.toString(), "$/caches/*/nice_org/any.pkg/10.2.3/src/**~test~resources/*.bal");
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class URIConverterTest method testURIConverter.
@Test
public void testURIConverter() {
URI baseURI = URI.create("http://staging.central.ballerina.io:9090/");
Patten patten = new Patten(path("natasha", "foo.bar", "1.0.5"));
URIConverter subject = new URIConverter(baseURI);
List<URI> urls = patten.convert(subject).collect(Collectors.toList());
URI expected = URI.create("http://staging.central.ballerina.io:9090/natasha/foo.bar/1.0.5/");
Assert.assertEquals(urls, Collections.singletonList(expected));
}
use of org.wso2.ballerinalang.compiler.packaging.Patten in project ballerina by ballerina-lang.
the class PullCommand method execute.
@Override
public void execute() {
if (helpFlag) {
String commandUsageInfo = BLauncherCmd.getCommandUsageInfo(parentCmdParser, "pull");
outStream.println(commandUsageInfo);
return;
}
if (argList == null || argList.size() == 0) {
throw new BLangCompilerException("no package given");
}
if (argList.size() > 1) {
throw new BLangCompilerException("too many arguments");
}
// Enable remote debugging
if (null != debugPort) {
System.setProperty(SYSTEM_PROP_BAL_DEBUG, debugPort);
}
String resourceName = argList.get(0);
String orgName;
String packageName;
String version;
// Get org-name
int orgNameIndex = resourceName.indexOf("/");
if (orgNameIndex != -1) {
orgName = resourceName.substring(0, orgNameIndex);
} else {
throw new BLangCompilerException("no package-name provided");
}
// Get package name
int packageNameIndex = resourceName.indexOf(":");
if (packageNameIndex != -1) {
// version is provided
packageName = resourceName.substring(orgNameIndex + 1, packageNameIndex);
version = resourceName.substring(packageNameIndex + 1, resourceName.length());
} else {
packageName = resourceName.substring(orgNameIndex + 1, resourceName.length());
version = "*";
}
URI baseURI = URI.create("https://staging.central.ballerina.io:9090/");
Repo remoteRepo = new RemoteRepo(baseURI);
PackageID packageID = new PackageID(new Name(orgName), new Name(packageName), new Name(version));
Patten patten = remoteRepo.calculate(packageID);
if (patten != Patten.NULL) {
Converter converter = remoteRepo.getConverterInstance();
patten.convertToSources(converter, packageID).collect(Collectors.toList());
} else {
outStream.println("couldn't find package " + patten);
}
Runtime.getRuntime().exit(0);
}
use of org.wso2.ballerinalang.compiler.packaging.Patten 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;
}
Aggregations