/**
   * Set up the execution classpath for Jasper.
   *
   * <p>Put everything in the classesDirectory and all of the dependencies on the classpath.
   *
   * @returns a list of the urls of the dependencies
   * @throws Exception
   */
  private List<URL> setUpWebAppClassPath() throws Exception {
    // add any classes from the webapp
    List<URL> urls = new ArrayList<URL>();
    String classesDir = classesDirectory.getCanonicalPath();
    classesDir = classesDir + (classesDir.endsWith(File.pathSeparator) ? "" : File.separator);
    urls.add(Resource.toURL(new File(classesDir)));

    if (getLog().isDebugEnabled()) getLog().debug("Adding to classpath classes dir: " + classesDir);

    // add the dependencies of the webapp (which will form WEB-INF/lib)
    for (Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();

      // Include runtime and compile time libraries
      if (!Artifact.SCOPE_TEST.equals(artifact.getScope())
          && !Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
        String filePath = artifact.getFile().getCanonicalPath();
        if (getLog().isDebugEnabled())
          getLog().debug("Adding to classpath dependency file: " + filePath);

        urls.add(Resource.toURL(artifact.getFile()));
      }
    }
    return urls;
  }
  @Override
  protected List<File> getDependencies() {
    ArrayList<File> dependencies = new ArrayList<File>();

    @SuppressWarnings("unchecked")
    final Iterator<Artifact> it = project.getArtifacts().iterator();
    while (it.hasNext()) {
      final Artifact declared = it.next();
      this.log.debug("Checking artifact " + declared);
      if (this.isJavaArtifact(declared)) {
        if (Artifact.SCOPE_COMPILE.equals(declared.getScope())
            || Artifact.SCOPE_RUNTIME.equals(declared.getScope())
            || Artifact.SCOPE_PROVIDED.equals(declared.getScope())
            || Artifact.SCOPE_SYSTEM.equals(declared.getScope())) {
          this.log.debug("Resolving artifact " + declared);
          if (declared.getFile() != null) {
            dependencies.add(declared.getFile());
          } else {
            this.log.debug("Unable to resolve artifact " + declared);
          }
        } else {
          this.log.debug(
              "Artifact "
                  + declared
                  + " has not scope compile or runtime, but "
                  + declared.getScope());
        }
      } else {
        this.log.debug(
            "Artifact " + declared + " is not a java artifact, type is " + declared.getType());
      }
    }

    return dependencies;
  }
  private Collection<Artifact> getMostRecentArtifacts(Set<Artifact> artifacts) {
    Map<String, Artifact> artifactIdToArtifact = new HashMap<String, Artifact>();

    for (Artifact artifact : artifacts) {
      if (artifact.getScope() != null && artifact.getScope().contains("provide")) {
        continue;
      }

      String artifactId = artifact.getArtifactId();

      ArtifactVersion artifactVersion;

      try {
        artifactVersion = new DefaultArtifactVersion(artifact.getVersion());
      } catch (Exception e) {
        artifactVersion = null;
      }

      Artifact actualArtifactForId = artifactIdToArtifact.get(artifactId);
      ArtifactVersion actualArtifactVersion =
          (actualArtifactForId == null)
              ? null
              : new DefaultArtifactVersion(actualArtifactForId.getVersion());

      if (actualArtifactVersion == null) {
        artifactIdToArtifact.put(artifactId, artifact);
      } else {
        if (actualArtifactVersion.compareTo(artifactVersion) < 0) {
          artifactIdToArtifact.put(artifactId, artifact);
        }
      }
    }

    return artifactIdToArtifact.values();
  }
