Java Code Examples for org.apache.tools.ant.BuildException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project aether-ant, under directory /src/main/java/org/eclipse/aether/ant/.

Source file: AntRepoSys.java

  21 
vote

public synchronized RepositorySystem getSystem(){
  if (repoSys == null) {
    repoSys=locator.getService(RepositorySystem.class);
    if (repoSys == null) {
      throw new BuildException("The repository system could not be initialized");
    }
  }
  return repoSys;
}
 

Example 2

From project aether-ant, under directory /src/main/java/org/eclipse/aether/ant/.

Source file: AntRepoSys.java

  21 
vote

private synchronized RemoteRepositoryManager getRemoteRepoMan(){
  if (remoteRepoMan == null) {
    remoteRepoMan=locator.getService(RemoteRepositoryManager.class);
    if (remoteRepoMan == null) {
      throw new BuildException("The repository system could not be initialized");
    }
  }
  return remoteRepoMan;
}
 

Example 3

From project anadix, under directory /integration/anadix-ant/src/main/java/org/anadix/utils/.

Source file: AnalyzerAntTask.java

  21 
vote

private Analyzer createAnalyzer() throws BuildException {
  try {
    return Anadix.newAnalyzer();
  }
 catch (  InstantiationException ex) {
    throw new BuildException("Unable to istantiate Analyzer " + ex,ex);
  }
}
 

Example 4

From project anadix, under directory /integration/anadix-ant/src/main/java/org/anadix/utils/.

Source file: AnalyzerAntTask.java

  21 
vote

private Report analyzeFile(Analyzer analyzer,File file){
  try {
    Source s=SourceFactory.newFileSource(file);
    return analyzer.analyze(s);
  }
 catch (  SourceException ex) {
    throw new BuildException("Unable to create source",ex);
  }
}
 

Example 5

From project ant4eclipse, under directory /org.ant4eclipse.ant.cdt/src/org/ant4eclipse/ant/cdt/.

Source file: GetCdtSourcePathTask.java

  21 
vote

/** 
 * {@inheritDoc}
 */
@Override protected void preconditions() throws BuildException {
  super.preconditions();
  if (!CdtUtilities.isCRelatedProject(getEclipseProject())) {
    throw new BuildException(String.format("The project '%s' must have the c or c++ project role!",getEclipseProject().getSpecifiedName()));
  }
}
 

Example 6

From project ant4eclipse, under directory /org.ant4eclipse.ant.core/src/org/ant4eclipse/ant/core/.

Source file: AbstractAnt4EclipseCondition.java

  21 
vote

/** 
 * {@inheritDoc}
 */
public final boolean eval() throws BuildException {
  AbstractAnt4EclipseDataType.validateAll();
  AntConfigurator.configureAnt4Eclipse(getProject());
  try {
    return doEval();
  }
 catch (  Exception ex) {
    throw new BuildException(ex.toString(),ex);
  }
}
 

Example 7

From project avro, under directory /lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/.

Source file: ProtocolTask.java

  21 
vote

/** 
 * Run the compiler. 
 */
@Override public void execute(){
  if (src == null && filesets.size() == 0)   throw new BuildException("No file or fileset specified.");
  if (src != null)   compile(src);
  Project myProject=getProject();
  for (int i=0; i < filesets.size(); i++) {
    FileSet fs=filesets.get(i);
    DirectoryScanner ds=fs.getDirectoryScanner(myProject);
    File dir=fs.getDir(myProject);
    String[] srcs=ds.getIncludedFiles();
    for (int j=0; j < srcs.length; j++) {
      compile(new File(dir,srcs[j]));
    }
  }
}
 

Example 8

From project avro, under directory /lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/.

Source file: ProtocolTask.java

  21 
vote

private void compile(File file){
  try {
    doCompile(file,dest);
  }
 catch (  AvroRuntimeException e) {
    throw new BuildException(e);
  }
catch (  IOException e) {
    throw new BuildException(e);
  }
}
 

Example 9

From project aws-tasks, under directory /src/main/java/datameer/awstasks/ant/ec2/.

Source file: AbstractEc2ConnectTask.java

  21 
vote

@Override public final void doExecute(AmazonEC2 ec2) throws BuildException {
  InstanceGroup instanceGroup=new InstanceGroupImpl(ec2);
  try {
    instanceGroup.connectTo(_groupName);
    doExecute(ec2,instanceGroup);
  }
 catch (  Exception e) {
    LOG.info("execution " + getClass().getSimpleName() + " with groupName '"+ _groupName+ "' failed: "+ e.getMessage());
    throw new BuildException(e);
  }
}
 

