use of org.eclipse.ceylon.common.tool.ToolUsageError in project ceylon by eclipse.
the class ImportJarToolTests method testBug1630.
@Test
public void testBug1630() throws Exception {
FileUtil.delete(destFile("importtest"));
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--dry-run", "--descriptor", "test/src/org/eclipse/ceylon/tools/test/test-descriptor.properties", "importtest/1.0", "test/src/org/eclipse/ceylon/tools/test/test2.jar"));
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting.", e.getMessage());
}
}
use of org.eclipse.ceylon.common.tool.ToolUsageError in project ceylon by eclipse.
the class ImportJarToolTests method testMissingOptionalPackages.
@Test
public void testMissingOptionalPackages() throws Exception {
// Jetty is compiled for JDK8
Assume.assumeTrue("Runs on JDK8", JDKUtils.jdk == JDKUtils.JDK.JDK8);
CeylonRepoManagerBuilder builder = CeylonUtils.repoManager();
RepositoryManager repository = builder.buildManager();
File artifact = repository.getArtifact(MavenArtifactContext.NAMESPACE, "org.eclipse.jetty:jetty-server", "9.3.2.v20150730");
Assert.assertNotNull(artifact);
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
// no descriptor
CeylonImportJarTool tool;
StringBuilder b = new StringBuilder();
// make sure we don't get a missing package with array shit in there: [Ljavax.servlet;
try {
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.setOut(b);
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting. Try adding a descriptor file, see help for more information.", e.getMessage());
Assert.assertEquals("The following JDK modules are used and could be declared as imports:\n" + " java.base ... [shared]\n" + " java.jdbc ... [shared]\n" + " java.tls ... [shared]\n" + " javax.naming\n" + "Modules containing the following packages need to be declared as imports:\n" + "(Tip: try running again with the '--show-suggestions' option)\n" + " javax.servlet ... [shared]\n" + " javax.servlet.descriptor ... [shared]\n" + " javax.servlet.http ... [shared]\n" + " org.eclipse.jetty.http ... [shared]\n" + " org.eclipse.jetty.io ... [shared]\n" + " org.eclipse.jetty.io.ssl ... [shared]\n" + " org.eclipse.jetty.jmx ... [shared]\n" + " org.eclipse.jetty.util ... [shared]\n" + " org.eclipse.jetty.util.annotation ... [shared]\n" + " org.eclipse.jetty.util.component ... [shared]\n" + " org.eclipse.jetty.util.log ... [shared]\n" + " org.eclipse.jetty.util.resource ... [shared]\n" + " org.eclipse.jetty.util.ssl ... [shared]\n" + " org.eclipse.jetty.util.statistic ... [shared]\n" + " org.eclipse.jetty.util.thread ... [shared]\n", b.toString());
}
// all OK
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-module.properties", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // exact
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.eclipse.jetty.jmx", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // **
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.**.jmx", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // *
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.eclipse.jetty.jm*", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
try {
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // * with dots
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.*.jmx", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting.", e.getMessage());
}
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // ?
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.eclipse.jetty.jm?", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
try {
// with invalid pattern
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", "--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
Assert.fail();
} catch (ToolError e) {
Assert.assertEquals("Invalid missing dependencies descriptor : 'org.eclipse.jetty:jetty-jmxnotfound'. 'Syntax is module-name/module-version=package-wildcard(,package-wildcard)*'.", e.getMessage());
}
}
use of org.eclipse.ceylon.common.tool.ToolUsageError in project ceylon by eclipse.
the class ImportJarToolTests method testWithUnknownModule.
@Test
public void testWithUnknownModule() throws Exception {
FileUtil.delete(destFile("importtest"));
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/test-descriptor-unknown.properties", "importtest/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar"));
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting.", e.getMessage());
}
}
use of org.eclipse.ceylon.common.tool.ToolUsageError in project ceylon by eclipse.
the class ClasspathToolTests method testMissingModule.
@Test
public void testMissingModule() throws Exception {
ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
Assert.assertNotNull(model);
CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("naskduhqwedmansd"));
try {
tool.run();
Assert.fail();
} catch (ToolUsageError x) {
Assert.assertTrue(x.getMessage().contains("Module naskduhqwedmansd not found"));
}
}
use of org.eclipse.ceylon.common.tool.ToolUsageError in project ceylon by eclipse.
the class CeylonHelpTool method startPager.
private Process startPager() {
// find out the pager process, same process as in git
// first try ceylon-specific pager env var
String pager = System.getenv("CEYLON_PAGER");
if (pager == null) {
// first try tool-specific option
String option = CeylonConfig.get().getOption("help.pager");
// if it's neither true nor false it's a pager program
if (option != null && !CeylonConfig.isTrueish(option) && !CeylonConfig.isFalsish(option))
pager = option;
}
if (pager == null) {
// then try general option
String option = CeylonConfig.get().getOption("defaults.pager");
// if it's neither true nor false it's a pager program
if (option != null && !CeylonConfig.isTrueish(option) && !CeylonConfig.isFalsish(option))
pager = option;
}
// then try general pager env var
if (pager == null)
pager = System.getenv("PAGER");
// default to less
if (pager == null)
pager = "less";
// make sure we don't page for cat
if (!pager.equals("cat")) {
// start the pager process
ProcessBuilder pb = new ProcessBuilder(pager);
pb.redirectError(Redirect.INHERIT);
pb.redirectOutput(Redirect.INHERIT);
try {
return pb.start();
} catch (IOException e) {
throw new ToolUsageError("Could not start pager process '" + pager + "'. Try fixing your $CEYLON_PAGER or $PAGER environment variable or invoke with the --no-pager command-line option.", e);
}
}
return null;
}
Aggregations