Tabnine Logo
CommandLineUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
CommandLineUtils
in
org.apache.maven.shared.utils.cli

Best Java code snippets using org.apache.maven.shared.utils.cli.CommandLineUtils (Showing top 20 results out of 315)

origin: fabric8io/docker-maven-plugin

  private FixedStringSearchInterpolator createEnvInterpolator() {
    PrefixedPropertiesValueSource envProps = new PrefixedPropertiesValueSource(Collections.singletonList("env."),
                                          CommandLineUtils.getSystemEnvVars(false), true );
    return FixedStringSearchInterpolator.create( envProps );
  }
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cl The command line {@link Commandline}
 * @param systemOut {@link StreamConsumer}
 * @param systemErr {@link StreamConsumer}
 * @return return code.
 * @throws CommandLineException in case of a problem.
 */
public static int executeCommandLine( @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr )
  throws CommandLineException
{
  return executeCommandLine( cl, null, systemOut, systemErr, 0 );
}
origin: org.apache.maven.shared/maven-verifier

public static void launchSubversion( String line, String basedir )
  throws VerificationException
{
  try
  {
    Commandline cli = new Commandline( line );
    cli.setWorkingDirectory( basedir );
    Writer logWriter = new FileWriter( new File( basedir, LOG_FILENAME ) );
    StreamConsumer out = new WriterStreamConsumer( logWriter );
    StreamConsumer err = new WriterStreamConsumer( logWriter );
    System.out.println( "Command: " + CommandLineUtils.toString( cli.getCommandline() ) );
    int ret = CommandLineUtils.executeCommandLine( cli, out, err );
    logWriter.close();
    if ( ret > 0 )
    {
      System.err.println( "Exit code: " + ret );
      throw new VerificationException();
    }
  }
  catch ( CommandLineException e )
  {
    throw new VerificationException( e );
  }
  catch ( IOException e )
  {
    throw new VerificationException( e );
  }
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * {@inheritDoc}
 */
public void setLine( String line )
{
  if ( line == null )
  {
    return;
  }
  try
  {
    parts = CommandLineUtils.translateCommandline( line );
  }
  catch ( Exception e )
  {
    System.err.println( "Error translating Commandline." );
  }
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * Immediately forks a process, returns a callable that will block until process is complete.
 *
 * @param cl               The command line to execute
 * @param systemIn         The input to read from, must be thread safe
 * @param systemOut        A consumer that receives output, must be thread safe
 * @param systemErr        A consumer that receives system error stream output, must be thread safe
 * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout.
 * @param runAfterProcessTermination Optional callback to run after the process terminated or the the timeout was
 * @return A CommandLineCallable that provides the process return value, see {@link Process#exitValue()}. "call"
 *         must be called on this to be sure the forked process has terminated, no guarantees is made about
 *         any internal state before after the completion of the call statements
 * @throws CommandLineException or CommandLineTimeOutException if time out occurs
 */
public static CommandLineCallable executeCommandLineAsCallable( @Nonnull final Commandline cl,
                                @Nullable final InputStream systemIn,
                                final StreamConsumer systemOut,
                                final StreamConsumer systemErr,
                                final int timeoutInSeconds,
                               @Nullable final Runnable runAfterProcessTermination )
  throws CommandLineException
{
  return executeCommandLineAsCallable( cl, systemIn, systemOut, systemErr, timeoutInSeconds,
                     runAfterProcessTermination, null );
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * Return the shell environment variables. If <code>caseSensitive == true</code>, then envar
 * keys will all be upper-case.
 *
 * @param caseSensitive Whether environment variable keys should be treated case-sensitively.
 * @return Properties object of (possibly modified) envar keys mapped to their values.
 * @see System#getenv() System.getenv() API, new in JDK 5.0, to get the same result
 *      <b>since 2.0.2 System#getenv() will be used if available in the current running jvm.</b>
 */
public static Properties getSystemEnvVars( boolean caseSensitive )
{
  Map<String, String> envs = System.getenv();
  return ensureCaseSensitivity( envs, caseSensitive );
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cl               The command line to execute
 * @param systemIn         The input to read from, must be thread safe
 * @param systemOut        A consumer that receives output, must be thread safe
 * @param systemErr        A consumer that receives system error stream output, must be thread safe
 * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout.
 * @return A return value, see {@link Process#exitValue()}
 * @throws CommandLineException or CommandLineTimeOutException if time out occurs
 */
public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut,
                   StreamConsumer systemErr, int timeoutInSeconds )
  throws CommandLineException
{
  return executeCommandLine( cl, systemIn, systemOut, systemErr, timeoutInSeconds, null );
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * Create a new command line object.
 * Shell is autodetected from operating system
 *
 * @param toProcess The command to process
 */
public Commandline( String toProcess )
{
  setDefaultShell();
  String[] tmp = new String[0];
  try
  {
    tmp = CommandLineUtils.translateCommandline( toProcess );
  }
  catch ( Exception e )
  {
    System.err.println( "Error translating Commandline." );
  }
  if ( ( tmp != null ) && ( tmp.length > 0 ) )
  {
    setExecutable( tmp[0] );
    for ( int i = 1; i < tmp.length; i++ )
    {
      createArg().setValue( tmp[i] );
    }
  }
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cl               The command line to execute
 * @param systemIn         The input to read from, must be thread safe
 * @param systemOut        A consumer that receives output, must be thread safe
 * @param systemErr        A consumer that receives system error stream output, must be thread safe
 * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout.
 * @param runAfterProcessTermination Optional callback to run after the process terminated or the the timeout was
 *  exceeded, but before waiting on the stream feeder and pumpers to finish.
 * @param streamCharset    Charset to use for reading streams
 * @return A return value, see {@link Process#exitValue()}
 * @throws CommandLineException or CommandLineTimeOutException if time out occurs
 */
public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut,
                   StreamConsumer systemErr, int timeoutInSeconds,
                   @Nullable Runnable runAfterProcessTermination,
                   @Nullable final Charset streamCharset )
  throws CommandLineException
{
  final CommandLineCallable future =
    executeCommandLineAsCallable( cl, systemIn, systemOut, systemErr, timeoutInSeconds,
                   runAfterProcessTermination, streamCharset );
  return future.call();
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * Gets the shell environment variables for this process. Note that the returned mapping from variable names to
 * values will always be case-sensitive regardless of the platform, i.e. <code>getSystemEnvVars().get("path")</code>
 * and <code>getSystemEnvVars().get("PATH")</code> will in general return different values. However, on platforms
 * with case-insensitive environment variables like Windows, all variable names will be normalized to upper case.
 *
 * @return The shell environment variables, can be empty but never <code>null</code>.
 * @see System#getenv() System.getenv() API, new in JDK 5.0, to get the same result
 *      <b>since 2.0.2 System#getenv() will be used if available in the current running jvm.</b>
 */
public static Properties getSystemEnvVars()
{
  return getSystemEnvVars( !Os.isFamily( Os.FAMILY_WINDOWS ) );
}
origin: com.mulesoft.munit/munit-maven-plugins-common

public int execute(StreamConsumer outStreamConsumer, StreamConsumer errStreamConsumer) throws CommandLineException {
 log.debug("Executing command line: " + commandline);
 return CommandLineUtils.executeCommandLine(commandline, outStreamConsumer, errStreamConsumer);
}
origin: org.apache.maven.shared/maven-verifier

args.addAll( Arrays.asList( CommandLineUtils.translateCommandline( resolvedArg ) ) );
origin: org.apache.maven.shared/maven-verifier

private void findDefaultMavenHome()
  throws VerificationException
{
  defaultClasspath = System.getProperty( "maven.bootclasspath" );
  defaultClassworldConf = System.getProperty( "classworlds.conf" );
  defaultMavenHome = System.getProperty( "maven.home" );
  if ( defaultMavenHome == null )
  {
    Properties envVars = CommandLineUtils.getSystemEnvVars();
    defaultMavenHome = envVars.getProperty( "M2_HOME" );
  }
  if ( defaultMavenHome == null )
  {
    File f = new File( System.getProperty( "user.home" ), "m2" );
    if ( new File( f, "bin/mvn" ).isFile() )
    {
      defaultMavenHome = f.getAbsolutePath();
    }
  }
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cl The command line {@link Commandline}
 * @param systemOut {@link StreamConsumer}
 * @param systemErr {@link StreamConsumer}
 * @param timeoutInSeconds The timeout.
 * @return return code.
 * @throws CommandLineException in case of a problem.
 */
public static int executeCommandLine( @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr,
                   int timeoutInSeconds )
  throws CommandLineException
{
  return executeCommandLine( cl, null, systemOut, systemErr, timeoutInSeconds );
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * Add system environment variables
 */
public void addSystemEnvironment()
{
  Properties systemEnvVars = CommandLineUtils.getSystemEnvVars();
  for ( Object o : systemEnvVars.keySet() )
  {
    String key = (String) o;
    if ( !envVars.containsKey( key ) )
    {
      addEnvironment( key, systemEnvVars.getProperty( key ) );
    }
  }
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cl The command line {@link Commandline}
 * @param systemIn {@link StreamConsumer}
 * @param systemOut {@link StreamConsumer}
 * @param systemErr {@link StreamConsumer}
 * @return return code.
 * @throws CommandLineException in case of a problem.
 */
public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut,
                   StreamConsumer systemErr )
  throws CommandLineException
{
  return executeCommandLine( cl, systemIn, systemOut, systemErr, 0 );
}
origin: org.apache.maven.plugins/maven-assembly-plugin

private FixedStringSearchInterpolator createEnvInterpolator()
{
  PrefixedPropertiesValueSource envProps = new PrefixedPropertiesValueSource( Collections.singletonList( "env." ),
                                        CommandLineUtils.getSystemEnvVars(
                                          false ), true );
  return FixedStringSearchInterpolator.create( envProps );
}
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cl               The command line to execute
 * @param systemIn         The input to read from, must be thread safe
 * @param systemOut        A consumer that receives output, must be thread safe
 * @param systemErr        A consumer that receives system error stream output, must be thread safe
 * @param timeoutInSeconds Positive integer to specify timeout, zero and negative integers for no timeout.
 * @param runAfterProcessTermination Optional callback to run after the process terminated or the the timeout was
 *  exceeded, but before waiting on the stream feeder and pumpers to finish.
 * @return A return value, see {@link Process#exitValue()}
 * @throws CommandLineException or CommandLineTimeOutException if time out occurs
 */
public static int executeCommandLine( @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut,
                   StreamConsumer systemErr, int timeoutInSeconds,
                   @Nullable Runnable runAfterProcessTermination )
  throws CommandLineException
{
  return executeCommandLine( cl, systemIn, systemOut, systemErr, timeoutInSeconds, runAfterProcessTermination,
                null );
}
origin: org.apache.maven.shared/maven-verifier

return CommandLineUtils.executeCommandLine( cmd, out, err );
origin: org.apache.maven.shared/maven-shared-utils

/**
 * @param cli {@link Commandline}
 * @param request The request.
 * @return {@link JavaToolRequest}
 */
protected JavaToolResult executeCommandLine( Commandline cli, Request request )
{
  if ( getLogger().isDebugEnabled() )
  {
    getLogger().debug( "Executing: " + cli );
  }
  JavaToolResult result = createResult();
  result.setCommandline( cli );
  InputStream systemIn = createSystemInputStream();
  StreamConsumer systemOut = createSystemOutStreamConsumer( request );
  StreamConsumer systemErr = createSystemErrorStreamConsumer( request );
  try
  {
    int resultCode = CommandLineUtils.executeCommandLine( cli, systemIn, systemOut, systemErr );
    result.setExitCode( resultCode );
  }
  catch ( CommandLineException e )
  {
    result.setExecutionException( e );
  }
  return result;
}
org.apache.maven.shared.utils.cliCommandLineUtils

Most used methods

  • getSystemEnvVars
    Return the shell environment variables. If caseSensitive == true, then envar keys will all be upper-
  • executeCommandLine
  • translateCommandline
  • ensureCaseSensitivity
  • executeCommandLineAsCallable
  • toString

Popular in Java

  • Making http post requests using okhttp
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • startActivity (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Reference (javax.naming)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now