Example 10

From project aws-tasks, under directory /src/main/java/datameer/awstasks/ant/ec2/.

Source file: Ec2LaunchTask.java

  21 
vote

protected void validate(){
  for (  GroupPermission groupPermission : _groupPermissions) {
    if (null == groupPermission.getSourceIp() || groupPermission.getSourceIp().trim().length() == 0) {
      throw new BuildException("GroupPermission '" + groupPermission + "' has no attribute 'sourceIp'.");
    }
  }
}
 

Example 11

From project bpelunit, under directory /net.bpelunit.framework.client.ant/src/main/java/net/bpelunit/framework/ui/ant/.

Source file: BPELUnit.java

  21 
vote

@Override public void execute(){
  checkAttributes();
  HashMap<String,String> options=new HashMap<String,String>();
  options.put(BPELUnitRunner.HALT_ON_ERROR,Boolean.toString(fHaltOnError));
  options.put(BPELUnitRunner.HALT_ON_FAILURE,Boolean.toString(fHaltOnFailure));
  BPELUnitAntRunner runner=new BPELUnitAntRunner(fBPELUnitDir,fLoggingList,fOutputList);
  try {
    runner.initialize(options);
    runner.run(fTestSuiteFile);
  }
 catch (  Exception e) {
    throw new BuildException(e.getMessage(),e);
  }
}
 

Example 12

From project cargo-maven2-plugin-db, under directory /src/main/java/org/codehaus/cargo/maven2/configuration/.

Source file: Deployable.java

  21 
vote

/** 
 * Call setter methods corresponding to deployable properties.
 * @param deployable the deployable on which to call the setter method corresponding to thespecified property
 */
private void callMethodForProperty(org.codehaus.cargo.container.deployable.Deployable deployable,String name,String value){
  try {
    Method method=deployable.getClass().getMethod(getSetterMethodName(name),new Class[]{String.class});
    method.invoke(deployable,new Object[]{value});
  }
 catch (  Exception e) {
    throw new BuildException("Invalid property [" + name + "] for deployable type ["+ deployable.getType()+ "]",e);
  }
}
 

Example 13

From project cpptasks-parallel, under directory /src/main/java/net/sf/antcontrib/cpptasks/compiler/.

Source file: CommandLineLinker.java

  21 
vote

protected String[] getOutputFileSwitch(CCTask task,String outputFile){
  if (isWindows() && outputFile.length() > maxPathLength) {
    throw new BuildException("Absolute path too long, " + outputFile.length() + " > "+ maxPathLength+ ": '"+ outputFile);
  }
  return getOutputFileSwitch(outputFile);
}
 

Example 14

From project cpptasks-parallel, under directory /src/main/java/net/sf/antcontrib/cpptasks/compiler/.

Source file: CommandLineLinker.java

  21 
vote

/** 
 * Processes filename into argument form
 */
protected String prepareFilename(StringBuffer buf,String outputDir,String sourceFile){
  if (isWindows() && sourceFile.length() > maxPathLength) {
    throw new BuildException("Absolute path too long, " + sourceFile.length() + " > "+ maxPathLength+ ": '"+ sourceFile);
  }
  return quoteFilename(buf,sourceFile);
}
 

Example 15

From project Aardvark, under directory /aardvark-core/src/main/java/gw/vark/.

Source file: AardvarkProgram.java

  20 
vote

public void runBuild(LinkedHashMap<String,TargetCall> targetCalls) throws BuildException {
  Throwable error=null;
  try {
    _project.fireBuildStarted();
    _project.init();
    _project.setBaseDir(_baseDir);
    try {
      maybeEvaluate();
      addTargets(_project,targetCalls);
    }
 catch (    Exception e) {
      throw new BuildException(e);
    }
    Vector<String> targets=new Vector<String>();
    if (targetCalls.size() > 0) {
      targets.addAll(targetCalls.keySet());
    }
 else     if (_project.getDefaultTarget() != null) {
      targets.add(_project.getDefaultTarget());
    }
    if (targets.size() == 0) {
      _project.log("No targets to run",Project.MSG_ERR);
    }
 else {
      _project.executeTargets(targets);
    }
  }
 catch (  RuntimeException e) {
    error=e;
    throw e;
  }
catch (  Error e) {
    error=e;
    throw e;
  }
 finally {
    _project.fireBuildFinished(error);
  }
}
 

Example 16

From project Aardvark, under directory /aardvark-core/src/main/java/gw/vark/task/.

Source file: GosuInvokerTask.java

  20 
vote