예제 #4
0
  /** @return */
  private List<File> getDependencyFiles() {
    List<File> dependencyFiles = new ArrayList<File>();
    for (Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();

      // Include runtime and compile time libraries, and possibly test libs too
      if (artifact.getType().equals("war")) {
        continue;
      }

      if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
        continue; // never add dependencies of scope=provided to the webapp's classpath (see also
                  // <useProvidedScope> param)

      if (Artifact.SCOPE_TEST.equals(artifact.getScope()) && !useTestScope)
        continue; // only add dependencies of scope=test if explicitly required

      dependencyFiles.add(artifact.getFile());
      getLog()
          .debug(
              "Adding artifact "
                  + artifact.getFile().getName()
                  + " with scope "
                  + artifact.getScope()
                  + " for WEB-INF/lib ");
    }

    return dependencyFiles;
  }
  /**
   * Get the classpath to use for running the fitnesse tests. The classpath is found using the
   * fitnesse <code>path</code> property or using Maven dependancies, according to the POM
   * configuration. The classpath is adapted to the local server configuration depending on the
   * local folders.
   *
   * @param tServer The FitNesse configuration.
   * @return The ClassPath to use.
   * @throws MojoExecutionException If the classpath can't be found.
   */
  private String getClassPath(Fitnesse tServer) throws MojoExecutionException {
    String tResult;
    if ("fitnesse".equals(classPathProvider)) {
      StringBuffer tBuffer = new StringBuffer();
      ClassPathBuilder tBuilder =
          new ClassPathBuilder(
              tServer.getHostName(), tServer.getPort(), tServer.getPageName(), getLog());
      tBuffer.append(tBuilder.getPath(classPathSubstitutions, getLog()));
      Artifact curArt;
      for (Iterator tIt = pluginArtifacts.iterator(); tIt.hasNext(); ) {
        curArt = (Artifact) tIt.next();
        if (!curArt.getScope().equals(Artifact.SCOPE_PROVIDED)
            && !curArt.getScope().equals(Artifact.SCOPE_TEST)) {
          tBuffer.append(File.pathSeparatorChar).append(curArt.getFile().getAbsolutePath());
        }
      }
      tBuffer.append(File.pathSeparatorChar).append(resolvePlugin().getFile().getAbsolutePath());
      getLog().info("Try to download classpath from FitNesse server...");
      tResult = tBuffer.toString();
    } else {
      tResult = getMavenClassPath();
    }
    if (copyDependencies) {
      tResult = copyDependenciesLocally(tResult);
    }

    return tResult;
  }
  private void addDependencies(final MavenProject project, final JettyWebAppContext webAppConfig)
      throws Exception {
    List<File> dependencyFiles = new ArrayList<File>();
    List<Resource> overlays = new ArrayList<Resource>();

    for (Artifact artifact : project.getArtifacts()) {
      if (artifact.getType().equals("war")) {
        overlays.add(Resource.newResource("jar:" + artifact.getFile().toURL().toString() + "!/"));
      } else if ((!Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
          && (!Artifact.SCOPE_TEST.equals(artifact.getScope()))) {
        File dependencyFile = artifact.getFile();

        if (dependencyFile == null || !dependencyFile.exists()) {
          String coordinates =
              String.format(
                  "%s:%s:%s",
                  artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());

          LOG.log(
              Level.WARNING,
              "Dependency '" + coordinates + "' does not exist in repository. Skipping!");
          continue;
        }

        dependencyFiles.add(artifact.getFile());
      }
    }

    webAppConfig.setOverlays(overlays);
    webAppConfig.setWebInfLib(dependencyFiles);
  }
예제 #7
0
  private Set<Artifact> getNativeDependenciesArtifacts() {
    Set<Artifact> filteredArtifacts = new HashSet<Artifact>();
    @SuppressWarnings("unchecked")
    final Set<Artifact> allArtifacts = project.getDependencyArtifacts();

    for (Artifact artifact : allArtifacts) {
      if ("so".equals(artifact.getType())
          && (Artifact.SCOPE_COMPILE.equals(artifact.getScope())
              || Artifact.SCOPE_RUNTIME.equals(artifact.getScope()))) {
        filteredArtifacts.add(artifact);
      }
    }

    return filteredArtifacts;
  }
 public boolean accept(Artifact artifact) {
   String scope = artifact.getScope();
   if (scope == null) {
     return matcher == SegmentMatch.ANY;
   }
   return matcher.match(scope);
 }
  /** @return */
  private List<File> getDependencyFiles() {
    List<File> dependencyFiles = new ArrayList<File>();

    for (Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();

      if (((!Artifact.SCOPE_PROVIDED.equals(artifact.getScope()))
              && (!Artifact.SCOPE_TEST.equals(artifact.getScope())))
          || (useTestScope && Artifact.SCOPE_TEST.equals(artifact.getScope()))) {
        dependencyFiles.add(artifact.getFile());
        getLog().debug("Adding artifact " + artifact.getFile().getName() + " for WEB-INF/lib ");
      }
    }

    return dependencyFiles;
  }
 private void checkRequiredApi() throws MojoExecutionException {
   Artifact api = getNullablePluginApiArtifact();
   if (api == null || !Artifact.SCOPE_PROVIDED.equals(api.getScope())) {
     throw new MojoExecutionException(
         SONAR_PLUGIN_API_ARTIFACTID + " must be declared in dependencies with scope <provided>");
   }
 }
예제 #11
0
  /** Finds and lists dependency plugins. */
  private String findDependencyPlugins() throws IOException, MojoExecutionException {
    StringBuilder buf = new StringBuilder();
    for (MavenArtifact a : getDirectDependencyArtfacts()) {
      if (a.isPlugin() && scopeFilter.include(a.artifact) && !a.hasSameGAAs(project)) {
        if (buf.length() > 0) buf.append(',');
        buf.append(a.getArtifactId());
        buf.append(':');
        buf.append(a.getVersion());
        if (a.isOptional()) {
          buf.append(";resolution:=optional");
        }
      }
    }

    // check any "provided" scope plugin dependencies that are probably not what the user intended.
    // see
    // http://www.nabble.com/Classloading-problem-when-referencing-classes-from-another-plugin-during-the-initialization-phase-of-a-plugin-%28ClassicPluginStrategy%29-td25426117.html
    for (Artifact a : (Collection<Artifact>) project.getDependencyArtifacts())
      if ("provided".equals(a.getScope()) && wrap(a).isPlugin())
        throw new MojoExecutionException(
            a.getId()
                + " is marked as 'provided' scope dependency, but it should be the 'compile' scope.");

    return buf.toString();
  }
예제 #12
0
  /**
   * @param artifactObj not null
   * @return the POM for the given artifact.
   * @throws MojoExecutionException if the artifact has a system scope.
   * @throws ProjectBuildingException when building pom.
   */
  private MavenProject getMavenProject(Artifact artifactObj)
      throws MojoExecutionException, ProjectBuildingException {
    if (Artifact.SCOPE_SYSTEM.equals(artifactObj.getScope())) {
      throw new MojoExecutionException("System artifact is not be handled.");
    }

    Artifact copyArtifact = ArtifactUtils.copyArtifact(artifactObj);
    if (!"pom".equals(copyArtifact.getType())) {
      copyArtifact =
          artifactFactory.createProjectArtifact(
              copyArtifact.getGroupId(), copyArtifact.getArtifactId(),
              copyArtifact.getVersion(), copyArtifact.getScope());
    }

    return mavenProjectBuilder.buildFromRepository(
        copyArtifact, remoteRepositories, localRepository);
  }
예제 #13
0
  private Set<Artifact> getNotProvidedDependencies() throws Exception {
    final Set<Artifact> result = new HashSet<Artifact>();
    for (final Artifact artifact : getIncludedArtifacts()) {
      if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope())
          || Artifact.SCOPE_TEST.equals(artifact.getScope())) {
        continue;
      }

      if (artifact.isOptional()) {
        continue;
      }

      result.add(artifact);
    }

    return result;
  }
