public void buildMultiReleaseJar() throws IOException {
   JarBuilder jb = customMultiReleaseJar("multi-release.jar", "true");
   addEntries(jb);
   jb.addEntry(
       "META-INF/versions/9/version/Version.class", version9Classes.get("version.Version"));
   jb.build();
 }
 public void buildCustomMultiReleaseJar(
     String filename, String multiReleaseValue, Map<String, String> extraAttributes)
     throws IOException {
   JarBuilder jb = new JarBuilder(filename);
   extraAttributes.entrySet().forEach(entry -> jb.addAttribute(entry.getKey(), entry.getValue()));
   jb.addAttribute("Multi-Release", multiReleaseValue);
   jb.build();
 }
 public void buildUnversionedJar() throws IOException {
   JarBuilder jb = new JarBuilder("unversioned.jar");
   jb.addEntry("README", readme8.getBytes());
   jb.addEntry("version/Main.java", main.getBytes());
   jb.addEntry("version/Main.class", rootClasses.get("version.Main"));
   jb.addEntry("version/Version.java", java8.getBytes());
   jb.addEntry("version/Version.class", rootClasses.get("version.Version"));
   jb.build();
 }
 private static File buildJar2() throws FileNotFoundException, IOException {
   JarBuilder jar2Builder = new JarBuilder(tmpFolder, "jar2.jar");
   jar2Builder.addResourceFile("com/jar2/resource.file", "jar2");
   jar2Builder.addResourceFile("com/test/resource2.file", "resource2");
   return jar2Builder.build();
 }
 private static File buildJar3() throws FileNotFoundException, IOException {
   JarBuilder jar3Builder = new JarBuilder(tmpFolder, "jar3.jar");
   jar3Builder.addResourceFile("com/test/resource3.file", "resource3");
   jar3Builder.addResourceFile("com/missing/jar3/resource.file", "jar3");
   return jar3Builder.build();
 }
Example #6
0
 void addEntryToJarOutput(final String key, final byte[] bytes) throws VoltCompilerException {
   m_jarBuilder.addEntry(key, bytes);
 }
Example #7
0
  /**
   * @param projectFileURL URL of the project file.
   * @param clusterConfig Object containing desired physical cluster parameters
   * @param jarOutputPath The location to put the finished JAR to.
   * @param output Where to print status/errors to, usually stdout.
   * @param procInfoOverrides Optional overridden values for procedure annotations.
   */
  public boolean compile(
      final String projectFileURL,
      final ClusterConfig clusterConfig,
      final String jarOutputPath,
      final PrintStream output,
      final Map<String, ProcInfoData> procInfoOverrides) {
    m_hsql = null;
    m_projectFileURL = projectFileURL;
    m_jarOutputPath = jarOutputPath;
    m_outputStream = output;
    // use this map as default annotation values
    m_procInfoOverrides = procInfoOverrides;

    LOG.l7dlog(
        Level.DEBUG,
        LogKeys.compiler_VoltCompiler_LeaderAndHostCountAndSitesPerHost.name(),
        new Object[] {
          clusterConfig.getLeaderAddress(),
          clusterConfig.getHostCount(),
          clusterConfig.getSitesPerHost()
        },
        null);

    // do all the work to get the catalog
    final Catalog catalog = compileCatalog(projectFileURL, clusterConfig);
    if (catalog == null) {
      LOG.error(
          "VoltCompiler had " + m_errors.size() + " errors\n" + StringUtil.join("\n", m_errors));
      return (false);
    }

    // WRITE CATALOG TO JAR HERE
    final String catalogCommands = catalog.serialize();

    byte[] catalogBytes = null;
    try {
      catalogBytes = catalogCommands.getBytes("UTF-8");
    } catch (final UnsupportedEncodingException e1) {
      addErr("Can't encode the compiled catalog file correctly");
      return false;
    }

    // Create Dtxn.Coordinator configuration for cluster
    //        byte[] dtxnConfBytes = null;
    //        try {
    //            dtxnConfBytes = HStoreDtxnConf.toHStoreDtxnConf(catalog).getBytes("UTF-8");
    //        } catch (final Exception e1) {
    //            addErr("Can't encode the Dtxn.Coordinator configuration file correctly");
    //            return false;
    //        }

    try {
      //            m_jarBuilder.addEntry("dtxn.conf", dtxnConfBytes);
      m_jarBuilder.addEntry(CatalogUtil.CATALOG_FILENAME, catalogBytes);
      m_jarBuilder.addEntry("project.xml", new File(projectFileURL));
      for (final Entry<String, String> e : m_ddlFilePaths.entrySet())
        m_jarBuilder.addEntry(e.getKey(), new File(e.getValue()));
      m_jarBuilder.writeJarToDisk(jarOutputPath);
    } catch (final VoltCompilerException e) {
      return false;
    }

    assert (!hasErrors());

    if (hasErrors()) {
      return false;
    }

    return true;
  }
 public void buildShortMultiReleaseJar() throws IOException {
   JarBuilder jb = customMultiReleaseJar("short-multi-release.jar", "true");
   addEntries(jb);
   jb.build();
 }
 private void addEntries(JarBuilder jb) {
   jb.addEntry("README", readme8.getBytes());
   jb.addEntry("version/Main.java", main.getBytes());
   jb.addEntry("version/Main.class", rootClasses.get("version.Main"));
   jb.addEntry("version/Version.java", java8.getBytes());
   jb.addEntry("version/Version.class", rootClasses.get("version.Version"));
   jb.addEntry("META-INF/versions/9/README", readme9.getBytes());
   jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes());
   jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes());
   jb.addEntry(
       "META-INF/versions/9/version/PackagePrivate.class",
       version9Classes.get("version.PackagePrivate"));
   jb.addEntry("META-INF/versions/10/README", readme10.getBytes());
   jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes());
   jb.addEntry(
       "META-INF/versions/10/version/Version.class", version10Classes.get("version.Version"));
 }
 private JarBuilder customMultiReleaseJar(String filename, String multiReleaseValue)
     throws IOException {
   JarBuilder jb = new JarBuilder(filename);
   jb.addAttribute("Multi-Release", multiReleaseValue);
   return jb;
 }