public void execute() throws BuildException {
  if (_expression.length() == 0) {
    throw new BuildException("no expression to evaluate");
  }
  try {
    IGosuParser parser=GosuParserFactory.createParser(_expression.toString(),new StandardSymbolTable(true));
    parser.parseExpOrProgram(null,false,true).evaluate();
  }
 catch (  IEvaluationException e) {
    if (e.getCause() != null && e.getCause() instanceof BuildException) {
      throw (BuildException)e.getCause();
    }
 else {
      throw e;
    }
  }
catch (  Exception e) {
    throw new BuildException(e);
  }
}
 

Example 17

From project AdServing, under directory /modules/services/geo/src/main/java/net/mad/ads/services/geo/ant/.

Source file: GeoIpImportTask.java

  20 
vote

@Override public void execute() throws BuildException {
  try {
    IPLocationDB readerhsql=new MaxmindIpLocationDB();
    readerhsql.open(exportDir);
    long before=System.currentTimeMillis();
    System.out.println("start import maxmind");
    readerhsql.importCountry(importDir);
    long after=System.currentTimeMillis();
    System.out.println("end import after: " + (after - before) + "ms");
    readerhsql.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new BuildException(e);
  }
}
 

Example 18

From project apb, under directory /modules/apb-ant/src/apb/ant/.

Source file: ApbTask.java

  20 
vote

public void execute() throws BuildException {
  super.execute();
  final Environment env=apb.getEnvironment();
  env.setNonRecursive(!recurse);
  if (module == null) {
    throw new BuildException("You must specify a module name");
  }
  try {
    final File dir=defdir == null ? null : new File(defdir);
    apb.build(dir,module,command);
  }
 catch (  Throwable throwable) {
    throw new BuildException(throwable);
  }
}
 

Example 19

From project bpelunit, under directory /net.bpelunit.framework.client.ant/src/main/java/net/bpelunit/framework/ui/ant/.

Source file: BPELUnit.java

  20 
vote

private void checkAttributes(){
  if (fTestSuiteFile == null) {
    throw new BuildException("The testsuite argument is required.");
  }
  if (!fTestSuiteFile.exists()) {
    throw new BuildException("The testsuite file does not exist.");
  }
  if (StringUtils.isEmpty(fBPELUnitDir)) {
    throw new BuildException("The BPELUnit directory is required - either specify an argument or set environment variable BPELUNIT_HOME.");
  }
  for (  Output output : fOutputList) {
    if (!output.hasValidStyle()) {
      throw new BuildException("An output specification is missing the style attribute, or wrong style specified.");
    }
  }
  for (  Logging logging : fLoggingList) {
    if (!logging.hasValidLevel()) {
      throw new BuildException("A logging specification is missing the level attribute, or wrong level specified.");
    }
  }
}
 

Example 20

From project CIShell, under directory /templates/org.cishell.templates.tasks/src/org/cishell/templates/dataset/.

Source file: DatasetIntegrationTask.java

  20 
vote

public void execute() throws BuildException {
  if (baseDir != null && baseDir.exists() && baseDir.isDirectory() && baseProperties != null && template != null && template.exists()) {
    try {
      setupManifest();
      File dataDir=new File(baseDir.getAbsolutePath() + File.separator + "data");
      if (dataDir.exists() && dataDir.isDirectory()) {
        processDir(dataDir);
      }
 else {
        throw new BuildException("Missing required 'data' directory");
      }
      writeManifest();
    }
 catch (    Throwable e) {
      e.printStackTrace();
      throw new BuildException(e);
    }
  }
 else {
    throw new BuildException("Invalid or missing argument(s).");
  }
}
 

Example 21

From project CIShell, under directory /templates/org.cishell.templates.tasks/src/org/cishell/templates/dataset/.

Source file: DatasetIntegrationTask.java

  20 
vote

protected void addDataset(File dataProps) throws IOException {
  File dataFile=new File(dataProps.getParent() + File.separator + dataProps.getName().substring(0,dataProps.getName().length() - 11));
  if (!dataFile.exists()) {
    throw new BuildException("Data file: " + dataFile.getName() + " for .properties file does not exist!");
  }
  PrintWriter out=new PrintWriter(new FileWriter(dataProps,true));
  out.println();
  out.println("type=dataset");
  out.println("remoteable=true");
  String symbolicDir="";
  File parent=dataProps.getParentFile();
  while (parent != null && !parent.getName().equals("data") && !parent.getParent().equals(baseDir.getName())) {
    symbolicDir=parent.getName() + "." + symbolicDir;
    parent=parent.getParentFile();
  }
  symbolicDir="." + symbolicDir;
  String pid=symbolicName + dataFile.getName();
  out.println("service.pid=" + pid);
  out.close();
  symbolicDir="/data" + symbolicDir;
  File componentFile=new File(dataFile.getPath() + ".component.xml");
  util.copyFile(template,componentFile);
  replace(componentFile,"${service.properties}",symbolicDir + dataProps.getName());
  replace(componentFile,"${component.id}",pid + ".component");
  replace(componentFile,"${dataset}",symbolicDir + dataFile.getName());
  if (componentAttr.length() != 0) {
    componentAttr+=", ";
  }
  componentAttr+=symbolicDir + componentFile.getName();
}
 