예제 #14
0
  public Set<Artifact> getNativeDependenciesArtifacts(File unpackDirectory, boolean sharedLibraries)
      throws MojoExecutionException {
    final Set<Artifact> filteredArtifacts = new LinkedHashSet<Artifact>();

    // Add all dependent artifacts declared in the pom file
    @SuppressWarnings("unchecked")
    final Set<Artifact> allArtifacts = project.getDependencyArtifacts();

    // Add all attached artifacts as well - this could come from the NDK mojo for example
    boolean result = allArtifacts.addAll(project.getAttachedArtifacts());

    for (Artifact artifact : allArtifacts) {
      // A null value in the scope indicates that the artifact has been attached
      // as part of a previous build step (NDK mojo)
      if (isNativeLibrary(sharedLibraries, artifact.getType()) && artifact.getScope() == null) {
        // Including attached artifact
        log.debug(
            "Including attached artifact: "
                + artifact.getArtifactId()
                + "("
                + artifact.getGroupId()
                + ")");
        filteredArtifacts.add(artifact);
      } else if (isNativeLibrary(sharedLibraries, artifact.getType())
          && (Artifact.SCOPE_COMPILE.equals(artifact.getScope())
              || Artifact.SCOPE_RUNTIME.equals(artifact.getScope()))) {
        filteredArtifacts.add(artifact);
      } else if (APKLIB.equals(artifact.getType())) {
        // Check if the artifact contains a libs folder - if so, include it in the list
        File libsFolder =
            new File(
                AbstractAndroidMojo.getLibraryUnpackDirectory(unpackDirectory, artifact) + "/libs");
        if (libsFolder.exists()) {
          filteredArtifacts.add(artifact);
        }
      }
    }

    Set<Artifact> transientArtifacts =
        processTransientDependencies(project.getDependencies(), sharedLibraries);

    filteredArtifacts.addAll(transientArtifacts);

    return filteredArtifacts;
  }
