コード例 #1
0
 @SuppressWarnings("unchecked")
 private Set<Artifact> getAllArtifacts() throws MojoExecutionException {
   Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
   for (Dependency dep : (List<Dependency>) project.getDependencies()) {
     VersionRange versionRange;
     try {
       versionRange = VersionRange.createFromVersionSpec(dep.getVersion());
     } catch (InvalidVersionSpecificationException e) {
       throw new MojoExecutionException(
           String.format(
               "%1s: unable to parse version '%2s' for dependency '%3s': %4s",
               dep.getArtifactId(), dep.getVersion(), dep.getManagementKey(), e.getMessage()),
           e);
     }
     String type = dep.getType() == null ? "jar" : dep.getType();
     boolean optional = dep.isOptional();
     String scope = dep.getScope() == null ? Artifact.SCOPE_COMPILE : dep.getScope();
     Artifact artifact =
         artifactFactory.createDependencyArtifact(
             dep.getGroupId(),
             dep.getArtifactId(),
             versionRange,
             type,
             dep.getClassifier(),
             scope,
             optional);
     if (scope.equalsIgnoreCase(Artifact.SCOPE_SYSTEM)) {
       artifact.setFile(new File(dep.getSystemPath()));
     }
     handleExclusions(artifact, dep);
     artifacts.add(artifact);
   }
   return artifacts;
 }
コード例 #2
0
    private void addBundleListDependencies()
        throws IOException, XmlPullParserException, MojoExecutionException {
      BundleList bundleList;

      if (bundleListFile.exists()) {
        bundleList = readBundleList(bundleListFile);
      } else {
        bundleList = new BundleList();
      }

      if (additionalBundles != null) {
        for (ArtifactDefinition def : additionalBundles) {
          bundleList.add(def.toBundleList());
        }
      }

      interpolateProperties(bundleList, project, session);

      for (StartLevel startLevel : bundleList.getStartLevels()) {
        for (Bundle bundle : startLevel.getBundles()) {
          log.debug(
              String.format(
                  "adding bundle (%s) from bundle list to dependencies of project %s",
                  bundle, project));
          project.getDependencies().addAll(ArtifactDefinition.toDependencyList(bundle, PROVIDED));
        }
      }
    }
コード例 #3
0
ファイル: RunMojo.java プロジェクト: aaronwalker/camel
  // generic method to retrieve all the transitive dependencies
  private Collection<Artifact> getAllDependencies() throws MojoExecutionException {
    List<Artifact> artifacts = new ArrayList<Artifact>();

    for (Iterator<?> dependencies = project.getDependencies().iterator();
        dependencies.hasNext(); ) {
      Dependency dependency = (Dependency) dependencies.next();

      String groupId = dependency.getGroupId();
      String artifactId = dependency.getArtifactId();

      VersionRange versionRange;
      try {
        versionRange = VersionRange.createFromVersionSpec(dependency.getVersion());
      } catch (InvalidVersionSpecificationException e) {
        throw new MojoExecutionException("unable to parse version", e);
      }

      String type = dependency.getType();
      if (type == null) {
        type = "jar";
      }
      String classifier = dependency.getClassifier();
      boolean optional = dependency.isOptional();
      String scope = dependency.getScope();
      if (scope == null) {
        scope = Artifact.SCOPE_COMPILE;
      }

      Artifact art =
          this.artifactFactory.createDependencyArtifact(
              groupId, artifactId, versionRange, type, classifier, scope, null, optional);

      if (scope.equalsIgnoreCase(Artifact.SCOPE_SYSTEM)) {
        art.setFile(new File(dependency.getSystemPath()));
      }

      List<String> exclusions = new ArrayList<String>();
      for (Iterator<?> j = dependency.getExclusions().iterator(); j.hasNext(); ) {
        Exclusion e = (Exclusion) j.next();
        exclusions.add(e.getGroupId() + ":" + e.getArtifactId());
      }

      ArtifactFilter newFilter = new ExcludesArtifactFilter(exclusions);

      art.setDependencyFilter(newFilter);

      artifacts.add(art);
    }

    return artifacts;
  }
