class ScriptCompilerCommand extends AbstractCclCommand {

    @Override
    public void run(final CclCommandTerminal terminal) {
        final EtmPoint point = PointFactory.getPoint(getClass(), "run");
        try {
            final String objectName = parseObjectName(sourceCodeLocation);

            final CclResourceUploader uploader = CclResourceUploader.getUploader();
            uploader.queueUpload(sourceCodeLocation);
            for (final File dependency : dependencies)
                uploader.queueUpload(dependency);
            final URI sourceCodeTargetLocation = uploader.upload().get(sourceCodeLocation);

            final String listingOutputFilename = createListingOutputFilename(objectName);
            final File finalListingDestination = localListingDestination == null
                    ? createTemporaryFile(listingOutputFilename)
                    : localListingDestination;

            final Environment environment = Environment.getEnvironment();
            final URI listingTargetLocation = URI.create(environment.getCerTemp() + "/" + listingOutputFilename);

            /*
             * CCL can't handle too long of lines, so put each parameter on its own line
             */
            try {
                final List<String> commands = new ArrayList<String>();
                if (doDebugCompile)
                    commands.add("SET COMPILE = DEBUG go");
                commands.addAll(Arrays.asList("call compile(", "'" + sourceCodeTargetLocation.getPath() + "',",
                        "'" + listingTargetLocation.getPath() + "'", ") go"));
                if (doDebugCompile)
                    commands.add("SET COMPILE = NODEBUG go");
                terminal.executeCommands(new JSchSshTerminal(), commands, false);
            } catch (final SshTimeoutException e) {
                throw new CclCompilationTimeoutException("Compilation of " + objectName + " timed out.", e);
            } catch (final SshException e) {
                throw new CclCommandException("Compilation of " + objectName + " failed.", e);
            }

            // Download and verify the listing output
            final Downloader downloader = SftpDownloader.createDownloader(AuthHelper.fromCurrentSubject());
            downloader.download(Collections
                    .singleton(FileRequestFactory.create(listingTargetLocation, finalListingDestination.toURI())));
            logger.info("validating compile {}", listingOutputFilename);
            CompileErrorValidator.getInstance().validate(finalListingDestination);
        } finally {
            point.collect();
        }
    }

    public  ScriptCompilerCommand(final File sourceCodeLocation, final Collection<File> dependencies,
            final File localListingDestination, final boolean doDebugCompile);

}