Package org.milyn.archive

Examples of org.milyn.archive.Archive$DeleteOnExitHook


    for (EPackage pkg : packages) {
      if ("cuscar".equals(pkg.getName()) || "invoic".equals(pkg.getName())) {
        smallerSet.add(pkg);
      }
    }
    Archive archive = SchemaConverter.INSTANCE.createArchive(smallerSet, pluginID, pathPrefix);
    archive.toOutputStream(new ZipOutputStream(new FileOutputStream(new File("./target/" + archive.getArchiveName()))));
  }
View Full Code Here


  public Archive createArchive(Set<EPackage> packages, String pluginID, String pathPrefix)
      throws IOException {
    String qualifier = qualifierFormat.format(Calendar.getInstance()
        .getTime());

    Archive archive = new Archive(pluginID + "_1.0.0.v" + qualifier
        + ".jar");
    StringBuilder pluginBuilder = new StringBuilder(
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<?eclipse version=\"3.0\"?>\n" + "<plugin>\n");
    StringBuilder xmlExtension = new StringBuilder(
        "\t<extension point=\"org.eclipse.wst.xml.core.catalogContributions\"><catalogContribution>\n");

    for (EPackage pkg : packages) {
      ResourceSet rs = createResourceSet();
      Resource resource = addSchemaResource(rs, pkg);
      EObject obj = resource.getContents().get(0);
      String fileName = resource.getURI().lastSegment();
      String ecoreEntryPath = pathPrefix + "/" + fileName;
      xmlExtension.append(saveSchema(archive, ecoreEntryPath, resource,
          ((XSDSchema) obj).getTargetNamespace(), pluginID));
      // Save memory
      System.gc();
    }

    xmlExtension.append("\t</catalogContribution></extension>\n");
    pluginBuilder.append(xmlExtension);
    pluginBuilder.append("</plugin>");
    archive.addEntry(FRAGMENT_XML_ENTRY, pluginBuilder.toString());

    return archive;
  }
View Full Code Here

    @Rule
    public TemporaryFolder tempFolder = new TemporaryFolder();

    @Test
    public void merge_resources_from_two_jars() throws Exception {
        final Archive firstJar = setupFirstJar();
        final Archive secondJar = setupSecondJar();

        final Archive mergedJar = resourceMerger.mergeJars("smooks-all.jar", Arrays.asList(firstJar, secondJar));

        assertThat(mergedJar.getArchiveName(), is("smooks-all.jar"));

        final String contentHandlers = readContent(mergedJar, CONTENT_HANDLER_PATH);
        assertThat(contentHandlers, containsString("property1"));
        assertThat(contentHandlers, containsString("property2"));
View Full Code Here

        final String content = readContent(mergedJar, "firstJar/someFile");
        assertThat(content, is("dummyContent"));
    }

    private Archive setupFirstJar() throws Exception {
        final Archive jar = new Archive("firstJar");
        addToJar(jar, "firstJar/someFile", "dummyContent");
        return addToJar(jar, CONTENT_HANDLER_PATH, "property1");
    }
View Full Code Here

        addToJar(jar, "firstJar/someFile", "dummyContent");
        return addToJar(jar, CONTENT_HANDLER_PATH, "property1");
    }

    private Archive setupSecondJar() throws Exception {
        final Archive jar = new Archive("secondJar");
        return addToJar(jar, CONTENT_HANDLER_PATH, "property2");
    }
View Full Code Here

    }

    @Test
    public void merge_with_pre_existing_jar() throws Exception {
        final File jarfile = setupPreExistingJar();
        final Archive firstJar = setupFirstJar();

        final Archive merged = resourceMerger.mergeJars(jarfile.getAbsolutePath(), Arrays.asList(firstJar));

        assertThat(readContent(merged, "firstJar/someFile"), is("dummyContent"));
        assertThat(readContent(merged, "preExistingJar/file"), is("contentInPreExistingJar"));
    }
View Full Code Here

        assertThat(readContent(merged, "preExistingJar/file"), is("contentInPreExistingJar"));
    }

    private File setupPreExistingJar() throws Exception {
        final String jarname = "prexisting.jar";
        final Archive preExistingJar = createPreExistingJar();
        return exportJarToFile(jarname, preExistingJar);
    }
View Full Code Here

        return exportJarToFile(jarname, preExistingJar);
    }

    private Archive createPreExistingJar() throws Exception {
        final String jarname = "prexisting.jar";
        final Archive preExistingJar = new Archive(jarname);
        addToJar(preExistingJar, "preExistingJar/file", "contentInPreExistingJar");
        addToJar(preExistingJar, JarFile.MANIFEST_NAME, "manifesto");
        return preExistingJar;
    }
View Full Code Here

        return jarfile;
    }

    @Test
    public void verify_that_metainf_is_the_first_entry_in_jar() throws Exception {
        final Archive firstJar = setupFirstJar();
        final File jarfile = setupPreExistingJar();

        final Archive merged = resourceMerger.mergeJars(jarfile.getAbsolutePath(), Arrays.asList(firstJar));

        final byte[] content = merged.getEntryBytes(JarFile.MANIFEST_NAME);
        assertThat(content, is(notNullValue()));

        final File newFile = exportJarToFile(merged, "output.jar");
        final Manifest manifest = getManifest(newFile.getAbsolutePath());
        assertNotNull("Manifest could not be found by JarInputStream", manifest);
View Full Code Here

            // Compile it...
            antRunner.run("compile");

            // Build and return an archive instance from the compiled sources...
            return new Archive(new ZipInputStream(new FileInputStream("./target/ejc/ejc.jar")));
        } finally {
            Thread.currentThread().setContextClassLoader(origTCCL);
        }
    }
View Full Code Here

TOP

Related Classes of org.milyn.archive.Archive$DeleteOnExitHook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.