All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javaposse.jobdsl.Run Maven / Gradle / Ivy

There is a newer version: 1.22-rxd-2
Show newest version
package javaposse.jobdsl;

import javaposse.jobdsl.dsl.DslScriptLoader;
import javaposse.jobdsl.dsl.FileJobManagement;
import javaposse.jobdsl.dsl.GeneratedJob;
import javaposse.jobdsl.dsl.ScriptRequest;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Able to run from the command line to test out. Leverage FileJobManagement
 */
public class Run {

    public static void main(String[] args) throws Exception {
        if(args.length == 0) {
            throw new RuntimeException("Script name is required");
        }

        File cwd = new File(".");
        URL cwdURL = cwd.toURI().toURL();

        FileJobManagement jm = new FileJobManagement(cwd);
        jm.getParameters().putAll(System.getenv());
        for(Map.Entry entry: System.getProperties().entrySet()) {
            jm.getParameters().put(entry.getKey().toString(), entry.getValue().toString());
        }

        Collection scripts = new ArrayList();
        for(String arg: args) {
            if(arg.startsWith("--")) {
                scripts.add(arg);
            }
        }

        for(String scriptName: args) {
            ScriptRequest request = new ScriptRequest(scriptName, null, cwdURL, false);
            Set generatedJobs = DslScriptLoader.runDslEngine(request, jm);

            for(GeneratedJob job: generatedJobs) {
                System.out.println("From "+ scriptName + ", Generated: " + job);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy