use of org.eclipse.ceylon.cmr.api.ModuleVersionResult in project ceylon by eclipse.
the class RepoUsingTool method findCompiledVersions.
private Collection<ModuleVersionDetails> findCompiledVersions(RepositoryManager repoMgr, String name, Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) throws IOException {
String outRepo = DefaultToolOptions.getCompilerOutputRepo();
if (outRepo != null) {
File outDir = new File(outRepo);
CmrRepository rep = null;
List<CmrRepository> repositories = repoMgr.getRepositories();
for (CmrRepository repository : repositories) {
OpenNode root = repository.getRoot();
// it has binaries if it is not a folder
if (root.isRemote() || root.hasBinaries())
continue;
ContentStore service = root.getService(ContentStore.class);
if (service == null)
continue;
ContentHandle content = service.peekContent(root);
// again skip binaries
if (content == null || content.hasBinaries())
continue;
File repoFile = content.getContentAsFile();
if (repoFile != null && FileUtil.sameFile(repoFile, outDir)) {
rep = repository;
break;
}
}
if (rep != null && rep.isSearchable()) {
ModuleVersionQuery query = getModuleVersionQuery(null, name, null, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
ModuleVersionResult result = new ModuleVersionResult(query.getName());
rep.completeVersions(query, result);
NavigableMap<String, ModuleVersionDetails> outRepoVersions = result.getVersions();
if (!outRepoVersions.isEmpty()) {
return outRepoVersions.values();
}
}
}
return null;
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionResult in project ceylon by eclipse.
the class RepoUsingTool method getModuleVersions.
protected Collection<ModuleVersionDetails> getModuleVersions(RepositoryManager repoMgr, String namespace, String name, String version, boolean exactVersionMatch, ModuleQuery.Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) {
ModuleVersionQuery query = getModuleVersionQuery(namespace, name, version, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
query.setExactVersionMatch(exactVersionMatch);
ModuleVersionResult result = repoMgr.completeVersions(query);
NavigableMap<String, ModuleVersionDetails> versionMap = result.getVersions();
return versionMap.values();
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionResult in project ceylon by eclipse.
the class ModuleCopycat method getModuleVersions.
private Collection<ModuleVersionDetails> getModuleVersions(RepositoryManager repoMgr, String name, String version, ModuleQuery.Type type, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) {
ModuleVersionQuery query = new ModuleVersionQuery(null, name, version, type);
if (jvmBinaryMajor != null) {
query.setJvmBinaryMajor(jvmBinaryMajor);
}
if (jvmBinaryMinor != null) {
query.setJvmBinaryMinor(jvmBinaryMinor);
}
if (jsBinaryMajor != null) {
query.setJsBinaryMajor(jsBinaryMajor);
}
if (jsBinaryMinor != null) {
query.setJsBinaryMinor(jsBinaryMinor);
}
ModuleVersionResult result = repoMgr.completeVersions(query);
NavigableMap<String, ModuleVersionDetails> versionMap = result.getVersions();
return versionMap.values();
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionResult in project ceylon by eclipse.
the class AetherTestCase method testListVersionsAether.
@Test
public void testListVersionsAether() throws Exception {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ModuleVersionQuery lookup = new ModuleVersionQuery("com.sparkjava:spark-core", "1.", Type.JAR);
ModuleVersionResult result = manager.completeVersions(lookup);
Assert.assertEquals(3, result.getVersions().size());
Assert.assertNotNull(result.getVersions().get("1.0"));
Assert.assertNotNull(result.getVersions().get("1.1"));
Assert.assertNotNull(result.getVersions().get("1.1.1"));
for (ModuleVersionDetails res : result.getVersions().values()) {
Assert.assertEquals("Spark\nA Sinatra inspired java web framework\nhttp://www.sparkjava.com", res.getDoc());
Assert.assertEquals("The Apache Software License, Version 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0.txt", res.getLicense());
NavigableSet<ModuleDependencyInfo> deps = res.getDependencies();
List<ModuleDependencyInfo> compileDeps = new ArrayList<>(deps.size());
for (ModuleDependencyInfo dep : res.getDependencies()) {
if (dep.getModuleScope() == ModuleScope.COMPILE || dep.getModuleScope() == ModuleScope.PROVIDED)
compileDeps.add(dep);
}
Assert.assertEquals(4, compileDeps.size());
}
lookup = new ModuleVersionQuery("com.sparkjava:spark-core", null, Type.JAR);
result = manager.completeVersions(lookup);
// Count the version up to 2.3
int cnt = 0;
for (ModuleVersionDetails mvd : result.getVersions().values()) {
cnt++;
if ("2.3".equals(mvd.getVersion())) {
break;
}
}
Assert.assertEquals(7, cnt);
// now check that we only downloaded the POMs for that, and not the jars
File repo = new File("build/test-classes/maven-settings/repository");
File folder = new File(repo, "com/sparkjava/spark-core/1.0");
Assert.assertTrue(new File(folder, "spark-core-1.0.pom").exists());
Assert.assertFalse(new File(folder, "spark-core-1.0.jar").exists());
Assert.assertFalse(new File(repo, "org/eclipse/jetty/jetty-server/9.0.2.v20130417/jetty-server-9.0.2.v20130417.jar").exists());
// this one has a conflict if we do resolve it non-lazily
lookup = new ModuleVersionQuery("org.hibernate:hibernate-validator", "3.", Type.JAR);
result = manager.completeVersions(lookup);
Assert.assertEquals(4, result.getVersions().size());
}
use of org.eclipse.ceylon.cmr.api.ModuleVersionResult in project ceylon by eclipse.
the class AbstractTest method testListVersions.
protected void testListVersions(String query, String versionQuery, ModuleVersionDetails[] expected, RepositoryManager manager, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor, String memberSearch, ModuleQuery.Type type, ModuleQuery.Retrieval retrieval) throws Exception {
ModuleVersionQuery lookup = new ModuleVersionQuery(query, versionQuery, type);
lookup.setRetrieval(retrieval);
lookup.setJvmBinaryMajor(jvmBinaryMajor);
lookup.setJvmBinaryMinor(jvmBinaryMinor);
lookup.setJsBinaryMajor(jsBinaryMajor);
lookup.setJsBinaryMinor(jsBinaryMinor);
lookup.setMemberName(memberSearch);
ModuleVersionResult result = manager.completeVersions(lookup);
int i = 0;
Assert.assertEquals(expected.length, result.getVersions().size());
for (Entry<String, ModuleVersionDetails> entry : result.getVersions().entrySet()) {
ModuleVersionDetails expectedVersion = expected[i++];
ModuleVersionDetails version = entry.getValue();
Assert.assertEquals(expectedVersion.getVersion(), entry.getKey());
Assert.assertEquals(expectedVersion.getVersion(), version.getVersion());
if (expectedVersion.getDoc() != null) {
// Docs can be really big, this let's allow us to ignore them for comparisons
Assert.assertEquals(expectedVersion.getDoc(), version.getDoc());
}
Assert.assertEquals(expectedVersion.getLicense(), version.getLicense());
Assert.assertEquals(expectedVersion.getAuthors(), version.getAuthors());
Assert.assertEquals(expectedVersion.getDependencies(), version.getDependencies());
Assert.assertEquals(expectedVersion.getArtifactTypes(), version.getArtifactTypes());
Assert.assertEquals(expectedVersion.isRemote(), version.isRemote());
Assert.assertEquals(expectedVersion.getOrigin(), version.getOrigin());
Assert.assertEquals(expectedVersion.getNamespace(), version.getNamespace());
}
}
Aggregations