private boolean determineFamilyMatch( String family ) { String test = family; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isFamily( test ); return reverse ? !result : result; }
private boolean determineNameMatch( String name ) { String test = name; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isName( test ); return reverse ? !result : result; }
private boolean determineArchMatch( String arch ) { String test = arch; boolean reverse = false; if ( test.startsWith( "!" ) ) { reverse = true; test = test.substring( 1 ); } boolean result = Os.isArch( test ); return reverse ? !result : result; }
/** * Helper method to determine the current OS family. * * @return name of current OS family. * @since 1.4.2 */ private static String getOsFamily() { // in case the order of static initialization is // wrong, get the list // safely. Set<String> families = null; if ( !validFamilies.isEmpty() ) { families = validFamilies; } else { families = setValidFamilies(); } for ( String fam : families ) { if ( Os.isFamily( fam ) ) { return fam; } } return null; }
throws ScmException if ( fileSet.getFileList().isEmpty() ) throw new ScmException( "You must provide at least one file/directory to remove" ); Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFileList() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); throw new ScmException( "Error while executing command.", ex ); return new RemoveScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); return new RemoveScmResult( cl.toString(), consumer.getRemovedFiles() );
boolean windows = Os.isFamily( "windows" ); Commandline cmdLine = new Commandline(); File exec; if ( windows ) cmdLine.addArguments( new String[] { "--console", "suppress" } ); cmdLine.setExecutable( exec.getAbsolutePath() );
public static void chmod(final File file, final int mode, final Log logger, boolean useJvmChmod) throws ArchiverException { if (!Os.isFamily(Os.FAMILY_UNIX)) { return; final Commandline commandline = new Commandline(); commandline.setWorkingDirectory(file.getParentFile().getAbsolutePath()); commandline.setExecutable("chmod"); commandline.createArg().setValue(m); commandline.createArg().setValue(path); final CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); logger.warn("Standard error:"); logger.warn("-------------------------------"); logger.warn(stderr.getOutput()); logger.warn("-------------------------------"); logger.warn("Standard output:");
public static int executeCleanUp( File workinDirectory, StreamConsumer stdout, StreamConsumer stderr, ScmLogger logger ) throws CommandLineException { Commandline cl = new Commandline(); cl.setExecutable( "svn" ); cl.setWorkingDirectory( workinDirectory.getAbsolutePath() ); if ( logger != null ) { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } } } return CommandLineUtils.executeCommandLine( cl, stdout, stderr ); }
throws MojoExecutionException Commandline cl = new Commandline(); try cl.addSystemEnvironment(); cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" ); if ( Os.isFamily( "windows" ) )
throw new ScmException( "tag must be specified" ); if ( !fileSet.getFileList().isEmpty() ) throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag, messageFile, scmTagParameters ); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); throw new ScmException( "Error while executing command.", ex ); return new TagScmResult( cl.toString(), "The svn tag command failed.", stderr.getOutput(), false ); if ( StringUtils.isNotEmpty( fileSet.getExcludes() ) ) return new TagScmResult( cl.toString(), fileList );
throws ScmException Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), version ); SvnUpdateConsumer consumer = new SvnUpdateConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); throw new ScmException( "Error while executing command.", ex ); return new UpdateScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); UpdateScmResultWithRevision result = new UpdateScmResultWithRevision( cl.toString(), consumer.getUpdatedFiles(), String.valueOf( consumer.getRevision() ) );
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); if ( !fileSet.getFileList().isEmpty() ) if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) for ( File file: fileSet.getFileList() ) return new CheckInScmResult( clAdd.toString(), "The git-add command failed.", stderr.getOutput(), false ); if ( getLogger().isInfoEnabled() ) getLogger().info( "nothing added to commit but untracked files present (use \"git add\" to " + "track)" ); if ( exitCode != 0 ) return new CheckInScmResult( clCommit.toString(), "The git-commit command failed.", stderr.getOutput(), false ); if ( exitCode != 0 ) return new CheckInScmResult( cl.toString(), "The git-push command failed.", stderr.getOutput(), false );
protected void executable( File file ) throws CommandLineException, IOException { if ( Os.isFamily( "unix" ) ) { Commandline cli = new Commandline(); cli.setExecutable( "chmod" ); cli.createArgument().setValue( "+x" ); cli.createArgument().setValue( file.getAbsolutePath() ); cli.execute(); } }
if ( !fileSet.getBasedir().exists() && !createInLocal ) fileSet.getBasedir().mkdirs(); Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( fileSet.getBasedir(), repository ); cl.createArg().setValue( "mkdir" ); cl.createArg().setValue( "--parents" ); Iterator<File> it = fileSet.getFileList().iterator(); String dirPath = it.next().getPath(); if ( dirPath != null && Os.isFamily( Os.FAMILY_WINDOWS ) ) cl.createArg().setValue( repository.getUrl() + "/" + dirPath + "@" );
public boolean login( String user, String password ) throws AccuRevException { // TODO Raise bug against plexus commandline - can't set workingdir to null // and will get an error if the working directory is deleted. cl.setWorkingDirectory( "." ); authArgs = EMPTY_STRING_ARRAY; AuthTokenConsumer stdout = new AuthTokenConsumer(); boolean result; if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( StringUtils.isBlank( password ) ) { // Ensure blank is passed in. password = "\"\""; } String[] login = { "login", "-A", user, password }; result = executeCommandLine( login, null, stdout ) == 0; } else { String[] login = { "login", "-A", user }; password = StringUtils.clean( password ) + "\n"; byte[] bytes = password.getBytes(); ByteArrayInputStream stdin = new ByteArrayInputStream( bytes ); result = executeCommandLine( login, stdin, stdout ) == 0; } authArgs = new String[] { "-A", stdout.getAuthToken() }; return result; }
protected void addDateRangeParameter( Commandline cl, String dateRange ) { // There's a difference between UNIX-like OS and Windows // See https://issues.apache.org/jira/browse/SCM-187 if ( Os.isFamily( "windows" ) ) { cl.createArg().setValue( "\"" + dateRange + "\"" ); } else { cl.createArg().setValue( dateRange ); } } }
Iterator<File> it = fileSet.getFileList().iterator(); String dirPath = it.next().getPath(); if ( dirPath != null && Os.isFamily( Os.FAMILY_DOS ) ) throw new ScmException( e.getMessage(), e );
protected AddScmResult executeAddFileSet(ScmFileSet fileSet) throws ScmException { File workingDirectory = fileSet.getBasedir(); List<File> files = fileSet.getFileList(); // command line can be too long for windows so add files individually (see SCM-697) if (Os.isFamily(Os.FAMILY_WINDOWS)) { for (File file : files) { AddScmResult result = executeAddFiles(workingDirectory, Collections.singletonList(file)); if (result != null) { return result; } } } else { AddScmResult result = executeAddFiles(workingDirectory, files); if (result != null) { return result; } } return null; }
/** * Returns the executable and all defined arguments.<br> * For Windows Family, {@link Commandline#getShellCommandline()} is returned */ public String[] getCommandline() { if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { return getShellCommandline(); } final String[] args = getArguments(); String executable = getLiteralExecutable(); if ( executable == null ) { return args; } final String[] result = new String[args.length + 1]; result[0] = executable; System.arraycopy( args, 0, result, 1, args.length ); return result; }