use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.
the class ImportJarToolTests method testDescriptorSuffix.
@Test
public void testDescriptorSuffix() {
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/ImportJarToolTests.java", "test/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar"));
Assert.fail();
} catch (ImportJarException e) {
Assert.assertEquals("Descriptor file test/src/org/eclipse/ceylon/tools/test/ImportJarToolTests.java does not end with '.xml' or '.properties' extension", e.getMessage().replace('\\', '/'));
}
}
use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.
the class ImportJarToolTests method testWithPropertiesDescriptorCwd.
@Test
public void testWithPropertiesDescriptorCwd() throws Exception {
File destDir = destFile("importtest");
FileUtil.delete(destDir);
destDir.mkdirs();
FileUtil.copyAll(new File("test/src/org/eclipse/ceylon/tools/test/test-descriptor.properties"), destDir);
FileUtil.copyAll(new File("test/src/org/eclipse/ceylon/tools/test/test.jar"), destDir);
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("--cwd", destDir.getPath(), "--cacherep", getCachePath(), "--sysrep", getSysRepPath(), "--descriptor", "test-descriptor.properties", "importtest/1.0", "test.jar"));
tool.run();
File f1 = destFile("importtest/modules/importtest/1.0/importtest-1.0.jar");
File f2 = destFile("importtest/modules/importtest/1.0/importtest-1.0.jar.sha1");
File f3 = destFile("importtest/modules/importtest/1.0/module.properties");
Assert.assertTrue(f1.exists() && f2.exists());
Assert.assertTrue(f3.exists());
}
use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.
the class ImportJarToolTests method testModuleOnlyJar.
@Test
public void testModuleOnlyJar() {
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
try {
CeylonImportJarTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("test", "my.jar"));
Assert.fail();
} catch (OptionArgumentException e) {
Assert.assertEquals("Invalid value 'test' given for argument 'module' to command 'import-jar'", e.getMessage());
}
}
use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.
the class ImportJarToolTests method checkModuleDescriptor.
protected void checkModuleDescriptor(RepositoryManager repository, String module, String version) throws Exception {
System.err.println("Checking " + module + "/" + version);
File artifact = repository.getArtifact(new ArtifactContext(null, module, version, ArtifactContext.CAR, ArtifactContext.JAR));
File descr = new File(artifact.getParentFile(), "module.xml");
Assert.assertNotNull(artifact);
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
CeylonImportJarTool tool;
List<String> options = toolOptions("--dry-run", "--allow-cars", "--descriptor", descr.getAbsolutePath(), module + "/" + version, artifact.getAbsolutePath());
if (module.equals("org.apache.commons.logging")) {
options.addAll(0, Arrays.asList("--missing-dependency-packages", "org.apache.avalon.framework/4.1.3=org.apache.avalon.framework.**", "--missing-dependency-packages", "org.apache.log4j/1.2.12=org.apache.log4j.**", "--missing-dependency-packages", "org.apache.logkit/1.0.1=org.apache.log.**"));
}
if (module.startsWith("org.eclipse.ceylon.aether")) {
options.addAll(0, Arrays.asList("--ignore-annotations"));
}
tool = pluginFactory.bindArguments(model, getMainTool(), options);
tool.run();
}
use of org.eclipse.ceylon.tools.importjar.CeylonImportJarTool in project ceylon by eclipse.
the class ImportJarToolTests method testWithInvalidXmlDescriptor.
@Test
public void testWithInvalidXmlDescriptor() 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-broken.xml", "importtest/1.0", "test/src/org/eclipse/ceylon/tools/test/test.jar"));
tool.run();
Assert.fail();
} catch (ImportJarException e) {
Assert.assertEquals("Descriptor file test/src/org/eclipse/ceylon/tools/test/test-descriptor-broken.xml is not a valid module.xml file: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.", e.getMessage().replace('\\', '/'));
}
}
Aggregations