예제 #15
0
 private void createFileSyncConfigs() throws Exception {
   createFileSyncConfig(project);
   for (MavenProject prj : projectReferences.values()) {
     Artifact artifact = projectReferenceArtifacts.get(prj);
     if (artifact == null || SCOPES.contains(artifact.getScope())) {
       createFileSyncConfig(prj);
     }
   }
 }
예제 #16
0
  public static boolean isIncluded(List<String> includeScopeList, Artifact artifact) {

    for (String scope : includeScopeList) {
      if (scope.equalsIgnoreCase(artifact.getScope())) {
        return true;
      }
    }

    return false;
  }
  private Set<Artifact> filterArtifacts(Set<Artifact> resolvedArtifacts, String... scopes) {
    HashSet<Artifact> artifacts = new HashSet<Artifact>();
    List<String> checkScopes = Arrays.asList(scopes);

    for (Artifact artifact : resolvedArtifacts) {
      if (checkScopes.contains(artifact.getScope())) artifacts.add(artifact);
    }

    return artifacts;
  }
 @SuppressWarnings("unchecked")
 public Set<Artifact> getProjectRuntimeArtifacts() {
   Set<Artifact> artifacts = new HashSet<Artifact>();
   for (Artifact projectArtifact : (Collection<Artifact>) project.getArtifacts()) {
     String scope = projectArtifact.getScope();
     if (SCOPE_RUNTIME.equals(scope) || SCOPE_COMPILE.equals(scope)) {
       artifacts.add(projectArtifact);
     }
   }
   return artifacts;
 }
예제 #19
0
 /**
  * Find unused artifacts.
  *
  * @param env Environment
  * @return Collection of unused artifacts
  */
 private static Collection<String> unused(final MavenEnvironment env) {
   final ProjectDependencyAnalysis analysis = DependenciesValidator.analyze(env);
   final Collection<String> unused = new LinkedList<String>();
   for (final Object obj : analysis.getUnusedDeclaredArtifacts()) {
     final Artifact artifact = (Artifact) obj;
     if (!artifact.getScope().equals(Artifact.SCOPE_COMPILE)) {
       continue;
     }
     unused.add(artifact.toString());
   }
   return unused;
 }
 /**
  * TODO remove ! Check that gwt-dev is not define in dependencies : this can produce version
  * conflicts with other dependencies, as gwt-dev is a "uber-jar" with some commons-* and jetty
  * libs inside.
  */
 private void checkGwtDevAsDependency() {
   for (Iterator iterator = getProject().getArtifacts().iterator(); iterator.hasNext(); ) {
     Artifact artifact = (Artifact) iterator.next();
     if (GWT_GROUP_ID.equals(artifact.getGroupId())
         && "gwt-dev".equals(artifact.getArtifactId())
         && !SCOPE_TEST.equals(artifact.getScope())) {
       getLog()
           .warn(
               "Don't declare gwt-dev as a project dependency. This may introduce complex dependency conflicts");
     }
   }
 }
