use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class RepositoryBuilderImpl method buildRepository.
public CmrRepository[] buildRepository(String token, RepositoryBuilderConfig config) throws Exception {
if (token == null)
throw new IllegalArgumentException("Null repository");
final String key = (token.startsWith("${") ? token.substring(2, token.length() - 1) : token);
final String temp = SecurityActions.getProperty(key);
if (temp != null)
token = temp;
for (RepositoryBuilder builder : builders) {
CmrRepository[] repos = builder.buildRepository(token, config);
if (repos != null) {
return repos;
}
}
return localBuilder.buildRepository(token, config);
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class CeylonRunJsTool method run.
@Override
public void run() throws Exception {
// The timeout is to have enough time to start reading on the process streams
if (systemRepo == null) {
systemRepo = getCeylonRepo();
}
final boolean isDefault = ModuleUtil.isDefaultModule(module);
String version;
final String modname;
if (isDefault) {
modname = module;
version = "";
} else {
version = ModuleUtil.moduleVersion(module);
modname = ModuleUtil.moduleName(module);
}
compileFlags = processCompileFlags(compileFlags, DefaultToolOptions.getRunToolCompileFlags(org.eclipse.ceylon.common.Backend.JavaScript));
version = checkModuleVersionsOrShowSuggestions(modname, version, ModuleQuery.Type.JS, // JVM binary but don't care since JS
null, null, Versions.JS_BINARY_MAJOR_VERSION, Versions.JS_BINARY_MINOR_VERSION, compileFlags);
if (version == null) {
return;
}
File jsmod = getArtifact(getRepositoryManager(), modname, version, false);
// NB localRepos will contain a set of files pointing to the module repositories
// where all the needed modules can be found
List<File> localRepos = new ArrayList<>();
for (CmrRepository r : getRepositoryManager().getRepositories()) {
if (!r.getRoot().isRemote()) {
File f = new File(r.getDisplayString());
if (!localRepos.contains(f)) {
localRepos.add(f);
}
}
}
File rd = getRepoDir(modname, jsmod);
if (!localRepos.contains(rd)) {
localRepos.add(rd);
}
final Set<String> loadedDependencies = new HashSet<>();
loadedDependencies.add(module);
loadDependencies(localRepos, getRepositoryManager(), jsmod, loadedDependencies);
customizeDependencies(localRepos, getRepositoryManager(), loadedDependencies);
func = func != null ? func : "run";
final ProcessBuilder proc = buildProcess(modname, version, func, args, exepath, localRepos, output);
final Process nodeProcess = proc.start();
// All this shit because inheritIO doesn't work on fucking Windows
new ReadStream(nodeProcess.getInputStream(), output == null ? System.out : output).start();
if (output == null) {
new ReadErrorStream(nodeProcess.getErrorStream(), System.err, debug).start();
}
Thread stopThread = new Thread() {
public void run() {
try {
nodeProcess.destroy();
} catch (Throwable t) {
}
}
};
try {
try {
Runtime.getRuntime().addShutdownHook(stopThread);
} catch (Throwable t) {
}
int exitCode = nodeProcess.waitFor();
if (exitCode != 0) {
if (exitCode == 11)
exitCode = 2;
throw new CeylonRunJsException("Node process exited with non-zero exit code: " + exitCode, exitCode);
}
} finally {
try {
Runtime.getRuntime().removeShutdownHook(stopThread);
} catch (Throwable t) {
}
}
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class CallbackTestCase method doTest.
protected void doTest(ArtifactContext context, TestArtifactCallback callback) throws Exception {
String repoURL = "http://jboss-as7-modules-repository.googlecode.com/svn/trunk/ceylon";
try {
new URL(repoURL).openStream();
} catch (Exception e) {
log.error(String.format("Cannot connect to repo %s - %s", repoURL, e));
// probably not on the internet?
return;
}
RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
RemoteContentStore rcs = new RemoteContentStore(repoURL, log, false, 60000, java.net.Proxy.NO_PROXY);
CmrRepository repo = new DefaultRepository(rcs.createRoot());
RepositoryManager manager = builder.addRepository(repo).buildRepository();
try {
File file = manager.getArtifact(context);
Assert.assertNotNull(file);
Assert.assertTrue(callback.size > 0);
Assert.assertEquals(callback.size, callback.current);
} catch (Exception re) {
Assert.assertNotNull(callback.ts);
Assert.assertNotNull(callback.err);
Assert.assertEquals(callback.ts, callback.err.getMessage());
} finally {
manager.removeArtifact(null, name, version);
// test if remove really works
testSearchResults("org.eclipse.fizbiz", ModuleQuery.Type.JVM, new ModuleSearchResult.ModuleDetails[0]);
}
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class SmokeTestCase method testGetMultiple.
@Test
public void testGetMultiple() 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 artifact = new ArtifactContext(null, "ceylon.json", "1.0.0", ArtifactContext.CAR, ArtifactContext.SCRIPTS_ZIPPED, ArtifactContext.JS);
List<ArtifactResult> json = manager.getArtifactResults(artifact);
Assert.assertNotNull("Module 'ceylon.json-1.0.0' not found", json);
Assert.assertEquals("Expected two artifacts for 'ceylon.json-1.0.0'", 2, json.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());
}
use of org.eclipse.ceylon.cmr.api.CmrRepository in project ceylon by eclipse.
the class SmokeTestCase method testRemoteContent.
@Test
public void testRemoteContent() throws Exception {
String repoURL = "http://jboss-as7-modules-repository.googlecode.com/svn/trunk/ceylon";
try {
new URL(repoURL).openStream();
} catch (Exception e) {
log.error(String.format("Cannot connect to repo %s - %s", repoURL, e));
// probably not on the internet?
return;
}
RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
RemoteContentStore rcs = new RemoteContentStore(repoURL, log, false, 60000, java.net.Proxy.NO_PROXY);
CmrRepository repo = new DefaultRepository(rcs.createRoot());
RepositoryManager manager = builder.addRepository(repo).buildRepository();
String name = "org.eclipse.fizbiz";
String version = "1.0.0.Beta1";
File file = null;
File originFile = null;
try {
file = manager.getArtifact(null, name, version);
Assert.assertNotNull(file);
originFile = new File(file.getAbsolutePath() + ".origin");
Assert.assertNotNull(originFile);
try {
String line;
try (BufferedReader reader = new BufferedReader(new FileReader(originFile))) {
line = reader.readLine();
}
assertEquals(repoURL, line);
} catch (IOException ignored) {
}
} finally {
manager.removeArtifact(null, name, version);
// test if remove really works
if (file != null)
assertFalse(file.exists());
if (originFile != null)
assertFalse(originFile.exists());
testSearchResults("org.eclipse.fizbiz", Type.JVM, new ModuleDetails[0]);
}
}
Aggregations