Package hudson.util

Examples of hudson.util.ArgumentListBuilder


    when(installation.getSonarPassword()).thenReturn("sonarpassword");
    when(publisher.getInstallation()).thenReturn(installation);
    when(publisher.getBranch()).thenReturn("branch");
    when(publisher.getLanguage()).thenReturn("language");

    ArgumentListBuilder args = new ArgumentListBuilder();
    SonarMaven sonarMaven = new SonarMaven("-Dprop=value", "Default Maven", "pom.xml", "", new DefaultLocalRepositoryLocator(), publisher, mock(BuildListener.class), null, null,
      null);
    sonarMaven.wrapUpArguments(args, "sonar:sonar", mock(AbstractBuild.class), mock(Launcher.class), mock(BuildListener.class));

    List<String> result = args.toList();
    assertThat(result).contains("-Dprop=value");
    assertThat(result).contains("-Dsonar.jdbc.driver=driver");
    assertThat(result).contains("-Dsonar.jdbc.url=databaseUrl");
    assertThat(result).contains("-Dsonar.jdbc.username=login");
    assertThat(result).contains("-Dsonar.jdbc.password=password");
View Full Code Here


public class ExtendedArgumentListBuilderTest {
  private ArgumentListBuilder original;
  private ExtendedArgumentListBuilder builder;

  public ExtendedArgumentListBuilderTest(boolean unix) {
    original = new ArgumentListBuilder();
    builder = new ExtendedArgumentListBuilder(original, unix);
  }
View Full Code Here

