Java Code Examples for com.martiansoftware.jsap.JSAP#parse()

The following examples show how to use com.martiansoftware.jsap.JSAP#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Launcher.java    From repairnator with MIT License 5 votes vote down vote up
public static void init(String[] args) throws JSAPException{
    JSAP jsap = defineBasicArgs();
    JSAPResult res = jsap.parse(args);
    String choice = res.getString("launcherChoice");
    if (choice.equals("OLD")) {
        launcher = new LegacyLauncher(args);
    } else {
        launcher = new BranchLauncher(args);
    }
}
 
Example 2
Source File: Launcher.java    From repairnator with MIT License 5 votes vote down vote up
public static void main(String[] args) throws JSAPException{
    JSAP jsap = defineBasicArgs();
    JSAPResult jsapResult = jsap.parse(args); 
    String choice = jsapResult.getString("launcherChoice");

    if (choice.equals("OLD") ) {
        launcher = new LegacyLauncher(args);
    } else {
        launcher = new BranchLauncher(args);
    }
    RepairnatorConfig.getInstance().setSonarRules(removeDuplicatesInArray(jsapResult.getString("sonarRules").split(",")));
    launcher.launch();
}
 
Example 3
Source File: LegacyLauncher.java    From repairnator with MIT License 5 votes vote down vote up
public LegacyLauncher(String[] args) throws JSAPException {
    InputStream propertyStream = getClass().getResourceAsStream("/version.properties");
    Properties properties = new Properties();
    if (propertyStream != null) {
        try {
            properties.load(propertyStream);
        } catch (IOException e) {
            LOGGER.error("Error while loading property file.", e);
        }
        LOGGER.info("PIPELINE VERSION: "+properties.getProperty("PIPELINE_VERSION"));
    } else {
        LOGGER.info("No information about PIPELINE VERSION has been found.");
    }

    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.PIPELINE);
    this.initConfig(arguments);

    if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) {
        this.checkToolsLoaded(jsap);
        this.checkNopolSolverPath(jsap);
        LOGGER.info("The pipeline will try to repair the following build id: "+this.getConfig().getBuildId());
    } else {
        this.checkNextBuildId(jsap);
        LOGGER.info("The pipeline will try to reproduce a bug from build "+this.getConfig().getBuildId()+" and its corresponding patch from build "+this.getConfig().getNextBuildId());
    }

    if (this.getConfig().isDebug()) {
        Utils.setLoggersLevel(Level.DEBUG);
    } else {
        Utils.setLoggersLevel(Level.INFO);
    }

    this.initSerializerEngines();
    this.initNotifiers();
}
 
Example 4
Source File: BranchLauncher.java    From repairnator with MIT License 5 votes vote down vote up
public static void main(String[] args) throws JSAPException {
	JSAP jsap = defineBasicArgs();
	JSAPResult jsapResult = jsap.parse(args);
	
	MainProcess mainProcess = getMainProcess(jsap,args);
	mainProcess.run();
}
 
Example 5
Source File: CheckBranchLauncher.java    From repairnator with MIT License 5 votes vote down vote up
private CheckBranchLauncher(String[] args) throws JSAPException {
    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.CHECKBRANCHES);

    this.initConfig(arguments);
    this.initNotifiers();
}
 
Example 6
Source File: BuildAnalyzerLauncher.java    From repairnator with MIT License 5 votes vote down vote up
private BuildAnalyzerLauncher(String[] args) throws JSAPException {
    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.DOCKERPOOL);

    this.initConfig(arguments);
    this.initSerializerEngines();
    this.initNotifiers();
}
 
Example 7
Source File: RTLauncher.java    From repairnator with MIT License 5 votes vote down vote up
private RTLauncher(String[] args) throws JSAPException {
    JSAP jsap = this.defineArgs();
    JSAPResult arguments = jsap.parse(args);
    LauncherUtils.checkArguments(jsap, arguments, LauncherType.REALTIME);

    this.initConfig(arguments);
    this.initSerializerEngines();
    this.initNotifiers();
    this.initSummaryEmails();
}
 
