/**
   * Add all libraries that don't have the scope "provided" to the "Bundle-Classpath".
   *
   * @throws MojoExecutionException
   */
  protected String addBundleClasspathEntries() throws MojoExecutionException {
    StringBuffer bundleClasspathSb = new StringBuffer(ENTRY_BUNDLE_CLASSPATH);

    // local classes, if the plugin is jarred
    // @todo handle expanded plugins
    bundleClasspathSb.append(" .");

    for (int j = 0; j < config.getDeps().length; j++) {
      IdeDependency dep = config.getDeps()[j];
      if (!dep.isProvided() && !dep.isReferencedProject() && !dep.isTestDependency()) {
        bundleClasspathSb.append("," + NEWLINE);

        log.debug("Adding artifact to manifest: " + dep.getArtifactId());

        bundleClasspathSb.append(" " + dep.getFile().getName());
      }
    }
    // only insert the name of the property if there are local libraries
    return bundleClasspathSb.toString();
  }
예제 #2
0
  private void addDependency(Properties ajdtSettings, IdeDependency dep, String propName, int index)
      throws MojoExecutionException {

    String path;

    if (dep.isReferencedProject() && !config.isPde()) {
      path = "/" + dep.getEclipseProjectName(); // $NON-NLS-1$
    } else if (dep.isReferencedProject() && config.isPde()) {
      // don't do anything, referenced projects are automatically handled by eclipse in PDE builds
      return;
    } else {
      File artifactPath = dep.getFile();

      if (artifactPath == null) {
        log.error(
            Messages.getString("EclipsePlugin.artifactpathisnull", dep.getId())); // $NON-NLS-1$
        return;
      }

      if (dep.isSystemScoped()) {
        path =
            IdeUtils.toRelativeAndFixSeparator(
                config.getEclipseProjectDirectory(), artifactPath, false);

        if (log.isDebugEnabled()) {
          log.debug(
              Messages.getString(
                  "EclipsePlugin.artifactissystemscoped", //$NON-NLS-1$
                  new Object[] {dep.getArtifactId(), path}));
        }
      } else {
        File localRepositoryFile = new File(config.getLocalRepository().getBasedir());

        // if the dependency is not provided and the plugin runs in "pde mode", the dependency is
        // added to the Bundle-Classpath:
        if (config.isPde() && (dep.isProvided() || dep.isOsgiBundle())) {
          return;
        } else if (config.isPde() && !dep.isProvided() && !dep.isTestDependency()) {
          // path for link created in .project, not to the actual file
          path = dep.getFile().getName();
        }
        // running in PDE mode and the dependency is provided means, that it is provided by
        // the target platform. This case is covered by adding the plugin container
        else {
          String fullPath = artifactPath.getPath();
          String relativePath =
              IdeUtils.toRelativeAndFixSeparator(localRepositoryFile, new File(fullPath), false);

          if (!new File(relativePath).isAbsolute()) {
            path =
                EclipseClasspathWriter.M2_REPO
                    + "/" //$NON-NLS-1$
                    + relativePath;
          } else {
            path = relativePath;
          }
        }
      }
    }

    ajdtSettings.setProperty(AJDT_PROP_PREFIX + propName + CONTENT_KIND + index, BINARY);
    ajdtSettings.setProperty(AJDT_PROP_PREFIX + propName + ENTRY_KIND + index, LIBRARY);
    ajdtSettings.setProperty(AJDT_PROP_PREFIX + propName + index, path);
  }