use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class SmokeTestCase method testExternalNodes.
@Test
public void testExternalNodes() throws Exception {
RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
InMemoryContentStore imcs = new InMemoryContentStore();
OpenNode root = imcs.createRoot();
CmrRepository repo = new DefaultRepository(root);
RepositoryManager manager = builder.addRepository(repo).buildRepository();
// a few impl details, feel free to remove/ignore this test
String name = "org.eclipse.acme";
String version = "1.0.0.CR1";
ArtifactContext context = new ArtifactContext(null, name, version);
// ignore with in-memory
context.setIgnoreSHA(true);
OpenNode parent = repo.createParent(context);
parent.addContent(name + "-" + version + ArtifactContext.CAR, new ByteArrayInputStream("qwerty".getBytes()), context);
try {
File file = manager.getArtifact(context);
Assert.assertNotNull("Failed to retrieve after put", file);
} finally {
manager.removeArtifact(null, name, version);
}
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class AetherUtils method findDependencies.
private ArtifactResult findDependencies(RepositoryManager manager, Node node, Boolean fetchSingleArtifact) {
final ArtifactContext ac = ArtifactContext.fromNode(node);
if (ac == null)
return null;
final String name = ac.getName();
String[] groupArtifactIds = nameToGroupArtifactIds(name);
if (groupArtifactIds == null) {
return null;
}
String groupId = groupArtifactIds[0];
String artifactId = groupArtifactIds[1];
String classifier = groupArtifactIds[2];
String version = ac.getVersion();
String repositoryDisplayString = NodeUtils.getRepositoryDisplayString(node);
CmrRepository repository = NodeUtils.getRepository(node);
if (CeylonUtils.arrayContains(ac.getSuffixes(), ArtifactContext.LEGACY_SRC)) {
classifier = "sources";
}
return fetchDependencies(manager, repository, groupId, artifactId, classifier, version, fetchSingleArtifact != null ? fetchSingleArtifact : ac.isIgnoreDependencies(), repositoryDisplayString);
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class MavenRepositoryBuilder method createMavenRepository.
private CmrRepository[] createMavenRepository(String token, String prefix, RepositoryBuilderConfig config) throws Exception {
String settingsXml = null;
if (prefix != null) {
String settings = token.substring(prefix.length());
// backwards compat: ignore overrides from here, previously located after | symbol
int p = settings.indexOf("|");
if (p < 0) {
settingsXml = settings;
} else {
settingsXml = settings.substring(0, p);
}
}
Class<?> aetherRepositoryClass = Class.forName(AETHER_REPOSITORY_CLASS);
Method createRepository = aetherRepositoryClass.getMethod("createRepository", Logger.class, String.class, boolean.class, int.class, String.class);
CmrRepository repo = (CmrRepository) createRepository.invoke(null, config.log, settingsXml, config.offline, config.timeout, config.currentDirectory);
return new CmrRepository[] { repo };
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class NodeUtils method getRepository.
/**
* Get repository info.
*
* @param node the node
* @return repository info
*/
public static CmrRepository getRepository(Node node) {
if (node instanceof OpenNode) {
final OpenNode on = (OpenNode) node;
final Node info = on.peekChild(INFO);
return (info != null) ? info.getValue(CmrRepository.class) : null;
}
return null;
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class AetherUtils method createArtifactResult.
protected ArtifactResult createArtifactResult(final RepositoryManager manager, CmrRepository repository, final String groupId, final String artifactId, final String classifier, final String dVersion, final boolean shared, final boolean optional, final ModuleScope scope, final String repositoryDisplayString, final List<ExclusionDescriptor> exclusions) {
final String dName = MavenUtils.moduleName(groupId, artifactId, classifier);
return new MavenArtifactResult(repository, dName, dVersion, groupId, artifactId, classifier, repositoryDisplayString) {
private ArtifactResult result;
{
if (exclusions != null) {
List<Exclusion> ret = new ArrayList<>(exclusions.size());
for (ExclusionDescriptor xDescr : exclusions) {
ret.add(new Exclusion(xDescr.getGroupId(), xDescr.getArtifactId()));
}
setExclusions(ret);
}
}
@Override
public boolean exported() {
return shared;
}
@Override
public boolean optional() {
return optional;
}
@Override
public ModuleScope moduleScope() {
return scope;
}
private synchronized ArtifactResult getResult() {
if (result == null) {
result = fetchDependencies(manager, (CmrRepository) repository(), groupId, artifactId, classifier, dVersion, false, repositoryDisplayString);
}
return result;
}
protected File artifactInternal() throws RepositoryException {
return getResult().artifact();
}
public List<ArtifactResult> dependencies() throws RepositoryException {
return getResult().dependencies();
}
};
}
Aggregations