Search in sources :

Example 16 with CeylonImportJarTool

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('\\', '/'));
    }
}
Also used : ImportJarException(org.eclipse.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 17 with CeylonImportJarTool

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());
}
Also used : CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) File(java.io.File) Test(org.junit.Test)

Example 18 with CeylonImportJarTool

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());
    }
}
Also used : OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Example 19 with CeylonImportJarTool

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();
}
Also used : CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) MavenArtifactContext(org.eclipse.ceylon.cmr.api.MavenArtifactContext) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File)

Example 20 with CeylonImportJarTool

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('\\', '/'));
    }
}
Also used : ImportJarException(org.eclipse.ceylon.tools.importjar.ImportJarException) CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) Test(org.junit.Test)

Aggregations

CeylonImportJarTool (org.eclipse.ceylon.tools.importjar.CeylonImportJarTool)23 Test (org.junit.Test)22 File (java.io.File)12 ImportJarException (org.eclipse.ceylon.tools.importjar.ImportJarException)6 OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)3 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)3 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)1 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)1 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)1 CeylonRepoManagerBuilder (org.eclipse.ceylon.cmr.ceylon.CeylonUtils.CeylonRepoManagerBuilder)1 ToolError (org.eclipse.ceylon.common.tool.ToolError)1