コード例 #4
0
ファイル: MSBuildMojo.java プロジェクト: akutz/nvn
  /**
   * Initializes the reference paths from the given project's dependencies.
   *
   * @param project The maven project.
   * @throws MojoExecutionException
   */
  @SuppressWarnings({"rawtypes", "unchecked"})
  void initReferencePaths(MavenProject project) throws MojoExecutionException {
    List deps = project.getDependencies();

    if (deps == null) {
      debug("not processing project dependencies because they're null: " + project.getName());
      return;
    }

    if (deps.size() == 0) {
      debug(
          "not processing project dependencies because they're zero length: " + project.getName());
      return;
    }

    if (this.referencePaths == null) {
      this.referencePaths = new ArrayList();
    }

    for (Object od : deps) {
      Dependency d = (Dependency) od;

      if (StringUtils.isEmpty(d.getType())) {
        continue;
      }

      if (!d.getType().matches("dll|exe")) {
        continue;
      }

      File file = DependencyUtils.getArtifactFile(super.factory, super.localRepository, d);

      if (file == null) {
        continue;
      }

      if (!this.referencePaths.contains(file.getParentFile())) {
        this.referencePaths.add(file.getParentFile());

        String assemblyName =
            DependencyUtils.getAssemblyName(
                super.factory,
                super.localRepository,
                super.mavenProject.getRemoteArtifactRepositories(),
                super.resolver,
                d);

        DependencyUtils.copyToAssemblyNamedFiles(file, assemblyName);
      }
    }
  }
コード例 #5
0
    void addDependencies() throws Exception {
      readConfiguration();

      addBundleListDependencies();

      if (hasPreparePackageExecution()) {
        if (includeDefaultBundles && !isCurrentArtifact(project, defaultBundleList)) {
          log.debug(
              String.format(
                  "adding default bundle list (%s) to dependencies of project %s",
                  defaultBundleList, project));
          project.getDependencies().addAll(defaultBundleList.toDependencyList(PROVIDED));
        }

        if (hasJarPackagingExecution()) {
          log.debug(
              String.format(
                  "adding jar web support (%s) to dependencies of project %s",
                  jarWebSupport, project));
          project.getDependencies().addAll(jarWebSupport.toDependencyList(PROVIDED));
        }
      }
    }
コード例 #6
0
  private Set<Artifact> collectAllProjectArtifacts() throws MojoExecutionException {
    final Set<Artifact> resolvedArtifacts = new HashSet<Artifact>();

    /*
     * Get the Grails dependencies from the plugin's POM file first.
     */
    final MavenProject pluginProject;
    try {
      pluginProject = getPluginProject();
    } catch (ProjectBuildingException e) {
      throw new MojoExecutionException("Unable to get plugin project", e);
    }

    /*
     * Add the plugin's dependencies and the project using the plugin's dependencies to the list
     * of unresolved dependencies.  This is done so they can all be resolved at the same time so
     * that we get the benefit of Maven's conflict resolution.
     */

    Set<Artifact> uncheckedArtifacts =
        useTransitives
            ? resolveFromTree()
            : getResolvedArtifactsFromUnresolvedDependencies(project.getDependencies(), false);
    Map<String, Artifact> checklist = new HashMap<String, Artifact>();

    for (Artifact artifact : uncheckedArtifacts) {
      //      resolvedArtifacts.add(artifact);
      checklist.put(artifactToKey(artifact), artifact);
      //      resolvedArtifacts.add(artifact);
    }

    // major breaking change, no dependencies from plugin
    /*
        for( Artifact artifact : getResolvedArtifactsFromUnresolvedDependencies(replaceVersion(filterGrailsDependencies(pluginProject.getDependencies())), true) ) {

    //      resolvedArtifacts.add(artifact);

          String key = artifactToKey(artifact);
          Artifact existing = checklist.get(key);

          if (existing == null)
            checklist.put(key, artifact);
        }
        */

    resolvedArtifacts.addAll(checklist.values());

    return resolvedArtifacts;
  }
コード例 #7
0
  public List<Dependency> getDependenciesForAllModules(MavenProject project)
      throws MojoFailureException {
    List<Dependency> ret = new ArrayList<Dependency>();

    ret.addAll(project.getDependencies());

    final List<String> modules = project.getModules();
    final List<String> moduleFullPaths = createFullPathsForModules(project, modules);
    for (String moduleFullPath : moduleFullPaths) {
      MavenProject moduleProject = getMavenProjectFromPath(moduleFullPath);
      ret.addAll(getDependenciesForAllModules(moduleProject));
    }

    return ret;
  }
コード例 #8
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;
  }
コード例 #9
0
  /**
   * Resolves dependencies of a bundle <code>groupId:artifactId:version</code>
   *
   * @param groupId
   * @param artifactId
   * @param version
   */
  @SuppressWarnings("unchecked")
  public ArtifactResolutionResult resolve(
      final String groupId, final String artifactId, final String version) {

    // final Artifact artifact = artifactFactory.createDependencyArtifact(groupId, artifactId,
    // VersionRange.createFromVersion(version), type, "", scope);
    final Artifact pomArtifact = getPomArtifact(groupId, artifactId, version);

    try {
      // load the pom as a MavenProject and get all of the dependencies for the project
      final MavenProject project = loadPomAsProject(projectBuilder, pomArtifact);
      final List dependencies = project.getDependencies();

      // make Artifacts of all the dependencies and the project itself
      final Set<Artifact> dependencyArtifacts =
          MavenMetadataSource.createArtifacts(artifactFactory, dependencies, null, null, null);
      dependencyArtifacts.add(project.getArtifact());

      // create listener for monitoring the resolution process
      final List<RuntimeResolutionListener> listeners = new ArrayList<RuntimeResolutionListener>();
      listeners.add(new RuntimeResolutionListener());

      // resolve all dependencies transitively to obtain a comprehensive list of jars
      final ArtifactResolutionResult result =
          artifactResolver.resolveTransitively(
              dependencyArtifacts,
              pomArtifact,
              Collections.EMPTY_MAP,
              localRepository,
              remoteRepositories,
              metadataSource,
              null,
              listeners);

      if (debug) {
        for (final Object o : result.getArtifactResolutionNodes()) {
          System.out.println(o.toString());
        }
      }

      return result;
    } catch (final Exception e) {
      throw new RuntimeException("Dependency Resolver failed", e);
    }
  }
コード例 #10
0
ファイル: RunMojo.java プロジェクト: aaronwalker/camel
  private Set<Artifact> resolveExecutableDependencies(Artifact executablePomArtifact)
      throws MojoExecutionException {

    Set<Artifact> executableDependencies;
    try {
      MavenProject executableProject =
          this.projectBuilder.buildFromRepository(
              executablePomArtifact, this.remoteRepositories, this.localRepository);

      // get all of the dependencies for the executable project
      List<Artifact> dependencies = CastUtils.cast(executableProject.getDependencies());

      // make Artifacts of all the dependencies
      Set<Artifact> dependencyArtifacts =
          CastUtils.cast(
              MavenMetadataSource.createArtifacts(
                  this.artifactFactory, dependencies, null, null, null));

      // not forgetting the Artifact of the project itself
      dependencyArtifacts.add(executableProject.getArtifact());

      // resolve all dependencies transitively to obtain a comprehensive
      // list of assemblies
      ArtifactResolutionResult result =
          artifactResolver.resolveTransitively(
              dependencyArtifacts,
              executablePomArtifact,
              Collections.EMPTY_MAP,
              this.localRepository,
              this.remoteRepositories,
              metadataSource,
              null,
              Collections.EMPTY_LIST);
      executableDependencies = CastUtils.cast(result.getArtifacts());

    } catch (Exception ex) {
      throw new MojoExecutionException(
          "Encountered problems resolving dependencies of the executable "
              + "in preparation for its execution.",
          ex);
    }

    return executableDependencies;
  }
コード例 #11
0
  public void execute(final Archiver archiver, final AssemblerConfigurationSource configSource)
      throws ArchiveCreationException, AssemblyFormattingException,
          InvalidAssemblerConfigurationException {
    if ((dependencySets == null) || dependencySets.isEmpty()) {
      logger.debug("No dependency sets specified.");
      return;
    }

    @SuppressWarnings("unchecked")
    final List<Dependency> deps = project.getDependencies();
    if ((deps == null) || deps.isEmpty()) {
      logger.debug(
          "Project " + project.getId() + " has no dependencies. Skipping dependency set addition.");
    }

    for (final Iterator<DependencySet> i = dependencySets.iterator(); i.hasNext(); ) {
      final DependencySet dependencySet = i.next();

      addDependencySet(dependencySet, archiver, configSource);
    }
  }
