Package aQute.bnd.build

Examples of aQute.bnd.build.Project


        context.registerService(Workspace.class.getName(), ws, null);
    }

    public Project getModel(IJavaProject project) {
        try {
            Project model = javaProjectToModel.get(project);
            if (model == null) {
                File projectDir = project.getProject().getLocation()
                        .makeAbsolute().toFile();
                model = Workspace.getProject(projectDir);
                if (workspace == null) {
                    model.getWorkspace();
                }
                if (model != null) {
                    javaProjectToModel.put(project, model);
                }
            }
View Full Code Here


                                                .getCurrentProjects());
                                    }
                                    return false;
                                }
                                if (workspace.isPresent(file.getName())) {
                                    Project project = workspace.getProject(file
                                            .getName());
                                    changed.add(project);
                                } else {
                                    ; // Project not created yet, so we
                                    // have
View Full Code Here

        if ( basedir == null )
            throw new BuildException("No basedir set");
       
        try {
            Project project = Workspace.getProject(basedir);
            project.setProperty("in.ant", "true");
            project.setProperty("environment", "ant");
            project.setExceptions(true);
            project.action(command);
           
            if ( report(project) )
                throw new BuildException("Command " + command + " failed");
        } catch (Throwable e) {
            if ( exceptions)
View Full Code Here

    try {
      // Prepare list of projects...
      List<Project> projects;
      File baseDir = getProject().getBaseDir();
      Project baseProject = Workspace.getProject(baseDir);
      if (runFiles == null) {
        projects = Collections.singletonList(baseProject);
      } else {
        StringTokenizer tokenizer = new StringTokenizer(runFiles, ",");
        projects = new LinkedList<Project>();
        while (tokenizer.hasMoreTokens()) {
          String runFilePath = tokenizer.nextToken().trim();
          Project runProject;
          if (".".equals(runFilePath)) {
            runProject = baseProject;
          } else {
            File runFile = new File(baseDir, runFilePath);
            if (!runFile.isFile())
              throw new BuildException(String.format("Run file %s does not exist (or is not a file).",
                  runFile.getAbsolutePath()));
            runProject = new Project(baseProject.getWorkspace(), baseDir, runFile);
            runProject.setParent(baseProject);
          }
          projects.add(runProject);
        }
      }
View Full Code Here

  public void execute() throws BuildException {
    try {
      createReleaseDir();
      BndEditModel model = new BndEditModel();
      model.loadFrom(bndFile);
      Project bndProject = new Project(new Workspace(rootDir), buildProject, bndFile);
      List<RepositoryPlugin> repositories = bndProject.getPlugins(RepositoryPlugin.class);
      if (allowSnapshots) {
        snapshots = indexBundleSnapshots();
      }

      for (VersionedClause runBundle : model.getRunBundles()) {
       
        String bsn = runBundle.getName();
        if (bsn.endsWith(".jar")) {
          bsn = bsn.substring(0, bsn.indexOf(".jar"));
        }
        if (allowSnapshots && snapshots.containsKey(bsn)) {
          Jar jar = snapshots.get(bsn);
          jar.write(new File(outputDir, jar.getName() + "-" + jar.getVersion() + ".jar"));
        } else {
          Version version = null;
          File foundJar = null;

          for (RepositoryPlugin repo : repositories) {
            SortedSet<Version> versions = repo.versions(bsn);
            for (Version availableVersion : versions) {
              VersionRange range = null;
             
              if(runBundle.getVersionRange() != null &&  !runBundle.getVersionRange().equals("latest")) {
                range = new VersionRange(runBundle.getVersionRange());
              }
             
              boolean rangeMatches = range == null || range.includes(availableVersion);
              boolean availableMatches = version == null || availableVersion.compareTo(version) > 0;

              if (rangeMatches && availableMatches) {
                version = availableVersion;
                foundJar = repo.get(bsn, version, null);
              }
            }
          }

          if (foundJar != null) {
            File outputFile = new File(outputDir, foundJar.getName());
            FileChannel source = null;
            FileChannel destination = null;

            try {
              source = new FileInputStream(foundJar).getChannel();
              destination = new FileOutputStream(outputFile).getChannel();
              destination.transferFrom(source, 0, source.size());
            }
            finally {
              if (source != null) {
                source.close();
              }

              if (destination != null) {
                destination.close();
              }
            }
          } else {
            log(bsn + " could not be found in any repository");
          }
        }
      }

      bndProject.close();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    if (basedir == null)
      throw new BuildException("No basedir set");

    try {
      Project project = Workspace.getProject(basedir);

      Workspace ws = project.getWorkspace();
      for (Property prop : workspaceProps) {
        ws.setProperty(prop.getName(), prop.getValue());
      }

      project.setProperty("in.ant", "true");
      project.setProperty("environment", "ant");
      project.setExceptions(true);
      project.setTrace(trace);
      project.setPedantic(pedantic);

      for (Property prop : properties) {
        project.setProperty(prop.getName(), prop.getValue());
      }

      if ( test )
        project.action(command,test);
      else
        project.action(command);
       

      for (Project p : ws.getCurrentProjects())
        ws.getInfo(p, p + ":");
View Full Code Here

        }
        catch (Exception e) {
          throw new BuildException(e);
        }
      } else {
        Project p = new Project(workspace, projectLocation, new File(projectLocation, bndFile));
        try {
          projects = p.getDependson();
        }
        finally {
          p.close();
        }
      }

      StringBuilder sb = new StringBuilder();
      String sep = "";
View Full Code Here

        throw new BuildException("The given base dir does not exist " + basedir);

      Workspace workspace = Workspace.getWorkspace(basedir.getParentFile());
      workspace.addBasicPlugin(new ConsoleProgress());

      Project project = workspace.getProject(basedir.getName());
      if (project == null)
        throw new BuildException("Unable to find bnd project in directory: " + basedir);

      project.setProperty("in.ant", "true");
      project.setProperty("environment", "ant");

      // Check if we are in a sub build, in that case
      // top will be set to the target directory at the
      // top project.
      if (top != null && top.length() > 0 && !top.startsWith("$"))
        project.setProperty("top", top);

      project.setExceptions(true);

      Properties properties = project.getFlattenedProperties();

      checkForTesting(project, properties);

      if (report() || report(workspace) || report(project))
        throw new BuildException("Errors during preparing bnd");
View Full Code Here

  public void execute() throws BuildException {
    try {
      createReleaseDir();
      BndEditModel model = new BndEditModel();
      model.loadFrom(bndFile);
      Project bndProject = new Project(new Workspace(rootDir), buildProject, bndFile);
      List<RepositoryPlugin> repositories = bndProject.getPlugins(RepositoryPlugin.class);
      if (allowSnapshots) {
        snapshots = indexBundleSnapshots();
      }

      for (VersionedClause runBundle : model.getRunBundles()) {
       
        String bsn = runBundle.getName();
        if (bsn.endsWith(".jar")) {
          bsn = bsn.substring(0, bsn.indexOf(".jar"));
        }
        if (allowSnapshots && snapshots.containsKey(bsn)) {
          Jar jar = snapshots.get(bsn);
          jar.write(new File(outputDir, jar.getName() + "-" + jar.getVersion() + ".jar"));
        } else {
          Version version = null;
          File foundJar = null;

          for (RepositoryPlugin repo : repositories) {
            SortedSet<Version> versions = repo.versions(bsn);
            for (Version availableVersion : versions) {
              VersionRange range = null;
             
              if(runBundle.getVersionRange() != null &&  !runBundle.getVersionRange().equals(Constants.VERSION_ATTR_LATEST)) {
                range = new VersionRange(runBundle.getVersionRange());
              }
             
              boolean rangeMatches = range == null || range.includes(availableVersion);
              boolean availableMatches = version == null || availableVersion.compareTo(version) > 0;

              if (rangeMatches && availableMatches) {
                version = availableVersion;
                foundJar = repo.get(bsn, version, null);
              }
            }
          }

          if (foundJar != null) {
            File outputFile = new File(outputDir, foundJar.getName());
            FileChannel source = null;
            FileChannel destination = null;

            try {
              source = new FileInputStream(foundJar).getChannel();
              destination = new FileOutputStream(outputFile).getChannel();
              destination.transferFrom(source, 0, source.size());
            }
            finally {
              if (source != null) {
                source.close();
              }

              if (destination != null) {
                destination.close();
              }
            }
          } else {
            log(bsn + " could not be found in any repository");
          }
        }
      }

      bndProject.close();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    if (basedir == null)
      throw new BuildException("No basedir set");

    try {
      Project project = Workspace.getProject(basedir);
      project.setProperty("in.ant", "true");
      project.setProperty("environment", "ant");
      project.setExceptions(true);
      project.setTrace(trace);
      project.setPedantic(pedantic);
     
      project.action(command);

      if (report(project))
        throw new BuildException("Command " + command + " failed");
    } catch (Throwable e) {
      if (exceptions)
View Full Code Here

TOP

Related Classes of aQute.bnd.build.Project

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.