Package org.apache.tools.ant.types.Commandline

Examples of org.apache.tools.ant.types.Commandline.Argument


   * Copy the classpath to the command line with access rules included.
   * @param cmd the given command line
   * @param classpath the given classpath entry
   */
  private void createClasspathArgument(Commandline cmd, Path classpath) {
    Argument arg = cmd.createArgument();
    final String[] pathElements = classpath.list();

    // empty path return empty string
    if (pathElements.length == 0) {
      arg.setValue(Util.EMPTY_STRING);
      return;
    }

    // no access rules, can set the path directly
    if (accessRules == null) {
      arg.setPath(classpath);
      return;
    }

    int rulesLength = accessRules.size();
    String[] rules = (String[]) accessRules.toArray(new String[rulesLength]);
    int nextRule = 0;
    final StringBuffer result = new StringBuffer();

    //access rules are expected in the same order as the classpath, but there could
    //be elements in the classpath not in the access rules or access rules not in the classpath
    for (int i = 0, max = pathElements.length; i < max; i++) {
      if (i > 0)
        result.append(File.pathSeparatorChar);
      String pathElement = pathElements[i];
      result.append(pathElement);
      //the rules list is [path, rule, path, rule, ...]
      for (int j = nextRule; j < rulesLength; j += 2) {
        String rule = rules[j];
        if (pathElement.endsWith(rule)) {
          result.append(rules[j + 1]);
          nextRule = j + 2;
          break;
        }
        // if the path doesn't match, it could be due to a trailing file separatorChar in the rule
        if (rule.endsWith(File.separator)) {
          // rule ends with the File.separator, but pathElement might not
          // otherwise it would match on the first endsWith
          int ruleLength = rule.length();
          if (pathElement.regionMatches(false, pathElement.length() - ruleLength + 1, rule, 0, ruleLength - 1)) {
            result.append(rules[j + 1]);
            nextRule = j + 2;
            break;
          }
        } else if (pathElement.endsWith(File.separator)) {
          // rule doesn't end with the File.separator, but pathElement might
          int ruleLength = rule.length();
          if (pathElement.regionMatches(false, pathElement.length() - ruleLength - 1, rule, 0, ruleLength)) {
            result.append(rules[j + 1]);
            nextRule = j + 2;
            break;
          }
        }
      }
    }

    arg.setValue(result.toString());
  }
View Full Code Here


      task.setJar(new File(mxmlcPath));
      task.setProject(project);
      task.setDir(project.getBaseDir());
      task.setOutputproperty(outputProperty);
     
      Argument versionArgument = task.createArg();
      versionArgument.setValue("--version");
     
      task.execute();
     
      //Parse version number and return as int
      String output = project.getProperty(outputProperty);
View Full Code Here

      task.setProject(project);
      task.setDir(project.getBaseDir());
      task.setMaxmemory("256M"); //MXMLC needs to eat
      task.setErrorProperty("MXMLC_ERROR");
     
      Argument flexLibArgument = task.createArg();
      flexLibArgument.setLine("+flexlib \"" + frameworksPath + "\"");
     
      if(configuration.getPlayer().equals("air"))
      {
         Argument airConfigArgument = task.createArg();
         airConfigArgument.setValue("+configname=air");
      }
     
      Argument outputFile = task.createArg();
      outputFile.setLine("-output \"" + finalFile.getAbsolutePath() + "\"");
     
      Argument sourcePath = task.createArg();
      sourcePath.setLine("-source-path " + configuration.getSources().getPathElements(" ") + " " + configuration.getTestSources().getPathElements(" "));
     
      determineLibraryPath( task );
    
      determineLoadConfigArgument( task );
      
      Argument debug = task.createArg();
      debug.setLine( "-debug=" + configuration.getDebug() );

      Argument headlessServer = task.createArg();
      headlessServer.setLine("-headless-server=true");
     
     
      Argument mainFile = task.createArg();
      mainFile.setValue(runnerFile.getAbsolutePath());
     
      return task;
   }
