Package org.apache.tools.ant

Examples of org.apache.tools.ant.BuildException


        initializeContextClassLoader();
        try
        {
            if (this.configurationUri == null)
            {
                throw new BuildException("Configuration is not a valid URI --> '" + this.configurationUri + "'");
            }

            // Create the configuration file from URI
            final Configuration configuration = Configuration.getInstance(this.configurationUri);

            // Create and start the server
            final AndroMDAServer andromdaServer = AndroMDAServer.newInstance();
            if (andromdaServer != null)
            {
                andromdaServer.start(configuration);
            }
        }
        catch (Throwable throwable)
        {
            final Throwable cause = ExceptionUtils.getCause(throwable);
            if (cause != null)
            {
                throwable = cause;
            }
            if (throwable instanceof FileNotFoundException)
            {
                throw new BuildException("No configuration could be loaded from --> '" + configurationUri + "'");
            }
            throw new BuildException(throwable);
        }
        finally
        {
            // Set the context class loader back ot its system class loaders
            // so that any processes running after won't be trying to use
View Full Code Here


        initializeContextClassLoader();
        try
        {
            if (this.configurationUri == null)
            {
                throw new BuildException("Configuration is not a valid URI --> '" + this.configurationUri + "'");
            }

            // Create the configuration file
            final Configuration configuration = Configuration.getInstance(this.configurationUri);

            final AndroMDAServer andromdaServer = AndroMDAServer.newInstance();
            if (andromdaServer != null)
            {
                andromdaServer.stop(configuration);
            }
        }
        catch (Throwable throwable)
        {
            final Throwable cause = ExceptionUtils.getCause(throwable);
            if (cause != null)
            {
                throwable = cause;
            }
            if (throwable instanceof FileNotFoundException)
            {
                throw new BuildException("No configuration could be loaded from --> '" + configurationUri + "'");
            }
            throw new BuildException(throwable);
        }
        finally
        {
            // Set the context class loader back ot its system class loaders
            // so that any processes running after won't be trying to use
View Full Code Here

 
  @Override
  public void execute() throws BuildException {
   
    if (name==null){
      throw new BuildException("name not specified.");
    }
    if (output==null){
      throw new BuildException("output directory is not specified.");
    }
   
    File fConfFile=null;
   
    if (indexDir!=null){
      File tempF=new File(indexDir,"bobo.spring");
      if (tempF.exists() && tempF.isFile()){
        fConfFile=tempF;
      }
    }
   
    if (fConfFile==null && fieldConf!=null){
      File tempF=new File(fieldConf);
      if (tempF.exists() && tempF.isFile()){
        fConfFile=tempF;
      }
    }
   
    if (fConfFile==null){
      throw new BuildException("Please provide field.xml location by either setting the indexDir or the fieldConf property.");
    }
   
   
    List<FacetHandler<?>> fConf=null;
   
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    ApplicationContext appCtx=null;
    try{
      appCtx=new FileSystemXmlApplicationContext("file:"+fConfFile.getAbsolutePath());
      fConf =  (List<FacetHandler<?>>)appCtx.getBean("handlers");
    }
    catch(Exception e){
      throw new BuildException(e.getMessage(),e);
    }
   
    File baseDir=getProject().getBaseDir();
   
    ArrayList<File> copyList=new ArrayList<File>(10);
    copyList.add(new File(new File(baseDir,"webapp"),"bobobase.js"));
    copyList.add(new File(new File(baseDir,"webapp"),"browse.js"));
    copyList.add(new File(new File(baseDir,"webapp"),"style.css"));
    copyList.add(new File(new File(baseDir,"webapp"),"json.js"));
    copyList.add(new File(new File(baseDir,"webapp"),"widgets.js"));
    copyList.add(new File(new File(baseDir,"webapp"),"remote.js"));
   
    File outputDir=new File(new File(baseDir,output),name);
    outputDir.mkdirs();
    try{
      Iterator<File> iter=copyList.iterator();
      while(iter.hasNext()){
        copyFile(iter.next(),outputDir);
      }
    }
    catch(IOException e){
      throw new BuildException(e.getMessage(),e);
    }
   
    try {
      //writeWebXML(outputDir, indexDir);
      writeApplicationJS(outputDir, fConf);
      writeHTML(outputDir, fConf);
    } catch (IOException e) {
      throw new BuildException(e.getMessage(),e);
    }
  }
View Full Code Here

            {
                parser.parse(configuration);
            }
            catch (ParseException ex)
            {
                throw new BuildException(ex.getMessage());
            }
            finally
            {
                parser.close();
            }
        }
        catch (IOException ex)
        {
            throw new BuildException(ex.getMessage());
        }
    }
View Full Code Here

    /**
     * @deprecated Use the nested outjar element instead.
     */
    public void setOutjar(String parameters)
    {
        throw new BuildException("Use the <outjar> nested element instead of the 'outjar' attribute");
    }
View Full Code Here

    public void setTarget(String target)
    {
        configuration.targetClassVersion = ClassUtil.internalClassVersion(target);
        if (configuration.targetClassVersion == 0)
        {
            throw new BuildException("Unsupported target '"+target+"'");
        }
    }
View Full Code Here

            ProGuard proGuard = new ProGuard(configuration);
            proGuard.execute();
        }
        catch (IOException ex)
        {
            throw new BuildException(ex.getMessage());
        }
    }
View Full Code Here

    AlertCounter counter = new AlertCounter(alertSink, getAlertPolicy());

    try {
      new Compiler(this).call(counter);
    } catch (InvalidConfigException e) {
      throw new BuildException(e);
    }

    if (counter.getErrorCount() > 0) {
      throw new BuildException("Compile failed; see the compiler error output for details.");
    }
  }
View Full Code Here

    }
  }

  public void configure() throws BuildException {
    if (fileScanner.getBasedir() == null) {
      throw new BuildException("Attribute 'srcdir' was not set.");
    }

    fileScanner.scan();

    String baseDir = fileScanner.getBasedir().getPath() + File.separator;
View Full Code Here

        log.debug("execute()");

        command = command.trim();

        if (srcFile == null && command.length() == 0 && filesets.isEmpty()) {
            throw new BuildException("Source file does not exist!", getLocation());
        }

        if (srcFile != null && !srcFile.exists()) {
            throw new BuildException("Source file does not exist!", getLocation());
        }

        // TODO: any of this used?
        // deal with the filesets
        for (int i = 0; i < filesets.size(); i++) {
            FileSet fs = filesets.elementAt(i);
            DirectoryScanner ds = fs.getDirectoryScanner(getProject());
            File srcDir = fs.getDir(getProject());
            String[] srcFiles = ds.getIncludedFiles();
        }

        try {
            PrintStream out = System.out;
            try {
                if (output != null) {
                    log.verbose("Opening PrintStream to output file " + output);
                    out = new PrintStream(
                            new BufferedOutputStream(
                                    new FileOutputStream(output.getAbsolutePath(), append)));
                }

                // if there are no groovy statements between the enclosing Groovy tags
                // then read groovy statements in from a text file using the src attribute
                if (command == null || command.trim().length() == 0) {
                    createClasspath().add(new Path(getProject(), srcFile.getParentFile().getCanonicalPath()));
                    command = getText(new BufferedReader(new FileReader(srcFile)));
                }

                if (command != null) {
                    execGroovy(command, out);
                } else {
                    throw new BuildException("Source file does not exist!", getLocation());
                }

            } finally {
                if (out != null && out != System.out) {
                    out.close();
                }
            }
        } catch (IOException e) {
            throw new BuildException(e, getLocation());
        }

        log.verbose("statements executed successfully");
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.BuildException

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.