コード例 #12
0
  public List<Artifact> resolvePom(File pomFile) {
    if (pomFile == null) {
      throw new RuntimeException("pomFile is null");
    }

    MavenProject pom;
    try {
      PlexusContainer container = container();
      org.apache.maven.repository.RepositorySystem lrs =
          container.lookup(org.apache.maven.repository.RepositorySystem.class);
      ProjectBuilder projectBuilder = container.lookup(ProjectBuilder.class);
      ProjectBuildingRequest request = new DefaultProjectBuildingRequest();
      request.setRepositorySession(repositorySystemSession);
      request.setProcessPlugins(false);
      request.setLocalRepository(lrs.createDefaultLocalRepository());
      request.setRemoteRepositories(
          Arrays.asList(new ArtifactRepository[] {lrs.createDefaultRemoteRepository()}.clone()));
      ProjectBuildingResult result = projectBuilder.build(pomFile, request);
      pom = result.getProject();
    } catch (Exception e) {
      if (e instanceof RuntimeException) {
        throw (RuntimeException) e;
      }
      throw new RuntimeException("Error loading pom: " + pomFile.getAbsolutePath(), e);
    }

    Artifact rootArtifact =
        new DefaultArtifact(
            pom.getArtifact().getGroupId(),
            pom.getArtifact().getArtifactId(),
            pom.getArtifact().getClassifier(),
            pom.getArtifact().getType(),
            pom.getArtifact().getVersion(),
            null,
            new File(pom.getModel().getBuild().getOutputDirectory()));

    CollectRequest collectRequest = new CollectRequest();
    for (org.apache.maven.model.Dependency dependency : pom.getDependencies()) {
      collectRequest.addDependency(toAetherDependency(dependency));
    }
    for (RemoteRepository repository : pom.getRemoteProjectRepositories()) {
      collectRequest.addRepository(repository);
    }
    for (RemoteRepository repository : repositories) {
      collectRequest.addRepository(repository);
    }

    // Make sure we account for managed dependencies
    if (pom.getDependencyManagement() != null) {
      for (org.apache.maven.model.Dependency managedDependency :
          pom.getDependencyManagement().getDependencies()) {
        collectRequest.addManagedDependency(toAetherDependency(managedDependency));
      }
    }

    DependencyRequest dependencyRequest =
        new DependencyRequest(
            collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME));
    List<Artifact> artifacts = resolveArtifacts(dependencyRequest);
    return ImmutableList.<Artifact>builder().add(rootArtifact).addAll(artifacts).build();
  }
