Examples of CommandLine


Examples of org.apache.maven.surefire.booter.shade.org.codehaus.plexus.util.cli.Commandline

        if (useSystemClassLoader()) {
            bootClasspath.addAll(classPathUrls);
        }

        Commandline cli =
            forkConfiguration.createCommandLine(bootClasspath, useManifestOnlyJar());

        cli.createArg().setFile(surefireProperties);

        if (systemProperties != null) {
            cli.createArg().setFile(systemProperties);
        }

        ForkingStreamConsumer out = getForkingStreamConsumer(showHeading, showFooter, redirectTestOutputToFile);

        StreamConsumer err;
View Full Code Here

Examples of org.apache.muse.util.CommandLine

   * and then try to do the WSDL merging.
   *
   * @param args The raw command line arguments
   */
  public static void main(String[] args) {
    CommandLine arguments = parseParameters(args);
   
    createLogger(arguments);
   
    checkHelpArg(arguments);
   
View Full Code Here

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

     * @throws Exception Indicates an error executing the target {@link ExecTask}.
     */
    private void startOpenOfficeServer() throws Exception
    {
        ExecTask execTask = (ExecTask) this.project.createTask("exec");
        Commandline commandLine =
            new Commandline(OPENOFFICE_EXECUTABLE
                + " -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard");
        execTask.setCommand(commandLine);
        execTask.execute();
    }
View Full Code Here

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

    /** reset variables to permit gc */
    public void reset() {
        //version = false;
        source14 = false;
        ignoredOptions = new HashSet();
        cmd = new Commandline();
        vmcmd = new Commandline();
        threads = -1;
        destdir = null;
        workingdir = null;
        internalclasspath = null;
        classpath = null;
View Full Code Here

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

    static boolean isEmpty(String s) {
      return ((null == s) || (0 == s.trim().length()));
    }

    GuardedCommand() {
      command = new Commandline();
    }
View Full Code Here

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

    public Ajdoc() {
        reset();
    }

    protected void reset() {
        cmd = new Commandline();
        vmcmd = new Commandline();
        sourcepath  = null;
        destdir  = null ;
        sourcefiles  = null;
        packagenames  = null;
        packageList  = null;
View Full Code Here

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

   * @throws BuildException if anything wrong happen during the compilation
   * @return boolean true if the compilation is ok, false otherwise
   */
  public boolean execute() throws BuildException {
    this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.usingJDTCompiler"), Project.MSG_VERBOSE); //$NON-NLS-1$
    Commandline cmd = setupJavacCommand();

    try {
      Class c = Class.forName(compilerClass);
      Constructor batchCompilerConstructor = c.getConstructor(new Class[] { PrintWriter.class, PrintWriter.class, Boolean.TYPE, Map.class});
      Object batchCompilerInstance = batchCompilerConstructor.newInstance(new Object[] {new PrintWriter(System.out), new PrintWriter(System.err), Boolean.TRUE, this.customDefaultOptions});
      Method compile = c.getMethod("compile", new Class[] {String[].class}); //$NON-NLS-1$
      Object result = compile.invoke(batchCompilerInstance, new Object[] { cmd.getArguments()});
      final boolean resultValue = ((Boolean) result).booleanValue();
      if (!resultValue && this.logFileName != null) {
        this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.error.compilationFailed", this.logFileName)); //$NON-NLS-1$
      }
      return resultValue;
View Full Code Here

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

    }
  }
 
 
  protected Commandline setupJavacCommand() throws BuildException {
    Commandline cmd = new Commandline();
    this.customDefaultOptions = new CompilerOptions().getMap();
   
    Class javacClass = Javac.class;
   
    /*
     * Read in the compiler arguments first since we might need to modify
     * the classpath if any access rules were specified
     */
    String [] compilerArgs = processCompilerArguments(javacClass);

    /*
     * This option is used to never exit at the end of the ant task.
     */
    cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$

        if (this.bootclasspath != null) {
      cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$
          if (this.bootclasspath.size() != 0) {
          /*
           * Set the bootclasspath for the Eclipse compiler.
           */
          cmd.createArgument().setPath(this.bootclasspath);
          } else {
          cmd.createArgument().setValue(Util.EMPTY_STRING);
          }
        }

        Path classpath = new Path(this.project);

       /*
         * Eclipse compiler doesn't support -extdirs.
         * It is emulated using the classpath. We add extdirs entries after the
         * bootclasspath.
         */
        if (this.extdirs != null) {
      cmd.createArgument().setValue("-extdirs"); //$NON-NLS-1$
      cmd.createArgument().setPath(this.extdirs);         
        }

    /*
     * The java runtime is already handled, so we simply want to retrieve the
     * ant runtime and the compile classpath.
     */
        classpath.append(getCompileClasspath());

        // For -sourcepath, use the "sourcepath" value if present.
        // Otherwise default to the "srcdir" value.
        Path sourcepath = null;
       
        // retrieve the method getSourcepath() using reflect
        // This is done to improve the compatibility to ant 1.5
        Method getSourcepathMethod = null;
        try {
          getSourcepathMethod = javacClass.getMethod("getSourcepath", null); //$NON-NLS-1$
        } catch(NoSuchMethodException e) {
          // if not found, then we cannot use this method (ant 1.5)
        }
        Path compileSourcePath = null;
        if (getSourcepathMethod != null) {
       try {
        compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, null);
      } catch (IllegalAccessException e) {
        // should never happen
      } catch (InvocationTargetException e) {
        // should never happen
      }
        }
        if (compileSourcePath != null) {
            sourcepath = compileSourcePath;
        } else {
            sourcepath = this.src;
        }
    classpath.append(sourcepath);
    /*
     * Set the classpath for the Eclipse compiler.
     */
    cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$
    createClasspathArgument(cmd, classpath);

        final String javaVersion = JavaEnvUtils.getJavaVersion();
    String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$
        if (this.memoryInitialSize != null) {
            if (!this.attributes.isForkedJavac()) {
                this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryInitialSize"), Project.MSG_WARN); //$NON-NLS-1$
            } else {
                cmd.createArgument().setValue(memoryParameterPrefix
                                              + "ms" + this.memoryInitialSize); //$NON-NLS-1$
            }
        }

        if (this.memoryMaximumSize != null) {
            if (!this.attributes.isForkedJavac()) {
                this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryMaximumSize"), Project.MSG_WARN); //$NON-NLS-1$
            } else {
                cmd.createArgument().setValue(memoryParameterPrefix
                                              + "mx" + this.memoryMaximumSize); //$NON-NLS-1$
            }
        }

        if (this.debug) {
         // retrieve the method getSourcepath() using reflect
          // This is done to improve the compatibility to ant 1.5
          Method getDebugLevelMethod = null;
          try {
            getDebugLevelMethod = javacClass.getMethod("getDebugLevel", null); //$NON-NLS-1$
          } catch(NoSuchMethodException e) {
            // if not found, then we cannot use this method (ant 1.5)
            // debug level is only available with ant 1.5.x
          }
           String debugLevel = null;
          if (getDebugLevelMethod != null) {
        try {
          debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, null);
        } catch (IllegalAccessException e) {
          // should never happen
        } catch (InvocationTargetException e) {
          // should never happen
        }
          }
      if (debugLevel != null) {
        this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
        this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
        this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE);
        if (debugLevel.length() != 0) {
          if (debugLevel.indexOf("vars") != -1) {//$NON-NLS-1$
            this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
          }
          if (debugLevel.indexOf("lines") != -1) {//$NON-NLS-1$
            this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
          }
          if (debugLevel.indexOf("source") != -1) {//$NON-NLS-1$
            this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE);
          }
        }
      } else {
        this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
        this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
        this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE);
            }
        } else {
      this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
      this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
      this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE);
        }
     
    /*
     * Handle the nowarn option. If none, then we generate all warnings.
     */
    if (this.attributes.getNowarn()) {
          // disable all warnings
      Object[] entries = this.customDefaultOptions.entrySet().toArray();
      for (int i = 0, max = entries.length; i < max; i++) {
        Map.Entry entry = (Map.Entry) entries[i];
        if (!(entry.getKey() instanceof String))
          continue;
        if (!(entry.getValue() instanceof String))
          continue;
        if (((String) entry.getValue()).equals(CompilerOptions.WARNING)) {
          this.customDefaultOptions.put(entry.getKey(), CompilerOptions.IGNORE);
        }
      }
      this.customDefaultOptions.put(CompilerOptions.OPTION_TaskTags, Util.EMPTY_STRING);
      if (this.deprecation) {
        this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
        this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED);
        this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.ENABLED);
      }
    } else if (this.deprecation) {
      this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
      this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.ENABLED);
      this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.ENABLED);
    } else {
      this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.IGNORE);
      this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode, CompilerOptions.DISABLED);
      this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED);
    }

       /*
     * destDir option.
     */   
    if (this.destDir != null) {
      cmd.createArgument().setValue("-d"); //$NON-NLS-1$
      cmd.createArgument().setFile(this.destDir.getAbsoluteFile());
    }

    /*
     * verbose option
     */
    if (this.verbose) {
      cmd.createArgument().setValue("-verbose"); //$NON-NLS-1$
    }

    /*
     * failnoerror option
     */
    if (!this.attributes.getFailonerror()) {
      cmd.createArgument().setValue("-proceedOnError"); //$NON-NLS-1$
    }

    /*
     * target option.
     */
    if (this.target != null) {
      this.customDefaultOptions.put(CompilerOptions.OPTION_TargetPlatform, this.target);
    }

    /*
     * source option
     */
    String source = this.attributes.getSource();
        if (source != null) {
      this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source);
        }

    /*
     * encoding option
     */
        if (this.encoding != null) {
            cmd.createArgument().setValue("-encoding"); //$NON-NLS-1$
            cmd.createArgument().setValue(this.encoding);
        }

    if (compilerArgs != null) {
          /*
       * Add extra argument on the command line
       */
      final int length = compilerArgs.length;
      if (length != 0) {
        for (int i = 0, max = length; i < max; i++) {
          String arg = compilerArgs[i];
          if (this.logFileName == null && "-log".equals(arg) && ((i + 1) < max)) { //$NON-NLS-1$
            this.logFileName = compilerArgs[i + 1];
          }
              cmd.createArgument().setValue(arg);
        }
      }
       }
       /*
     * Eclipse compiler doesn't have a -sourcepath option. This is
View Full Code Here

Examples of org.apache.xmlbeans.impl.tool.CommandLine

    opts.add("schemaCodePrinter");
    opts.add("extension");
    opts.add("extensionParms");
    opts.add("allowmdef");
    opts.add("catalog");
    CommandLine cl = new CommandLine(args, flags, opts);


    String[] badopts = cl.getBadOpts();
    if (badopts.length > 0) {
      for (int i = 0; i < badopts.length; i++)
        System.out.println("Unrecognized option: " + badopts[i]);
      return;
    }

    args = cl.args();
    boolean verbose = (cl.getOpt("verbose") != null);
    boolean quiet = (cl.getOpt("quiet") != null);
    if (verbose)
      quiet = false;


    String outputfilename = cl.getOpt("out");

    String repackage = cl.getOpt("repackage");

    String codePrinterClass = cl.getOpt("schemaCodePrinter");
    SchemaCodePrinter codePrinter = null;
    String name = cl.getOpt("name");

    boolean download = (cl.getOpt("dl") != null);
    boolean noUpa = (cl.getOpt("noupa") != null);
    boolean noPvr = (cl.getOpt("nopvr") != null);
    boolean noAnn = (cl.getOpt("noann") != null);
    boolean noVDoc = (cl.getOpt("novdoc") != null);
    boolean noExt = (cl.getOpt("noext") != null);
    boolean nojavac = (cl.getOpt("srconly") != null);
    boolean debug = (cl.getOpt("debug") != null);

    String allowmdef = cl.getOpt("allowmdef");
    Set mdefNamespaces = (allowmdef == null ? Collections.EMPTY_SET
        : new HashSet(Arrays.asList(XmlListImpl.split_list(allowmdef))));

    List extensions = new ArrayList();

    String classesdir = cl.getOpt("d");
    File classes = null;
    if (classesdir != null)
      classes = new File(classesdir);

    String srcdir = cl.getOpt("src");
    File src = null;
    if (srcdir != null)
      src = new File(srcdir);
    if (nojavac && srcdir == null && classes != null)
      src = classes;

    // create temp directory
    File tempdir = null;
    if (src == null || classes == null) {
      throw new XBayaRuntimeException("Code gen src directory or classes directory is null");
    }

    File jarfile = null;
    if (outputfilename == null && classes == null && !nojavac)
      outputfilename = "xmltypes.jar";
    if (outputfilename != null)
      jarfile = new File(outputfilename);

    if (src == null)
      src = IOUtil.createDir(tempdir, "src");
    if (classes == null)
      classes = IOUtil.createDir(tempdir, "classes");

    File[] classpath = null;
    String cpString = cl.getOpt("cp");
    if (cpString != null) {
      String[] cpparts = cpString.split(File.pathSeparator);
      List cpList = new ArrayList();
      for (int i = 0; i < cpparts.length; i++)
        cpList.add(new File(cpparts[i]));
      classpath = (File[]) cpList.toArray(new File[cpList.size()]);
    } else {
      classpath = CodeGenUtil.systemClasspath();
    }

    String javasource = cl.getOpt("javasource");
    String compiler = cl.getOpt("compiler");
    String jar = cl.getOpt("jar");
    if (verbose && jar != null)
      System.out.println("The 'jar' option is no longer supported.");

    String memoryInitialSize = cl.getOpt("ms");
    String memoryMaximumSize = cl.getOpt("mx");

    File[] xsdFiles = cl.filesEndingWith(".xsd");
    File[] wsdlFiles = cl.filesEndingWith(".wsdl");
    File[] javaFiles = cl.filesEndingWith(".java");
    File[] configFiles = cl.filesEndingWith(".xsdconfig");
    URL[] urlFiles = cl.getURLs();

    if (xsdFiles.length + wsdlFiles.length + urlFiles.length == 0) {
      System.out
          .println("Could not find any xsd or wsdl files to process.");
      return;
    }
    File baseDir = cl.getBaseDir();
    URI baseURI = baseDir == null ? null : baseDir.toURI();

    XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);

    String catString = cl.getOpt("catalog");

    Parameters params = new Parameters();
    params.setBaseDir(baseDir);
    params.setXsdFiles(xsdFiles);
    params.setWsdlFiles(wsdlFiles);
View Full Code Here

Examples of org.codehaus.plexus.compiler.javac.Commandline

   * @throws MojoExecutionException
   */
    public void execute() throws MojoExecutionException
    {
        getLog().debug( "Using apt compiler" );
        Commandline cmd = new Commandline();
        int result = APT_COMPILER_SUCCESS;
        StringWriter writer = new StringWriter();

        // Use reflection to be able to build on all JDKs:
        try
        {
            // init comand line
            setAptCommandlineSwitches( cmd );
            setAptSpecifics( cmd );
            setStandards( cmd );
            setClasspath( cmd );
            List sourceFiles = new ArrayList();
            if ( !fillSourcelist( sourceFiles ) )
            {
                if ( getLog().isDebugEnabled() )
                {
                    getLog().debug( "there are not stale sources." );
                }
                return;
            }
            else
            {
                if ( fork )
                {

                     if ( !tempRoot.exists() )
                     {
                         tempRoot.mkdirs();
                     }
                     File file = new File( tempRoot , "files" );
                     if ( !getLog().isDebugEnabled() )
                     {
                         file.deleteOnExit();
                     }
                     try
                     {
                         FileUtils.fileWrite( file.getAbsolutePath(),
                                 StringUtils.join( sourceFiles.iterator(), "\n" ) );
                         cmd.createArgument().setValue( '@' + file.getPath() );
                     }
                     catch ( IOException e )
                     {
                         throw new MojoExecutionException( "Unable to write temporary file for command execution", e );
                     }
                }
                else
                {
                    Iterator sourceIt = sourceFiles.iterator();
                    while ( sourceIt.hasNext() )
                    {
                        cmdAdd( cmd, (String) sourceIt.next() );
                    }
                }
            }
            if ( fork )
            {
                if ( getLog().isDebugEnabled() )
                {
                    getLog().debug( "Working dir: " + workingDir.getAbsolutePath() );
                }
                cmd.setWorkingDirectory( workingDir.getAbsolutePath() );
                cmd.setExecutable( getAptPath() );

                if ( getLog().isDebugEnabled() )
                {
                    getLog().debug( "Invoking apt with cmd " + Commandline.toString( cmd.getShellCommandline() ) );
                }

                CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
                try
                {
                    int exitCode = CommandLineUtils.executeCommandLine( cmd, new DefaultConsumer(), err );

                    getLog().error( err.getOutput() );

                    if ( exitCode != 0 )
                    {
                        throw new MojoExecutionException( "Exit code: " + exitCode + " - " + err.getOutput() );
                    }
                 }
                 catch ( CommandLineException e )
                 {
                     throw new MojoExecutionException( "Unable to execute apt command", e );
                 }
            }
            else
            {
                // we need to have tools.jar in lasspath
                // due to bug in Apt compiler, system classpath must be modified but in future:
                // TODO try separate ClassLoader (see Plexus compiler api)
                if ( !isClasspathModified )
                {
                    URL toolsJar = new File( System.getProperty( "java.home" ),
                        "../lib/tools.jar" ).toURL();
                    Method m = URLClassLoader.class.getDeclaredMethod( "addURL",
                          new Class[] { URL.class } );
                    m.setAccessible( true );
                    m.invoke( this.getClass().getClassLoader()
                        .getSystemClassLoader(), new Object[] { toolsJar } );
                    isClasspathModified = true;
                }
                Class c = this.getClass().forName( APT_ENTRY_POINT ); // getAptCompilerClass();
                Object compiler = c.newInstance();
                if ( getLog().isDebugEnabled() )
                {
                    getLog().debug( "Invoking apt with cmd " + cmd.toString() );
                }
                try
                {
                    Method compile = c.getMethod( APT_METHOD_NAME, new Class[] {
                        PrintWriter.class, ( new String[] {} ).getClass() } );
                    result = ( ( Integer ) //
                    compile.invoke( compiler, new Object[] { new PrintWriter( writer ),
                          cmd.getArguments() } ) ).intValue();
                }
                catch ( NoSuchMethodException e )
                {
                  // ignore
                    Method compile = c.getMethod( APT_METHOD_NAME_OLD, new Class[] {
                        ( new String[] {} ).getClass(),  PrintWriter.class } );
                    result = ( ( Integer ) //
                    compile.invoke( compiler, new Object[] {
                          cmd.getArguments()new PrintWriter( writer ) } ) ).intValue();
                }
            }


        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.