Example 22

From project clutter, under directory /src/com/thoughtworks/ashcroft/analysis/.

Source file: StaticFactoryDetectorTask.java

  20 
vote

protected void processClasses(JavaClass[] javaClasses){
  StringWriter reportWriter=new StringWriter();
  try {
    for (int i=0; i < javaClasses.length; i++) {
      staticFactoryDetector.writeReport(javaClasses[i],reportWriter);
    }
    String report=reportWriter.getBuffer().toString();
    if (!report.equals("")) {
      throw new BuildException(MESSAGE + report);
    }
  }
 catch (  IOException e) {
    throw new BuildException(e);
  }
}
 

Example 23

From project cloudbees-deployer-plugin, under directory /src/main/java/org/jenkins/plugins/cloudbees/util/.

Source file: FileFinder.java

  19 
vote

public List<String> find(final File workspace){
  try {
    FileSet fileSet=new FileSet();
    Project antProject=new Project();
    fileSet.setProject(antProject);
    fileSet.setDir(workspace);
    fileSet.setIncludes(pattern);
    String[] files=fileSet.getDirectoryScanner(antProject).getIncludedFiles();
    return files == null ? Collections.<String>emptyList() : Arrays.asList(files);
  }
 catch (  BuildException exception) {
    return Collections.emptyList();
  }
}
 

Example 24

From project cloudify, under directory /esc/src/main/java/org/cloudifysource/esc/installer/.

Source file: AgentlessInstaller.java

  19 
vote

private void sshCommand(final String host,final String command,final String username,final String password,final String keyFile,final long timeout,final TimeUnit unit) throws InstallerException, TimeoutException {
  try {
    Utils.executeSSHCommand(host,command,username,password,keyFile,timeout,unit);
  }
 catch (  final BuildException e) {
    logger.log(Level.FINE,"The remote boostrap command failed with error: " + e.getMessage() + ". The command that failed to execute is : "+ command,e);
    if (e instanceof BuildTimeoutException) {
      final TimeoutException ex=new TimeoutException("Remote bootstrap command failed to execute: " + e.getMessage());
      ex.initCause(e);
      throw ex;
    }
 else     if (e instanceof ExitStatusException) {
      final ExitStatusException ex=(ExitStatusException)e;
      final int ec=ex.getStatus();
      throw new InstallerException("Remote bootstrap command failed with exit code: " + ec,e);
    }
 else {
      throw new InstallerException("Remote bootstrap command failed to execute.",e);
    }
  }
}
 

Example 25

From project cloudify, under directory /esc/src/main/java/org/cloudifysource/esc/installer/remoteExec/.

Source file: SshExecutor.java

  19 
vote

@Override public void execute(final InstallationDetails details,final String command,final long endTimeMillis) throws InstallerException, TimeoutException {
  String host=null;
  if (details.isConnectedToPrivateIp()) {
    host=details.getPrivateIp();
  }
 else {
    host=details.getPublicIp();
  }
  try {
    Utils.executeSSHCommand(host,command,details.getUsername(),details.getPassword(),details.getKeyFile(),endTimeMillis - System.currentTimeMillis(),TimeUnit.MILLISECONDS);
  }
 catch (  final BuildException e) {
    logger.log(Level.FINE,"The remote boostrap command failed with error: " + e.getMessage() + ". The command that failed to execute is : "+ command,e);
    if (e instanceof BuildTimeoutException) {
      final TimeoutException ex=new TimeoutException("Remote bootstrap command failed to execute: " + e.getMessage());
      ex.initCause(e);
      throw ex;
    }
 else     if (e instanceof ExitStatusException) {
      final ExitStatusException ex=(ExitStatusException)e;
      final int ec=ex.getStatus();
      throw new InstallerException("Remote bootstrap command failed with exit code: " + ec,e);
    }
 else {
      throw new InstallerException("Remote bootstrap command failed to execute.",e);
    }
  }
}