コード例 #13
0
  public Set<Artifact> getNativeDependenciesArtifacts(
      AbstractAndroidMojo mojo, File unpackDirectory, boolean sharedLibraries)
      throws MojoExecutionException {
    log.debug(
        "Finding native dependencies. UnpackFolder="
            + unpackDirectory
            + " shared="
            + sharedLibraries);
    final Set<Artifact> filteredArtifacts = new LinkedHashSet<Artifact>();
    final Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();

    // Add all dependent artifacts declared in the pom file
    // Note: The result of project.getDependencyArtifacts() can be an UnmodifiableSet so we
    //       have created our own above and add to that.
    allArtifacts.addAll(project.getDependencyArtifacts());

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

    // Add all transitive artifacts as well
    // this allows armeabi classifier -> apklib -> apklib -> apk chaining to only include armeabi in
    // APK
    allArtifacts.addAll(project.getArtifacts());

    for (Artifact artifact : allArtifacts) {
      log.debug("Checking artifact : " + artifact);
      // 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 + ". Artifact scope is not set.");
        filteredArtifacts.add(artifact);
      } else {
        if (isNativeLibrary(sharedLibraries, artifact.getType())
            && (Artifact.SCOPE_COMPILE.equals(artifact.getScope())
                || Artifact.SCOPE_RUNTIME.equals(artifact.getScope()))) {
          log.debug(
              "Including attached artifact: "
                  + artifact
                  + ". Artifact scope is Compile or Runtime.");
          filteredArtifacts.add(artifact);
        } else {
          final String type = artifact.getType();

          if (APKLIB.equals(type)) {
            // Check if the artifact contains a libs folder - if so, include it in the list
            File libsFolder = null;
            if (mojo != null) {
              libsFolder = mojo.getUnpackedLibNativesFolder(artifact);
            } else {
              // This is used from NativeHelperTest since we have no AbstractAndroidMojo there
              libsFolder =
                  new File(
                      AbstractAndroidMojo.getLibraryUnpackDirectory(unpackDirectory, artifact),
                      "libs");
            }

            if (!libsFolder.exists()) {
              log.debug("Skipping " + libsFolder.getAbsolutePath() + " for native artifacts");
              continue;
            }

            if (!libsFolder.isDirectory()) {
              continue;
            }

            log.debug("Checking " + libsFolder.getAbsolutePath() + " for native artifacts");
            // make sure we ignore libs folders that only contain JARs
            // The regular expression filters out all file paths ending with '.jar' or '.JAR',
            // so all native libs remain
            if (libsFolder.list(new PatternFilenameFilter("^.*(?<!(?i)\\.jar)$")).length > 0) {
              log.debug("Including attached artifact: " + artifact + ". Artifact is APKLIB.");
              filteredArtifacts.add(artifact);
            }
          } else if (!"jar".equals(type)) {
            log.debug("Not checking " + type + " for native artifacts");
          }
        }
      }
    }

    Set<Artifact> transitiveArtifacts =
        processTransitiveDependencies(project.getDependencies(), sharedLibraries);

    filteredArtifacts.addAll(transitiveArtifacts);

    return filteredArtifacts;
  }
コード例 #14
0
  public void execute() throws MojoExecutionException {
    // find all the rules items and load them into a package
    try {

      // Need to load the build classpath
      @SuppressWarnings("unchecked")
      List<Dependency> dependencies = project.getDependencies();
      List<URL> url = new ArrayList<URL>();
      url.add(outputDirectory.toURI().toURL());
      for (Dependency d : dependencies) {
        String scope = d.getScope();
        if (!Artifact.SCOPE_TEST.equals(scope)) {
          Artifact artifact =
              getArtifact(
                  d.getGroupId(),
                  d.getArtifactId(),
                  d.getVersion(),
                  d.getType(),
                  d.getClassifier());
          url.add(artifact.getFile().toURI().toURL());
        }
      }

      URL[] classpath = url.toArray(new URL[url.size()]);

      URLClassLoader uc =
          new URLClassLoader(classpath, this.getClass().getClassLoader()) {
            @Override
            public Class<?> loadClass(String name) throws ClassNotFoundException {
              getLog().debug("Loading Class for compile [" + name + "]");
              Class<?> c = super.loadClass(name);
              getLog().debug("Loading Class for compile [" + name + "] found [" + c + "]");
              return c;
            }

            @Override
            protected Class<?> findClass(String name) throws ClassNotFoundException {
              getLog().debug("Finding Class for compile [" + name + "]");
              Class<?> c = super.findClass(name);
              getLog().debug("Finding Class for compile [" + name + "] found [" + c + "]");
              return c;
            }
          };
      URLClassLoader uc2 =
          new URLClassLoader(classpath, this.getClass().getClassLoader()) {
            @Override
            public Class<?> loadClass(String name) throws ClassNotFoundException {
              getLog().debug("Loading Class for runtime [" + name + "]");
              Class<?> c = super.loadClass(name);
              getLog().debug("Loading Class for runtime [" + name + "] found [" + c + "]");
              return c;
            }

            @Override
            protected Class<?> findClass(String name) throws ClassNotFoundException {
              getLog().debug("Finding Class for runtime [" + name + "]");
              Class<?> c = super.findClass(name);
              getLog().debug("Finding Class for runtime [" + name + "] found [" + c + "]");
              return c;
            }
          };
      getLog().info("Package Class loader is using classpath " + Arrays.toString(uc.getURLs()));

      listClassloader("  ", uc);

      PackageBuilderConfiguration packageBuilderConfiguration = new PackageBuilderConfiguration(uc);
      PackageBuilder pb = new PackageBuilder(packageBuilderConfiguration);

      DirectoryScanner ds = new DirectoryScanner();
      ds.setIncludes(includes);
      ds.setExcludes(excludes);
      ds.setBasedir(rulesdir);
      ds.setCaseSensitive(true);
      ds.scan();

      String[] files = ds.getIncludedFiles();
      for (String file : files) {
        File f = new File(rulesdir, file);
        Reader reader = new FileReader(f);
        try {
          if (file.endsWith(".drl")) {
            getLog().info("Adding Rules " + f);
            pb.addPackageFromDrl(reader);
          } else if (file.endsWith(".xml")) {
            getLog().info("Adding Package definition " + f);
            pb.addPackageFromXml(reader);
          } else if (file.endsWith(".rf")) {
            getLog().info("Adding Rule Flow " + f);
            pb.addRuleFlow(reader);
          } else {
            getLog().info("Ignored Resource " + f);
          }

        } finally {
          reader.close();
        }
      }

      pb.compileAll();
      PackageBuilderErrors errors = pb.getErrors();
      if (errors.size() > 0) {
        for (KnowledgeBuilderError kberr : errors) {
          getLog().error(kberr.toString());
        }
        throw new MojoExecutionException("Package is not valid");
      }
      org.drools.rule.Package p = pb.getPackage();
      if (!p.isValid()) {
        getLog().error("Package is not valid ");
        throw new MojoExecutionException("Package is not valid");
      }

      File outputFile = getOutputFile();
      getLog().info("Saving compiled package to  " + outputFile.getPath());
      outputFile.getParentFile().mkdirs();
      FileOutputStream fout = new FileOutputStream(outputFile);
      DroolsStreamUtils.streamOut(fout, p);
      fout.close();

      getLog().info("Testing Compiled package " + outputFile.getPath());

      File inputFile = getOutputFile();
      FileInputStream fin = new FileInputStream(inputFile);

      RuleBaseConfiguration config = new RuleBaseConfiguration(uc2);
      RuleBase ruleBase = RuleBaseFactory.newRuleBase(config);
      Object o = DroolsStreamUtils.streamIn(fin, uc);

      ruleBase.addPackage((Package) o);
      KnowledgeBase kb = new KnowledgeBaseImpl(ruleBase);

      @SuppressWarnings("unused")
      StatelessKnowledgeSession session = kb.newStatelessKnowledgeSession();

      getLog().info("Testing passed ");

    } catch (Exception e) {
      getLog().error(e);
      throw new MojoExecutionException(e.getMessage());
    }
  }