View Full Code Here

  
   private void determineLoadConfigArgument(Java java)
   {
       if(configuration.getLoadConfig() != null)
       {
           Argument argument = java.createArg();
           argument.setLine(configuration.getLoadConfig().getCommandLineArgument());
       }
   }
View Full Code Here

   private void determineLibraryPath(Java java)
   {
       if(!configuration.getLibraries().getPathElements(" -library-path+=").isEmpty())
       {
           Argument libraryPath = java.createArg();
           libraryPath.setLine("-library-path+=" + configuration.getLibraries().getPathElements(" -library-path+="));
       }
   }
View Full Code Here

      task.setJar(new File(getProject().getProperty("FLEX_HOME") + File.separatorChar + ADT_JAR_PATH));
      task.setProject(getProject());
      task.setDir(getProject().getBaseDir());
      task.setOutputproperty(outputProperty);

      Argument versionArgument = task.createArg();
      versionArgument.setValue("-version");

      task.execute();
      double version = parseAdtVersionNumber( getProject().getProperty(outputProperty) );
      LoggingUtil.log("Found AIR version: " + version);
      return version;
View Full Code Here

    }

    int javaExecResult = 0;

    void makeMockJava() {
        Argument mockArg = EasyMock.createNiceMock(Argument.class);
        mockJava = EasyMock.createNiceMock(Java.class);
        mockJava.createArg();
        EasyMock.expectLastCall().andReturn(mockArg);
        mockJava.createArg();
        EasyMock.expectLastCall().andReturn(mockArg);
View Full Code Here

    }

    int javaExecResult = 0;

    void makeMockJava() {
        Argument mockArg = EasyMock.createNiceMock(Argument.class);
        mockJava = EasyMock.createNiceMock(Java.class);
        mockJava.createArg();
        EasyMock.expectLastCall().andReturn(mockArg);
        mockJava.createArg();
        EasyMock.expectLastCall().andReturn(mockArg);
View Full Code Here

        Java java = new Java();
        java.setProject(project);
        java.setClassname("org.jruby.Main");
        java.setFailonerror(true);

        Argument arg;

        if (shouldFork) {
            java.setFork(true);
            java.setDir(launchDirectory);

            if (jvmArgs != null) {
                String[] splitArgs = jvmArgs.split("\\s+");
                for (int i = 0; i < splitArgs.length; i++) {
                    arg = java.createJvmarg();
                    arg.setValue(splitArgs[i]);
                    if (splitArgs[i].startsWith("-Xmx")) {
                        jrubyLaunchMemory = null;
                    }
                }
            }

            if (jrubyLaunchMemory != null) {
                arg = java.createJvmarg();
                arg.setValue("-Xmx" + jrubyLaunchMemory);
            }

            Variable classpath = new Variable();

            Path p = new Path(java.getProject());
            p.add((Path) project.getReference("maven.plugin.classpath"));
            p.add((Path) project.getReference("maven.compile.classpath"));
            classpath.setKey("JRUBY_PARENT_CLASSPATH");
            classpath.setValue(p.toString());

            java.addEnv(classpath);
        }

        if (jrubyHome != null) {
            Variable v = new Variable();
            v.setKey("jruby.home");
            v.setValue(jrubyHome);
            java.addSysproperty(v);
        }

        Path p = java.createClasspath();
        p.add((Path) project.getReference("maven.plugin.classpath"));
        p.add((Path) project.getReference("maven.compile.classpath"));
        getLog().debug("java classpath: " + p.toString());

        for (int i = 0; i < args.length; i++) {
            arg = java.createArg();
            arg.setValue(args[i]);
        }

        return java;
    }
View Full Code Here

      task.setJar(new File(mxmlcPath));
      task.setProject(project);
      task.setDir(project.getBaseDir());
      task.setOutputproperty(outputProperty);
     
      Argument versionArgument = task.createArg();
      versionArgument.setValue("--version");
     
      task.execute();
     
      //Parse version number and return as int
      String output = project.getProperty(outputProperty);
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.types.Commandline.Argument

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.