        // Build the command to install the given component(s)
        String list = StringUtils.join(components, ',');
        log(logger, Messages.INSTALLING_SDK_COMPONENTS(list));
        String all = sdk.getSdkToolsVersion() < 17 ? "-o" : "-a";
        String upgradeArgs = String.format("update sdk -u %s %s -t %s", all, proxySettings, list);
        ArgumentListBuilder cmd = Utils.getToolCommand(sdk, launcher.isUnix(), Tool.ANDROID, upgradeArgs);
        ProcStarter procStarter = launcher.launch().stderr(logger).readStdout().writeStdin().cmds(cmd);
        if (sdk.hasKnownHome()) {
            EnvVars env = new EnvVars();
            env.put("ANDROID_SDK_HOME", sdk.getSdkHome());
            procStarter = procStarter.envs(env);
View Full Code Here

            args.append("-s ");
            args.append(screenResolution.getSkinName());
            args.append(" -n ");
            args.append(getAvdName());
            boolean isUnix = !Functions.isWindows();
            ArgumentListBuilder builder = Utils.getToolCommand(androidSdk, isUnix, Tool.ANDROID, args.toString());

            // Tack on quoted platform name at the end, since it can be anything
            builder.add("-t");
            builder.add(osVersion.getTargetName());

            if (targetAbi != null && osVersion.requiresAbi()) {
                // This is an unpleasant side-effect of there being an ABI for android-10,
                // and that Google renamed the image after its initial release from Intel...
                // Ideally, as stated in AndroidPlatform#requiresAbi, we should preferably check
                // via the "android list target" command whether an ABI is actually required.
                if (osVersion.getSdkLevel() != 10 || targetAbi.equals("armeabi")
                        || targetAbi.equals("x86")) {
                    builder.add("--abi");
                    builder.add(targetAbi);
                }
            }

            // Log command line used, for info
            AndroidEmulator.log(logger, builder.toStringWithQuote());

            // Run!
            boolean avdCreated = false;
            final Process process;
            try {
                ProcessBuilder procBuilder = new ProcessBuilder(builder.toList());
                if (androidSdk.hasKnownHome()) {
                    procBuilder.environment().put("ANDROID_SDK_HOME", androidSdk.getSdkHome());
                }
                process = procBuilder.start();
            } catch (IOException ex) {
View Full Code Here

            return false;
        }

        private boolean createSdCard(File homeDir) {
            // Build command: mksdcard 32M /home/foo/.android/avd/whatever.avd/sdcard.img
            ArgumentListBuilder builder = Utils.getToolCommand(androidSdk, !Functions.isWindows(), Tool.MKSDCARD, null);
            builder.add(sdCardSize);
            builder.add(new File(getAvdDirectory(homeDir), "sdcard.img"));

            // Run!
            try {
                ProcessBuilder procBuilder = new ProcessBuilder(builder.toList());
                if (androidSdkHome != null) {
                    procBuilder.environment().put("ANDROID_SDK_HOME", androidSdkHome);
                }
                procBuilder.start().waitFor();
            } catch (InterruptedException ex) {
View Full Code Here

            androidToolsDir = "";
        }

        // Build tool command
        final String executable = tool.getExecutable(isUnix);
        ArgumentListBuilder builder = new ArgumentListBuilder(androidToolsDir + executable);
        if (args != null) {
            builder.add(Util.tokenize(args));
        }

        return builder;
    }
View Full Code Here

    public static void runAndroidTool(Launcher launcher, EnvVars env, OutputStream stdout, OutputStream stderr,
            AndroidSdk androidSdk, Tool tool, String args, FilePath workingDirectory)
                throws IOException, InterruptedException {

        ArgumentListBuilder cmd = Utils.getToolCommand(androidSdk, launcher.isUnix(), tool, args);
        ProcStarter procStarter = launcher.launch().stdout(stdout).stderr(stderr).cmds(cmd);
        if (androidSdk.hasKnownHome()) {
            // Copy the old one, so we don't mutate the argument.
            env = new EnvVars((env == null ? new EnvVars() : env));
            env.put("ANDROID_SDK_HOME", androidSdk.getSdkHome());
View Full Code Here

            Thread.sleep(bootDuration / 4);

            log(logger, Messages.UNLOCKING_SCREEN());
            final String keyEventArgs = String.format("-s %s shell input keyevent %%d", emu.serial());
            final String menuArgs = String.format(keyEventArgs, 82);
            ArgumentListBuilder menuCmd = emu.getToolCommand(Tool.ADB, menuArgs);
            emu.getProcStarter(menuCmd).join();

            // If a named emulator already existed, it may not have been booted yet, so the screen
            // wouldn't be locked.  Similarly, an non-named emulator may have already booted the
            // first time without us knowing.  In both cases, we press Back after Menu to compensate
            final String backArgs = String.format(keyEventArgs, 4);
            ArgumentListBuilder backCmd = emu.getToolCommand(Tool.ADB, backArgs);
            emu.getProcStarter(backCmd).join();
        }

        // Initialise snapshot image, if required
        if (snapshotState == SnapshotState.INITIALISE) {
            // In order to create a clean initial snapshot, give the system some more time to settle
            log(logger, Messages.WAITING_INITIAL_SNAPSHOT());
            Thread.sleep((long) (bootDuration * 0.8));

            // Clear main log before creating snapshot
            final String clearArgs = String.format("-s %s logcat -c", emu.serial());
            ArgumentListBuilder adbCmd = emu.getToolCommand(Tool.ADB, clearArgs);
            emu.getProcStarter(adbCmd).join();
            final String msg = Messages.LOG_CREATING_SNAPSHOT();
            final String logArgs = String.format("-s %s shell log -p v -t Jenkins '%s'", emu.serial(), msg);
            adbCmd = emu.getToolCommand(Tool.ADB, logArgs);
            emu.getProcStarter(adbCmd).join();
View Full Code Here

                logcatFile.copyTo(new FilePath(artifactsDir).child("logcat.txt"));
            }
            logcatFile.delete();
        }

        ArgumentListBuilder adbKillCmd = emu.getToolCommand(Tool.ADB, "kill-server");
        emu.getProcStarter(adbKillCmd).join();

        emu.cleanUp();

        // Delete the emulator, if required
View Full Code Here

            final int timeout, AndroidEmulatorContext emu) {
        long start = System.currentTimeMillis();
        int sleep = timeout / (int) (Math.sqrt(timeout / 1000) * 2);

        final String args = String.format("-s %s shell getprop dev.bootcomplete", emu.serial());
        ArgumentListBuilder bootCheckCmd = emu.getToolCommand(Tool.ADB, args);

        try {
            final long adbTimeout = timeout / 8;
            int iterations = 0;
            while (System.currentTimeMillis() < start + timeout && (ignoreProcess || emu.process().isAlive())) {
View Full Code Here

TOP

Related Classes of hudson.util.ArgumentListBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.