コード例 #15
0
  public Set<Artifact> getNativeDependenciesArtifacts(File unpackDirectory, boolean sharedLibraries)
      throws MojoExecutionException {
    final Set<Artifact> filteredArtifacts = new LinkedHashSet<Artifact>();
    final Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();

    // Add all dependent artifacts declared in the pom file
    // Note: The result of project.getDependencyArtifacts() can be an UnmodifiableSet so we
    //       have created our own above and add to that.
    allArtifacts.addAll(project.getDependencyArtifacts());

    // Add all attached artifacts as well - this could come from the NDK mojo for example
    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()
                + "). Artifact scope is not set.");
        filteredArtifacts.add(artifact);
      } else {
        if (isNativeLibrary(sharedLibraries, artifact.getType())
            && (Artifact.SCOPE_COMPILE.equals(artifact.getScope())
                || Artifact.SCOPE_RUNTIME.equals(artifact.getScope()))) {
          log.debug(
              "Including attached artifact: "
                  + artifact.getArtifactId()
                  + "("
                  + artifact.getGroupId()
                  + "). Artifact scope is Compile or Runtime.");
          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");
            // make sure we ignore libs folders that only contain JARs
            // The regular expression filters out all file paths ending with '.jar' or '.JAR',
            // so all native libs remain
            if (libsFolder.exists()
                && libsFolder.list(new PatternFilenameFilter("^.*(?<!(?i)\\.jar)$")).length > 0) {
              log.debug(
                  "Including attached artifact: "
                      + artifact.getArtifactId()
                      + "("
                      + artifact.getGroupId()
                      + "). Artifact is APKLIB.");
              filteredArtifacts.add(artifact);
            }
          }
        }
      }
    }

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

    filteredArtifacts.addAll(transientArtifacts);

    return filteredArtifacts;
  }