Examples of Java


Examples of org.apache.tools.ant.taskdefs.Java

        }

        log.info("Starting Geronimo server...");

        // Setup the JVM to start the server with
        final Java java = (Java)createTask("java");
        java.setClassname("org.apache.geronimo.cli.daemon.DaemonCLI");
        Path path = java.createClasspath();
        File libDir = new File(geronimoHome, "lib");
        FileSet fileSet = new FileSet();
        fileSet.setDir(libDir);
        path.addFileset(fileSet);
        java.setDir(geronimoHome);
        java.setFailonerror(true);
        java.setFork(true);

        if (javaVirtualMachine != null) {
            if (!javaVirtualMachine.exists()) {
                throw new MojoExecutionException("Java virtual machine is not valid: " + javaVirtualMachine);
            }
           
            log.info("Using Java virtual machine: " + javaVirtualMachine);
            java.setJvm(javaVirtualMachine.getCanonicalPath());
        }
       
        if (timeout > 0) {
            java.setTimeout(new Long(timeout * 1000));
        }

        if (maximumMemory != null) {
            java.setMaxmemory(maximumMemory);
        }
       
        if (maxPermSize != null){   
            java.createJvmarg().setValue("-XX:MaxPermSize="+maxPermSize);        
        }
       
        // Load the Java programming language agent for JPA
        File javaAgentJar = new File(geronimoHome, "lib/agent/transformer.jar");
        if (javaAgentJar.exists()) {
            java.createJvmarg().setValue("-javaagent:" + javaAgentJar.getCanonicalPath());
        }

        // Propagate some properties from Maven to the server if enabled
        if (propagateGeronimoProperties) {
            Properties props = System.getProperties();
            Iterator iter = props.keySet().iterator();
            while (iter.hasNext()) {
                String name = (String)iter.next();
                String value = System.getProperty(name);

                if (name.equals("geronimo.bootstrap.logging.enabled")) {
                    // Skip this property, never propagate it
                }
                else if (name.startsWith("org.apache.geronimo") || name.startsWith("geronimo")) {
                    if (log.isDebugEnabled()) {
                        log.debug("Propagating: " + name + "=" + value);
                    }
                    setSystemProperty(java, name, value);
                }
            }
        }

        // Apply option sets
        if (options != null  && (optionSets == null || optionSets.length == 0)) {
            throw new MojoExecutionException("At least one optionSet must be defined to select one using options");
        }
        else if (options == null) {
            options = "default";
        }

        if (optionSets != null && optionSets.length != 0) {
            OptionSet[] sets = selectOptionSets();

            for (int i=0; i < sets.length; i++) {
                if (log.isDebugEnabled()) {
                    log.debug("Selected option set: " + sets[i]);
                }
                else {
                    log.info("Selected option set: " + sets[i].getId());
                }

                String[] options = sets[i].getOptions();
                if (options != null) {
                    for (int j=0; j < options.length; j++) {
                        java.createJvmarg().setValue(options[j]);
                    }
                }

                Properties props = sets[i].getProperties();
                if (props != null) {
                    Iterator iter = props.keySet().iterator();
                    while (iter.hasNext()) {
                        String name = (String)iter.next();
                        String value = props.getProperty(name);

                        setSystemProperty(java, name, value);
                    }
                }
            }
        }

        // Set the properties which we pass to the JVM from the startup script
        setSystemProperty(java, "org.apache.geronimo.home.dir", geronimoHome);
        setSystemProperty(java, "karaf.home", geronimoHome);
        setSystemProperty(java, "karaf.base", geronimoHome);
        // Use relative path
        setSystemProperty(java, "java.io.tmpdir", "var/temp");
        setSystemProperty(java, "java.endorsed.dirs", prefixSystemPath("java.endorsed.dirs", new File(geronimoHome, "lib/endorsed")));
        setSystemProperty(java, "java.ext.dirs", prefixSystemPath("java.ext.dirs", new File(geronimoHome, "lib/ext")));
        // set console properties
        setSystemProperty(java, "karaf.startLocalConsole", "false");
        setSystemProperty(java, "karaf.startRemoteShell", "true");

        if (quiet) {
            java.createArg().setValue("--quiet");
        }
        else {
            java.createArg().setValue("--long");
        }

        if (verbose) {
            java.createArg().setValue("--verbose");
        }

        if (veryverbose) {
            java.createArg().setValue("--veryverbose");
        }

        if (startModules != null) {
            if (startModules.length == 0) {
                throw new MojoExecutionException("At least one module name must be configured with startModule");
            }

            log.info("Overriding the set of modules to be started");

            java.createArg().setValue("--override");

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

        //
        // TODO: Check if this really does capture STDERR or not!
        //

        if (logOutput) {
            File file = getLogFile();
            FileUtils.forceMkdir(file.getParentFile());

            log.info("Redirecting output to: " + file);

            java.setOutput(file);
        }

        // Holds any exception that was thrown during startup
        final ObjectHolder errorHolder = new ObjectHolder();

        StopWatch watch = new StopWatch();
        watch.start();

        // Start the server int a seperate thread
        Thread t = new Thread("Geronimo Server Runner") {
            public void run() {
                try {
                    java.execute();
                }
                catch (Exception e) {
                    errorHolder.set(e);

                    //
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

            throw new MojoExecutionException("Geronimo installation directory does not exist: " + geronimoHomeStr);
        }

        log.info("Starting Geronimo client...");

        Java java = (Java)createTask("java");
        java.setClassname("org.apache.geronimo.cli.client.ClientCLI");
        Path path = java.createClasspath();
        File libDir = new File(geronimoHome, "lib");
        FileSet fileSet = new FileSet();
        fileSet.setDir(libDir);
        path.addFileset(fileSet);
        java.setDir(geronimoHome);
        java.setFailonerror(true);
        java.setFork(true);

        if (javaVirtualMachine != null) {
            if (!javaVirtualMachine.exists()) {
                throw new MojoExecutionException("Java virtual machine is not valid: " + javaVirtualMachine);
            }
           
            log.info("Using Java virtual machine: " + javaVirtualMachine);
            java.setJvm(javaVirtualMachine.getCanonicalPath());
        }
       
        if (timeout > 0) {
            java.setTimeout(new Long(timeout * 1000));
        }

        if (maximumMemory != null) {
            java.setMaxmemory(maximumMemory);
        }

        // Set the properties which we pass to the JVM from the startup script
        setSystemProperty(java, "org.apache.geronimo.home.dir", geronimoHome);
        setSystemProperty(java, "karaf.home", geronimoHome);
        setSystemProperty(java, "karaf.base", geronimoHome);
        // Use relative path
        setSystemProperty(java, "java.io.tmpdir", "var/temp");
        setSystemProperty(java, "java.endorsed.dirs", prefixSystemPath("java.endorsed.dirs", new File(geronimoHome, "lib/endorsed")));
        setSystemProperty(java, "java.ext.dirs", prefixSystemPath("java.ext.dirs", new File(geronimoHome, "lib/ext")));
        // set console properties
        setSystemProperty(java, "karaf.startLocalConsole", "false");
        setSystemProperty(java, "karaf.startRemoteShell", "false");
       
        java.createArg().setValue(moduleId);

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

        if (logOutput) {
            File file = getLogFile();
            FileUtils.forceMkdir(file.getParentFile());

            log.info("Redirecting output to: " + file);

            java.setOutput(file);
        }

        java.execute();
    }
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

   *
   */
  private void generateMap()
  {
    log("Generating map...");
    Java javatask = (Java) getProject().createTask("java");
    javatask.setClassname(ServiceMapper.class.getCanonicalName());
    javatask.setFork(true);
    javatask.setFailonerror(true);

    javatask.createJvmarg().setValue("-Dfile.encoding="+this.inputCharset );
   
    for (Argument arg : jvmArgs)
    {
      if(arg != null)
      {
        javatask.createJvmarg().setValue(arg.getParts()[0]);
      }
    }

    addServiceMapperParameters(javatask);
   
    for (Argument arg : args)
    {
      if(arg != null)
      {
        javatask.createArg().setValue(arg.getParts()[0]);
      }
    }

    for (Path path : this.classpath)
    {
      javatask.setClasspath(path);
    }
   
    int resultCode = javatask.executeJava();
    if (resultCode != 0)
    {
      if (this.failOnError )
      {
        throw new ServiceMapperException("Crux Service Mapper returned errors.");
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

   * @throws Exception
   */
  protected void compileFile() throws Exception
  {
    log("Compiling...");
    Java javatask = (Java) getProject().createTask("java");
    javatask.setClassname(getProgramClassName());
    javatask.setFork(true);
    javatask.setFailonerror(true);

    javatask.createJvmarg().setValue("-Dfile.encoding="+this.inputCharset );
   
    for (Argument arg : jvmArgs)
    {
      if(arg != null)
      {
        javatask.createJvmarg().setValue(arg.getParts()[0]);
      }
    }
    addCompilerParameters(javatask);

    for (Argument arg : args)
    {
      if(arg != null)
      {
        javatask.createArg().setValue(arg.getParts()[0]);
      }
    }

    for (Path path : this.classpath)
    {
      javatask.setClasspath(path);
    }
   
    int resultCode = javatask.executeJava();
    if (resultCode != 0)
    {
      if (this.failOnError )
      {
        throw new CompilerException("Crux Compiler returned errors.");
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

   * @throws Exception
   */
  protected void generateSchemas(File baseDir) throws Exception
  {
    log("Generating Schemas to: " + baseDir.getCanonicalPath() + "/" + outputDir);
    Java javatask = (Java) getProject().createTask("java");
    javatask.setClassname(SchemaGenerator.class.getName());
    javatask.setFork(true);

    javatask.createJvmarg().setValue("-Dfile.encoding="+this.inputCharset );
   
    for (Argument arg : jvmArgs)
    {
      if(arg != null)
      {
        javatask.createJvmarg().setValue(arg.getParts()[0]);
      }
    }
    javatask.createArg().setValue(baseDir.getCanonicalPath());
    javatask.createArg().setValue(outputDir.getCanonicalPath());
    addCompilerParameters(javatask);

    for (Path path : this.classpath)
    {
      javatask.setClasspath(path);
    }

    int resultCode = javatask.executeJava();
    if (resultCode != 0)
    {
      log("Error generating schemas.", 1);
    }
  }
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

         // Create an instance of the compiler, redirecting output to
         // the project log
         if (classpath == null)
            throw new BuildException("No classpath");
         classpath.append(compilerClasspath);
         Java java = (Java) (getProject().createTask("java"));
         if (getClasspath() != null)
         {
            getProject().log("using user supplied classpath: " + getClasspath(), Project.MSG_DEBUG);
            java.setClasspath(getClasspath().concatSystemClasspath("ignore"));
         }
         else
         {
            Path classpath = new Path(getProject());
            classpath = classpath.concatSystemClasspath("only");
            getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG);
            java.setClasspath(classpath);
         }

         java.setDir(getProject().getBaseDir());
         java.setClassname("org.jboss.ant.tasks.retrocheck.Checker");
         //this is really irritating; we need a way to set stuff
         String args[] = cmd.getJavaCommand().getArguments();
         for (int i = 0; i < args.length; i++)
         {
            java.createArg().setValue(args[i]);
         }
         java.setFailonerror(getFailonerror());
         //we are forking here to be sure that if JspC calls
         //System.exit() it doesn't halt the build
         java.setFork(true);
         java.setTaskName("retrocheck");
         if (maxmemory != null)
         {
            java.setMaxmemory(maxmemory);
         }
         java.execute();
      }
      catch (Exception ex)
      {
         if (ex instanceof BuildException)
         {
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

    /**
     * Create the FindBugs engine (the Java process that will run whatever
     * FindBugs-related program this task is going to execute).
     */
    protected void createFindbugsEngine() {
        findbugsEngine = new Java();
        findbugsEngine.setProject(getProject());
        findbugsEngine.setTaskName(getTaskName());
        findbugsEngine.setFork(true);
        if (jvm.length() > 0) {
            findbugsEngine.setJvm(jvm);
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

         // Create an instance of the compiler, redirecting output to
         // the project log
         if (classpath == null)
            throw new BuildException("No classpath");
         classpath.append(compilerClasspath);
         Java java = (Java) (getProject().createTask("java"));
         if (getClasspath() != null)
         {
            getProject().log("using user supplied classpath: " + getClasspath(), Project.MSG_DEBUG);
            java.setClasspath(getClasspath().concatSystemClasspath("ignore"));
         }
         else
         {
            Path classpath = new Path(getProject());
            classpath = classpath.concatSystemClasspath("only");
            getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG);
            java.setClasspath(classpath);
         }

         java.setDir(getProject().getBaseDir());
         java.setClassname("org.jboss.weaver.Main");

         // Pass in any jvmargs
         String[] jvmargs = cmd.getVmCommand().getArguments();
         for (int i = 0; i < jvmargs.length; i++)
         {
            java.createJvmarg().setValue(jvmargs[i]);
         }

         //this is really irritating; we need a way to set stuff
         String args[] = cmd.getJavaCommand().getArguments();
         for (int i = 0; i < args.length; i++)
         {
            java.createArg().setValue(args[i]);
         }
         java.setFailonerror(getFailonerror());

         // Fork is required to set a new classpath
         java.setFork(true);
         java.setTaskName("retro");
         if (maxmemory != null)
         {
            java.setMaxmemory(maxmemory);
         }
        
         java.execute();
      }
      catch (Exception ex)
      {
         if (ex instanceof BuildException)
         {
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

                instrumentDir.getAbsolutePath()));
            iContractClasspath.append(new Path(getProject(),
                buildDir.getAbsolutePath()));

            // Create a forked java process
            Java iContract = (Java) getProject().createTask("java");

            iContract.setTaskName(getTaskName());
            iContract.setFork(true);
            iContract.setClassname("com.reliablesystems.iContract.Tool");
            iContract.setClasspath(iContractClasspath);

            // Build the arguments to iContract
            StringBuffer args = new StringBuffer();

            args.append(directiveString());
            args.append("-v").append(verbosity).append(" ");

            args.append("-b").append("\"").append(icCompiler);
            args.append(" -classpath ").append(beforeInstrumentationClasspath);
            args.append("\" ");

            args.append("-c").append("\"").append(icCompiler);
            args.append(" -classpath ").append(afterInstrumentationClasspath);
            args.append(" -d ").append(buildDir).append("\" ");

            args.append("-n").append("\"").append(icCompiler);
            args.append(" -classpath ").append(repositoryClasspath);
            args.append("\" ");

            args.append("-d").append(failThrowable).append(" ");

            args.append("-o").append(instrumentDir).append(File.separator);
            args.append("@p").append(File.separator).append("@f.@e ");

            args.append("-k").append(repositoryDir).append(File.separator);
            args.append("@p ");

            args.append(quiet ? "-q " : "");
            // reinstrument everything if controlFile exists and is newer
            // than any class
            args.append(instrumentall ? "-a " : "");
            args.append("@").append(targets.getAbsolutePath());
            iContract.createArg().setLine(args.toString());

            //System.out.println( "JAVA -classpath " + iContractClasspath
            //    + " com.reliablesystems.iContract.Tool " + args.toString() );

            // update iControlProperties if it's set.
            if (updateIcontrol) {
                Properties iControlProps = new Properties();

                try {
                    // to read existing propertiesfile
                    iControlProps.load(new FileInputStream("icontrol.properties"));
                } catch (IOException e) {
                    log("File icontrol.properties not found. That's ok. "
                        + "Writing a default one.");
                }
                iControlProps.setProperty("sourceRoot",
                    srcDir.getAbsolutePath());
                iControlProps.setProperty("classRoot",
                    classDir.getAbsolutePath());
                iControlProps.setProperty("classpath",
                    afterInstrumentationClasspath.toString());
                iControlProps.setProperty("controlFile",
                    controlFile.getAbsolutePath());
                iControlProps.setProperty("targetsFile",
                    targets.getAbsolutePath());

                try {
                    // to read existing propertiesfile
                    iControlProps.store(new FileOutputStream("icontrol.properties"),
                        ICONTROL_PROPERTIES_HEADER);
                    log("Updated icontrol.properties");
                } catch (IOException e) {
                    log("Couldn't write icontrol.properties.");
                }
            }

            // do it!
            int result = iContract.executeJava();

            if (result != 0) {
                if (iContractMissing) {
                    log("iContract can't be found on your classpath. "
                        + "Your classpath is:");
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.Java

        if (serverURL == null) {
            throw new BuildException("The url of the weblogic server must be provided.");
        }

        Java weblogicAdmin = (Java) getProject().createTask("java");
        weblogicAdmin.setFork(true);
        weblogicAdmin.setClassname("weblogic.Admin");
        String args;

        if (beaHome == null) {
            args = serverURL + " SHUTDOWN " + username + " " + password + " " + delay;
        } else {
            args = " -url " + serverURL
                    + " -username " + username
                    + " -password " + password
                    + " SHUTDOWN " + " " + delay;
        }

        weblogicAdmin.createArg().setLine(args);
        weblogicAdmin.setClasspath(classpath);
        weblogicAdmin.execute();
    }
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.