예제 #21
0
  private Collection<Artifact> getAllNonTestScopedDependencies() throws MojoExecutionException {
    List<Artifact> answer = new ArrayList<Artifact>();

    for (Artifact artifact : getAllDependencies()) {

      // do not add test artifacts
      if (!artifact.getScope().equals(Artifact.SCOPE_TEST)) {
        answer.add(artifact);
      }
    }
    return answer;
  }
  protected List<IMavenProjectFacade> getWorkspaceDependencies(
      IProject project, MavenProject mavenProject) {
    Set<IProject> projects = new HashSet<IProject>();
    List<IMavenProjectFacade> dependencies = new ArrayList<IMavenProjectFacade>();
    Set<Artifact> artifacts = mavenProject.getArtifacts();
    for (Artifact artifact : artifacts) {
      IMavenProjectFacade dependency =
          projectManager.getMavenProject(
              artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());

      if ((Artifact.SCOPE_COMPILE.equals(artifact.getScope())
              || Artifact.SCOPE_RUNTIME.equals(
                  artifact.getScope())) // MNGECLIPSE-1578 Runtime dependencies should be deployed
          && dependency != null
          && !dependency.getProject().equals(project)
          && dependency.getFullPath(artifact.getFile()) != null
          && projects.add(dependency.getProject())) {
        dependencies.add(dependency);
      }
    }
    return dependencies;
  }
  private String buildCompileClasspath() {

    Set<String> pathElements = new HashSet<String>();
    if (pluginArtifacts != null) {
      for (Artifact a : pluginArtifacts) {
        if ("compile".equalsIgnoreCase(a.getScope()) || "runtime".equalsIgnoreCase(a.getScope())) {
          File f = a.getFile();
          if (f != null) {
            pathElements.add(a.getFile().getAbsolutePath());
          }
        }
      }
    }

    getClasspathElements(pathElements);
    StringBuilder result = new StringBuilder();

    for (String elem : pathElements) {
      result.append(elem).append(File.pathSeparator);
    }
    return result.toString();
  }
예제 #24
0
  public void testDependencyManagementOverridesTransitiveDependencyVersion() throws Exception {
    File localRepo = getLocalRepositoryPath();

    File pom0 = new File(localRepo, "p0/pom.xml");
    File pom0Basedir = pom0.getParentFile();
    File pom1 = new File(pom0Basedir, "p1/pom.xml");

    // load the child project, which inherits from p0...
    MavenProject project0 = getProjectWithDependencies(pom0);
    MavenProject project1 = getProjectWithDependencies(pom1);

    assertEquals(pom0Basedir, project1.getParent().getBasedir());
    System.out.println("Project " + project1.getId() + " " + project1);
    Map map = project1.getArtifactMap();
    assertNotNull("No artifacts", map);
    assertTrue("No Artifacts", map.size() > 0);
    assertTrue("Set size should be 3, is " + map.size(), map.size() == 3);

    Artifact a = (Artifact) map.get("maven-test:t10-a");
    Artifact b = (Artifact) map.get("maven-test:t10-b");
    Artifact c = (Artifact) map.get("maven-test:t10-c");

    assertNotNull(a);
    assertNotNull(b);
    assertNotNull(c);

    // inherited from depMgmt
    System.out.println(a.getScope());
    assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("test"));

    // transitive dep, overridden b depMgmt
    assertTrue(
        "Incorrect scope for " + b.getDependencyConflictId(), b.getScope().equals("runtime"));

    // direct dep, overrides depMgmt
    assertTrue(
        "Incorrect scope for " + c.getDependencyConflictId(), c.getScope().equals("runtime"));
  }
  /**
   * @param allArtifacts
   * @return
   */
  private Set<Artifact> filterOutIrrelevantArtifacts(Iterable<Artifact> allArtifacts) {
    final Set<Artifact> results = new LinkedHashSet<Artifact>();
    for (Artifact artifact : allArtifacts) {
      if (artifact == null) {
        continue;
      }

      if (EXCLUDED_DEPENDENCY_SCOPES.contains(artifact.getScope())) {
        continue;
      }

      if ("apk".equalsIgnoreCase(artifact.getType())) {
        continue;
      }

      results.add(artifact);
    }
    return results;
  }
  /**
   * @return
   * @throws MojoExecutionException
   */
  public List<String> getProvidedJars() throws MojoExecutionException {
    // if we are configured to include the provided dependencies on the plugin's classpath
    // (which mimics being on jetty's classpath vs being on the webapp's classpath), we first
    // try and filter out ones that will clash with jars that are plugin dependencies, then
    // create a new classloader that we setup in the parent chain.
    if (useProvidedScope) {

      List<String> provided = new ArrayList<String>();
      for (Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); ) {
        Artifact artifact = iter.next();
        if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !isPluginArtifact(artifact)) {
          provided.add(artifact.getFile().getAbsolutePath());
          if (getLog().isDebugEnabled()) {
            getLog().debug("Adding provided artifact: " + artifact);
          }
        }
      }
      return provided;

    } else return null;
  }
 protected List<String> getValuesToMatch(Artifact artifact) {
   List<String> valuesToMatch = new ArrayList<String>();
   File file = artifact.getFile();
   if (file == null) {
     if (artifact.isResolved()) {
       MavenClientFactory.getLog().warn("Artifact " + artifact + " doesn't contain a file");
     } else if (!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
       // ignore provided artifacts; raise a warning for non provided
       MavenClientFactory.getLog().warn("Artifact " + artifact + " unresolved");
     }
     return valuesToMatch;
   }
   // ignore non jar files
   if (!file.getName().endsWith(".jar")) {
     return valuesToMatch;
   }
   try {
     JarFile jarFile = new JarFile(file, true);
     Manifest mf = jarFile.getManifest();
     if (mf != null) {
       Attributes attributes = mf.getMainAttributes();
       if (attributes != null) {
         String bundleCategories = attributes.getValue(MANIFEST_BUNDLE_CATEGORY);
         if (bundleCategories != null) {
           StringTokenizer st =
               new StringTokenizer(bundleCategories, MANIFEST_BUNDLE_CATEGORY_TOKEN);
           while (st.hasMoreTokens()) {
             valuesToMatch.add(st.nextToken());
           }
         }
       }
     } else {
       MavenClientFactory.getLog().warn("Artifact " + artifact + " doesn't contain a manifest");
     }
   } catch (IOException e) {
     MavenClientFactory.getLog()
         .error("error while inspecting this jar manifest: " + artifact.getFile(), e);
   }
   return valuesToMatch;
 }
