use of org.ballerinalang.model.elements.PackageID in project ballerina by ballerina-lang.
the class PackageLoader method updateVersionFromToml.
private void updateVersionFromToml(PackageID pkgId) {
String orgName = pkgId.orgName.value;
String pkgName = pkgId.name.value;
String pkgAlias = orgName + "/" + pkgName;
// TODO: make getDependencies return a map
Optional<Dependency> dependency = manifest.getDependencies().stream().filter(d -> d.getPackageName().equals(pkgAlias)).findFirst();
if (dependency.isPresent()) {
if (pkgId.version.value.isEmpty()) {
pkgId.version = new Name(dependency.get().getVersion());
} else {
throw new BLangCompilerException("dependency version in Ballerina.toml mismatches" + " with the version in the source for package " + pkgAlias);
}
}
}
use of org.ballerinalang.model.elements.PackageID in project ballerina by ballerina-lang.
the class ZipUtils method generateBalo.
/**
* Generates the balo/zip of the package.
*
* @param bLangPackage bLangPackage node
* @param projectPath project path
* @param paths paths of bal files inside the package
*/
static void generateBalo(BLangPackage bLangPackage, String projectPath, Stream<Path> paths) {
PackageID packageID = bLangPackage.packageID;
Path destPath = Paths.get(projectPath).resolve(".ballerina").resolve("repo").resolve(packageID.getOrgName().getValue()).resolve(packageID.getName().getValue()).resolve(packageID.getPackageVersion().getValue());
if (!Files.exists(destPath)) {
try {
Files.createDirectories(destPath);
} catch (IOException e) {
throw new BLangCompilerException("Error occurred when creating directories in " + "./ballerina/repo/ to save the generated balo");
}
}
String fileName = packageID.getName() + ".zip";
String baloDirPath = destPath.resolve(fileName).toString();
createArchive(paths, baloDirPath);
}
use of org.ballerinalang.model.elements.PackageID in project ballerina by ballerina-lang.
the class RepoHierarchyTest method testResolvingFromAnIntermediate.
@Test
public void testResolvingFromAnIntermediate() {
RepoHierarchy subject;
Resolution resolution;
// Part 1
PackageID repo1sPkg = newPackageID("good", "i.am", "1");
ArrayList<Integer> order = new ArrayList<>();
subject = createSubject(order);
resolution = subject.resolve(repo1sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
Assert.assertEquals(order, Arrays.asList(0, 1));
// Part 2
order.clear();
PackageID repo4sPkg = newPackageID("ugly", "ok.pkg", "4");
subject = resolution.resolvedBy;
subject.resolve(repo4sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
Assert.assertEquals(order, Arrays.asList(1, 2, 3, 4));
}
use of org.ballerinalang.model.elements.PackageID in project ballerina by ballerina-lang.
the class RepoHierarchyTest method testIdempotence.
@Test
public void testIdempotence() {
RepoHierarchy subject;
Resolution resolution;
// Part 1
PackageID repo0sPkg = newPackageID("easy", "too", "0");
ArrayList<Integer> order = new ArrayList<>();
subject = createSubject(order);
resolution = subject.resolve(repo0sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
// Part 2
order.clear();
subject = resolution.resolvedBy;
subject.resolve(repo0sPkg);
Assert.assertNotEquals(resolution, Resolution.NOT_FOUND);
}
use of org.ballerinalang.model.elements.PackageID in project ballerina by ballerina-lang.
the class RepoTest method testProjectObjRepo.
@Test
public void testProjectObjRepo() {
PackageID pkg = newPackageID("my_org", "my.pkg", "1.2.3");
ObjRepo subject = new ObjRepo((PathConverter) null);
Patten patten = subject.calculate(pkg);
Assert.assertEquals(patten.toString(), "$/repo/my_org/my.pkg/1.2.3/obj/my.pkg.balo");
}
Aggregations