Package de.matrixweb.smaller.resource.impl

Examples of de.matrixweb.smaller.resource.impl.JavaEEProcessorFactory


    final Task task = new Task();
    task.setProcessor(processors);
    task.setIn(resources.toArray(new String[resources.size()]));
    task.setOut(new String[] { "output.js", "output.css" });
    task.setOptionsDefinition(options);
    final ProcessorFactory processorFactory = new JavaEEProcessorFactory();
    try {
      final VFS vfs = new VFS();
      try {
        vfs.mount(vfs.find("/"), new ServletFile(getServletContext(), "/"));
        this.result = new Pipeline(processorFactory).execute(
            Version.getCurrentVersion(), vfs, new VFSResourceResolver(vfs),
            task);
      } finally {
        vfs.dispose();
      }
    } catch (final IOException e) {
      throw new ServletException("Failed to setup vfs", e);
    } finally {
      processorFactory.dispose();
    }
  }
View Full Code Here


      protected void executeSmaller(final File base,
          final List<String> includedFiles, final File target,
          final String host, final String port, final String proxyhost,
          final String proxyport, final ConfigFile configFile)
          throws ExecutionException {
        final ProcessorFactory processorFactory = new JavaEEProcessorFactory();
        try {
          final VFS vfs = new VFS(new Logger() {
            @Override
            public void debug(final String message) {
              getLog().debug(message);
            }

            @Override
            public void info(final String messsage) {
              getLog().info(messsage);
            }

            @Override
            public void error(final String message, final Exception e) {
              getLog().error(message, e);
            }
          });
          try {
            getLog().info("MVN: Adding " + base + " to VFS");
            vfs.mount(vfs.find("/"), new JavaFile(base));
            final ResourceResolver resolver = new VFSResourceResolver(vfs);
            final Manifest manifest = Manifest.fromConfigFile(configFile);
            final Pipeline pipeline = new Pipeline(processorFactory);
            pipeline.execute(Version.getCurrentVersion(), vfs, resolver,
                manifest, target);
          } finally {
            vfs.dispose();
          }
        } catch (final IOException e) {
          throw new ExecutionException("Embedded smaller failed", e);
        } finally {
          processorFactory.dispose();
        }
      }
    };
    client.execute();
  }
View Full Code Here

  protected boolean runToolChain(final Version minimum, final String file,
      final ToolChainCallback callback) throws Exception {
    if (Version.getCurrentVersion().isAtLeast(minimum)) {
      System.out.println("\nRun test: " + file);
      final File target = File.createTempFile("smaller-test-", ".dir");
      final ProcessorFactory processorFactory = new JavaEEProcessorFactory();
      try {
        assertTrue(target.delete());
        assertTrue(target.mkdir());
        final File source = FileUtils.toFile(this.getClass().getResource(
            "/" + file));
        final VFS vfs = new VFS();
        try {
          vfs.mount(vfs.find("/"), new JavaFile(source));
          final ResourceResolver resolver = new VFSResourceResolver(vfs);
          final Manifest manifest = getManifest(source);
          new Pipeline(processorFactory).execute(Version.getCurrentVersion(),
              vfs, resolver, manifest, target);
          callback.test(vfs, manifest);
        } finally {
          vfs.dispose();
        }
      } finally {
        processorFactory.dispose();
        FileUtils.deleteDirectory(target);
      }
      return true;
    }
    return false;
View Full Code Here

  /**
   * @see org.apache.tools.ant.Task#execute()
   */
  @Override
  public void execute() {
    final ProcessorFactory processorFactory = new JavaEEProcessorFactory();
    try {
      final File temp = File.createTempFile("smaller-ant", ".dir");
      try {
        temp.delete();
        temp.mkdirs();

        log("Reading config-file: " + this.configFilePath);
        final ConfigFile configFile = ConfigFile.read(this.configFilePath);

        final List<String> includedFiles = new ArrayList<String>();
        for (final String envName : configFile.getBuildServer()
            .getEnvironments()) {
          final Environment env = configFile.getEnvironments().get(envName);
          for (final String dir : env.getFiles().getFolder()) {
            copyFirstInputFile(env, dir, temp);

            File base = new File(dir);
            if (!base.isAbsolute()) {
              base = new File(this.configFilePath.getParentFile(),
                  base.getPath());
            }
            final String[] included = scanIncludedFiles(base.getAbsolutePath(),
                env.getFiles().getIncludes(), env.getFiles().getExcludes());

            for (final String include : included) {
              FileUtils.copyFile(new File(base, include), new File(temp,
                  include));
              includedFiles.add(include);
            }
          }
        }

        final VFS vfs = new VFS();
        try {
          vfs.mount(vfs.find("/"), new JavaFile(temp));
          final ResourceResolver resolver = new VFSResourceResolver(vfs);

          final Manifest manifest = Manifest.fromConfigFile(configFile);
          final Pipeline pipeline = new Pipeline(processorFactory);
          pipeline.execute(Version.getCurrentVersion(), vfs, resolver,
              manifest, this.target);
        } finally {
          vfs.dispose();
        }

      } finally {
        FileUtils.deleteDirectory(temp);
      }
    } catch (final IOException e) {
      log(Util.formatException(e), Project.MSG_ERR);
      throw new BuildException("Failed execute embedded smaller", e);
    } finally {
      processorFactory.dispose();
    }
  }
View Full Code Here

TOP

Related Classes of de.matrixweb.smaller.resource.impl.JavaEEProcessorFactory

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.