Java Code Examples for org.gradle.StartParameter#setShowStacktrace()

The following examples show how to use org.gradle.StartParameter#setShowStacktrace() . 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: InProcessGradleExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    StartParameter parameter = new StartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine, new BuildLayoutParameters());

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);
    converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties);

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory = GLOBAL_SERVICES.get(DefaultGradleLauncherFactory.class);
    factory.addListener(listener);
    try {
        GradleLauncher gradleLauncher = factory.newInstance(parameter, new DefaultBuildCancellationToken());
        try {
            gradleLauncher.addStandardOutputListener(outputListener);
            gradleLauncher.addStandardErrorListener(errorListener);
            return gradleLauncher.run();
        } finally {
            gradleLauncher.stop();
        }
    } finally {
        // Restore the environment
        System.setProperties(originalSysProperties);
        processEnvironment.maybeSetProcessDir(originalUserDir);
        for (String envVar : getEnvironmentVars().keySet()) {
            String oldValue = originalEnv.get(envVar);
            if (oldValue != null) {
                processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
            } else {
                processEnvironment.maybeRemoveEnvironmentVariable(envVar);
            }
        }
        factory.removeListener(listener);
        System.setIn(originalStdIn);
    }
}
 
Example 2
Source File: InProcessGradleExecuter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    StartParameter parameter = new StartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine);

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);
    converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties);

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled(new Factory<DefaultGradleLauncherFactory>() {
        public DefaultGradleLauncherFactory create() {
            return (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
        }
    });
    factory.addListener(listener);
    GradleLauncher gradleLauncher = factory.newInstance(parameter);
    gradleLauncher.addStandardOutputListener(outputListener);
    gradleLauncher.addStandardErrorListener(errorListener);
    try {
        return gradleLauncher.run();
    } finally {
        // Restore the environment
        System.setProperties(originalSysProperties);
        processEnvironment.maybeSetProcessDir(originalUserDir);
        for (String envVar: getEnvironmentVars().keySet()) {
            String oldValue = originalEnv.get(envVar);
            if (oldValue != null) {
                processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
            } else {
                processEnvironment.maybeRemoveEnvironmentVariable(envVar);
            }
        }
        factory.removeListener(listener);
        System.setIn(originalStdIn);
    }
}
 
Example 3
Source File: InProcessGradleExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    StartParameter parameter = new StartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine, new BuildLayoutParameters());

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);
    converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties);

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory = GLOBAL_SERVICES.get(DefaultGradleLauncherFactory.class);
    factory.addListener(listener);
    try {
        GradleLauncher gradleLauncher = factory.newInstance(parameter, new DefaultBuildCancellationToken());
        try {
            gradleLauncher.addStandardOutputListener(outputListener);
            gradleLauncher.addStandardErrorListener(errorListener);
            return gradleLauncher.run();
        } finally {
            gradleLauncher.stop();
        }
    } finally {
        // Restore the environment
        System.setProperties(originalSysProperties);
        processEnvironment.maybeSetProcessDir(originalUserDir);
        for (String envVar : getEnvironmentVars().keySet()) {
            String oldValue = originalEnv.get(envVar);
            if (oldValue != null) {
                processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
            } else {
                processEnvironment.maybeRemoveEnvironmentVariable(envVar);
            }
        }
        factory.removeListener(listener);
        System.setIn(originalStdIn);
    }
}
 
Example 4
Source File: InProcessGradleExecuter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private BuildResult doRun(final OutputListenerImpl outputListener, OutputListenerImpl errorListener, BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    StartParameter parameter = new StartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine);

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);
    converter.getSystemPropertiesConverter().convert(parsedCommandLine, properties);

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory = DeprecationLogger.whileDisabled(new Factory<DefaultGradleLauncherFactory>() {
        public DefaultGradleLauncherFactory create() {
            return (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
        }
    });
    factory.addListener(listener);
    GradleLauncher gradleLauncher = factory.newInstance(parameter);
    gradleLauncher.addStandardOutputListener(outputListener);
    gradleLauncher.addStandardErrorListener(errorListener);
    try {
        return gradleLauncher.run();
    } finally {
        // Restore the environment
        System.setProperties(originalSysProperties);
        processEnvironment.maybeSetProcessDir(originalUserDir);
        for (String envVar: getEnvironmentVars().keySet()) {
            String oldValue = originalEnv.get(envVar);
            if (oldValue != null) {
                processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
            } else {
                processEnvironment.maybeRemoveEnvironmentVariable(envVar);
            }
        }
        factory.removeListener(listener);
        System.setIn(originalStdIn);
    }
}