Example 8
Source File: GithubInitConfig.java    From repairnator with MIT License 4 votes vote down vote up
@Override
public void initConfigWithJSAP(JSAP jsap, String[] inputArgs) {
       JSAPResult arguments = jsap.parse(inputArgs);
	if (LauncherUtils.getArgDebug(arguments)) {
           getConfig().setDebug(true);
       }
       getConfig().setClean(true);
       getConfig().setRunId(LauncherUtils.getArgRunId(arguments));
       getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments));
       
       if (GitRepositoryLauncherUtils.getArgGitRepositoryMode(arguments)) {
           if (GitRepositoryLauncherUtils.getArgGitRepositoryFirstCommit(arguments)) {
               getConfig().setGitRepositoryFirstCommit(true);
           }
       } else {
           System.err.println("Error: Parameter 'gitrepo' is required in GIT_REPOSITORY launcher mode.");
       }
       
       if (LauncherUtils.getArgOutput(arguments) != null) {
           getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath());
       }
       getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments));
       getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments));
       getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments));
       getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments));
       getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments));
       getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments));
       getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments));
       getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments));

       if (LauncherUtils.getArgPushUrl(arguments) != null) {
           getConfig().setPush(true);
           getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments));
       }
       getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments));

       // we fork if we need to create a PR or if we need to notify
       if ((getConfig().isCreatePR() || (getConfig().getSmtpServer() != null && !getConfig().getSmtpServer().isEmpty() && getConfig().getNotifyTo() != null && getConfig().getNotifyTo().length > 0)) && getConfig().getGithubToken() != null) {
           getConfig().setFork(true);
       }

       if (arguments.getString("gitRepositoryUrl") == null) {
           System.err.println("Error: Parameter 'gitrepourl' is required in GIT_REPOSITORY launcher mode.");
       }

       if (getConfig().isGitRepositoryFirstCommit() && arguments.getString("gitRepositoryIdCommit") != null) {
           System.err.println("Error: Parameters 'gitrepofirstcommit' and 'gitrepoidcommit' cannot be used at the same time.");
       }

       getConfig().setGitRepositoryUrl(arguments.getString("gitRepositoryUrl"));
       getConfig().setGitRepositoryBranch(arguments.getString("gitRepositoryBranch"));
       getConfig().setGitRepositoryIdCommit(arguments.getString("gitRepositoryIdCommit"));
       

       getConfig().setZ3solverPath(new File(arguments.getString("z3")).getPath());
       getConfig().setWorkspacePath(arguments.getString("workspace"));
       if (arguments.getBoolean("tmpDirAsWorkSpace")) {
           tempDir = com.google.common.io.Files.createTempDir();
           getConfig().setWorkspacePath(tempDir.getAbsolutePath());
           getConfig().setOutputPath(tempDir.getAbsolutePath());
           getConfig().setZ3solverPath(new File(tempDir.getAbsolutePath() + File.separator + "z3_for_linux").getPath());
       }

       getConfig().setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments));
       getConfig().setGithubUserName(LauncherUtils.getArgGithubUserName(arguments));
       getConfig().setListenerMode(arguments.getString("listenermode"));
       getConfig().setActiveMQUrl(arguments.getString("activemqurl"));
       getConfig().setActiveMQListenQueueName(arguments.getString("activemqlistenqueuename"));

       getConfig().setGitUrl(arguments.getString("giturl"));
       getConfig().setGitBranch(arguments.getString("gitbranch"));
       getConfig().setGitCommitHash(arguments.getString("gitcommithash"));
       getConfig().setMavenHome(arguments.getString("MavenHome"));

       if (arguments.getFile("projectsToIgnore") != null) {
           getConfig().setProjectsToIgnoreFilePath(arguments.getFile("projectsToIgnore").getPath());
       }

       getConfig().setRepairTools(new HashSet<>(Arrays.asList(arguments.getStringArray("repairTools"))));
       
       // Make sure that it is a multiple of three in the list
       if((arguments.getStringArray("experimentalPluginRepoList").length) % 3 == 0) {
           getConfig().setExperimentalPluginRepoList(arguments.getStringArray("experimentalPluginRepoList"));
       } else if (arguments.getStringArray("experimentalPluginRepoList").length != 0) {
           LOGGER.warn("The experimental plugin repo list is not correctly formed."
                   + " Please make sure you have provided id, name and url for all repos. "
                   + "Repairnator will continue without these repos.");
           getConfig().setExperimentalPluginRepoList(null);
       } else {
           getConfig().setExperimentalPluginRepoList(null);
       }
}
 
Example 9
Source File: BranchLauncher.java    From repairnator with MIT License 3 votes vote down vote up
public static MainProcess getMainProcess(JSAP jsap,String[] args) throws JSAPException{
	JSAPResult jsapResult = jsap.parse(args);

	String launcherMode = jsapResult.getString("launcherMode");

	if (launcherMode.equals(LauncherMode.REPAIR.name())) {

		RepairnatorConfig.getInstance().setLauncherMode(LauncherMode.REPAIR);

		return MainProcessFactory.getDefaultMainProcess(args);

	} else if (launcherMode.equals(LauncherMode.BEARS.name())) {

		RepairnatorConfig.getInstance().setLauncherMode(LauncherMode.BEARS);

		return MainProcessFactory.getDefaultMainProcess(args);

	} else if (launcherMode.equals(LauncherMode.CHECKSTYLE.name())) {

		RepairnatorConfig.getInstance().setLauncherMode(LauncherMode.CHECKSTYLE);

		return MainProcessFactory.getDefaultMainProcess(args);

	} else if (launcherMode.equals(LauncherMode.GIT_REPOSITORY.name())) {

		RepairnatorConfig.getInstance().setLauncherMode(LauncherMode.GIT_REPOSITORY);

		return MainProcessFactory.getGithubMainProcess(args);

	} else if (launcherMode.equals(LauncherMode.KUBERNETES_LISTENER.name())) {
		RepairnatorConfig.getInstance().setLauncherMode(LauncherMode.KUBERNETES_LISTENER);
		return MainProcessFactory.getPipelineListenerMainProcess(args);
	} else {
		LOGGER.warn("Unknown launcher mode. Please choose the following: REPAIR, BEARS, CHECKSTYLE, GIT_REPOSITORY, KUBERNETES_LISTENER, JENKINS_PLUGIN");
		return null;
	}
}