use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class SmokeTestCase method testSimpleOSGi.
@Test
public void testSimpleOSGi() throws Exception {
RepositoryManager manager = getRepositoryManager();
ArtifactContext context = new ArtifactContext(null, "org.osgi.ceylon.simple", "1.0", ArtifactContext.JAR);
try {
Manifest manifest = mockManifest("1.0");
manifest.getMainAttributes().putValue("Require-Bundle", "moduletest;bundle-version=0.1");
manager.putArtifact(context, mockJar("foo", "bar".getBytes(), manifest));
File file = manager.getArtifact(context);
Assert.assertNotNull(file);
} finally {
manager.removeArtifact(context);
}
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class SmokeTestCase method testGetMultipleCached.
@Test
public void testGetMultipleCached() throws Exception {
RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
CmrRepository[] externalRepos = builder.repositoryBuilder().buildRepository(Constants.REPO_URL_CEYLON);
for (CmrRepository repo : externalRepos) {
builder.addRepository(repo);
}
RepositoryManager manager = builder.buildRepository();
ArtifactContext artifact1 = new ArtifactContext(null, "ceylon.json", "1.0.0", ArtifactContext.CAR, ArtifactContext.SCRIPTS_ZIPPED, ArtifactContext.JS);
List<ArtifactResult> json1 = manager.getArtifactResults(artifact1);
Assert.assertNotNull("Module 'ceylon.json-1.0.0' not found", json1);
Assert.assertEquals("Expected two artifacts for 'ceylon.json-1.0.0'", 2, json1.size());
File root = new File(manager.getRepositories().get(1).getDisplayString());
File missing = new File(root, "ceylon/json/1.0.0/ceylon.json-1.0.0.scripts.zip.missing");
Assert.assertTrue("Marker file .missing not found", missing.exists());
ArtifactContext artifact2 = new ArtifactContext(null, "ceylon.json", "1.0.0", ArtifactContext.CAR, ArtifactContext.SCRIPTS_ZIPPED, ArtifactContext.SRC);
List<ArtifactResult> json2 = manager.getArtifactResults(artifact2);
Assert.assertNotNull("Module 'ceylon.json-1.0.0' not found", json2);
Assert.assertEquals("Expected two artifacts for 'ceylon.json-1.0.0'", 2, json2.size());
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class SmokeTestCase method testOptionalOSGi.
@Test
public void testOptionalOSGi() throws Exception {
RepositoryManager manager = getRepositoryManager();
ArtifactContext context = new ArtifactContext(null, "org.osgi.ceylon.optional", "1.0", ArtifactContext.JAR);
try {
Manifest manifest = mockManifest("1.0");
manifest.getMainAttributes().putValue("Require-Bundle", "moduletest;resolution:=optional;bundle-version=0.1");
manager.putArtifact(context, mockJar("foo", "bar".getBytes(), manifest));
ArtifactResult result = manager.getArtifactResult(context);
Assert.assertNotNull(result);
Assert.assertNotNull(result.dependencies());
Assert.assertEquals(1, result.dependencies().size());
ArtifactResult dep1 = result.dependencies().get(0);
Assert.assertNotNull(dep1);
Assert.assertTrue(dep1.optional());
} finally {
manager.removeArtifact(context);
}
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class SmokeTestCase method testPropertiesGet.
@Test
public void testPropertiesGet() throws Exception {
RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
RepositoryBuilder rb = builder.repositoryBuilder();
CmrRepository[] repositories = rb.buildRepository(Constants.REPO_URL_CEYLON);
for (CmrRepository repo : repositories) {
builder.addRepository(repo);
}
RepositoryManager manager = builder.buildRepository();
ArtifactContext context = new ArtifactContext(null, "io.undertow.core", "1.0.0.Alpha1-9fdfd5f766", ArtifactContext.JAR);
try {
File artifact = manager.getArtifact(context);
Assert.assertNotNull(artifact);
File mp = new File(artifact.getParent(), ArtifactContext.MODULE_PROPERTIES);
Assert.assertNotNull(mp.exists());
} finally {
manager.removeArtifact(context);
}
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class JarUtils method publish.
public static void publish(File outputFile, File sha1File, ArtifactContext context, RepositoryManager repoManager, Logger log) {
try {
context.setForceOperation(true);
// In putting we're effectively renaming
repoManager.putArtifact(context, outputFile);
ArtifactContext sha1Context = context.getSha1Context();
sha1Context.setForceOperation(true);
repoManager.putArtifact(sha1Context, sha1File);
} catch (RuntimeException x) {
log.error("Failed to write module to repository: " + x.getMessage());
// fatal errors go all the way up but don't print anything if we logged an error
throw x;
} finally {
// now cleanup
outputFile.delete();
sha1File.delete();
}
}
Aggregations