예제 #28
0
  private String setUpSysClassPath() throws Exception {
    StringBuffer buff = new StringBuffer();

    // Put each of the plugin's artifacts onto the system classpath for jspc
    for (Iterator<Artifact> iter = pluginArtifacts.iterator(); iter.hasNext(); ) {
      Artifact pluginArtifact = iter.next();
      if ("jar".equalsIgnoreCase(pluginArtifact.getType())) {
        if (getLog().isDebugEnabled()) {
          getLog().debug("Adding plugin artifact " + pluginArtifact);
        }
        buff.append(pluginArtifact.getFile().getAbsolutePath());
        if (iter.hasNext()) buff.append(File.pathSeparator);
      }
    }

    if (useProvidedScope) {
      for (Iterator<Artifact> iter = projectArtifacts.iterator(); iter.hasNext(); ) {
        Artifact artifact = iter.next();
        if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
          // test to see if the provided artifact was amongst the plugin artifacts
          String path = artifact.getFile().getAbsolutePath();
          if (!buff.toString().contains(path)) {
            if (buff.length() != 0) buff.append(File.pathSeparator);
            buff.append(path);
            if (getLog().isDebugEnabled()) {
              getLog().debug("Adding provided artifact: " + artifact);
            }
          } else {
            if (getLog().isDebugEnabled()) {
              getLog().debug("Skipping provided artifact: " + artifact);
            }
          }
        }
      }
    }

    return buff.toString();
  }
예제 #29
0
  private void addDependencies(Archiver archiver) throws ArchiverException, MojoExecutionException {

    Log log = getLog();
    AndArtifactFilter filter = new AndArtifactFilter();
    filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
    filter.add(
        new ArtifactFilter() {
          public boolean include(Artifact artifact) {
            return !artifact.isOptional();
          }
        });
    filter.add(new TypeArtifactFilter("jar"));
    filter.add(buildSynapseRuntimeArtifactFilter());
    for (Artifact artifact : filterArtifacts((Set<Artifact>) project.getArtifacts(), filter)) {
      String targetFileName =
          artifact.getArtifactId()
              + "-"
              + artifact.getVersion()
              + "."
              + artifact.getArtifactHandler().getExtension();
      log.info("Adding " + targetFileName + " (scope " + artifact.getScope() + ")");
      archiver.addFile(artifact.getFile(), "lib/" + targetFileName);
    }
  }
예제 #30
0
 private boolean isLib(Artifact artifact) {
   return artifact.isResolved()
       && SCOPES.contains(artifact.getScope())
       && "jar".equals(artifact.getType())
       && projectReferences.get(getProjectReferenceId(artifact)) == null;
 }