コード例 #1
0
  /**
   * Utility method that locates a project producing the given artifact.
   *
   * @param artifact the artifact a project should produce.
   * @return <code>true</code> if the artifact is produced by a reactor projectart.
   */
  protected boolean isAvailableAsAReactorProject(Artifact artifact) {
    if (this.reactorProjects != null
        && (Constants.PROJECT_PACKAGING_JAR.equals(artifact.getType())
            || Constants.PROJECT_PACKAGING_EJB.equals(artifact.getType())
            || Constants.PROJECT_PACKAGING_WAR.equals(artifact.getType()))) {
      for (Object reactorProject1 : this.reactorProjects) {
        MavenProject reactorProject = (MavenProject) reactorProject1;

        if (reactorProject.getGroupId().equals(artifact.getGroupId())
            && reactorProject.getArtifactId().equals(artifact.getArtifactId())) {
          if (reactorProject.getVersion().equals(artifact.getVersion())) {
            return true;
          } else {
            getLog()
                .info(
                    "Artifact "
                        + artifact.getId()
                        + " already available as a reactor project, but with different version. "
                        + "Expected: "
                        + artifact.getVersion()
                        + ", found: "
                        + reactorProject.getVersion());
          }
        }
      }
    }
    return false;
  }
コード例 #2
0
 /** Check if the artifact is a java artifact (jar or bundle) */
 private boolean isJavaArtifact(Artifact artifact) {
   if ("jar".equals(artifact.getType())) {
     return true;
   }
   if ("bundle".equals(artifact.getType())) {
     return true;
   }
   return false;
 }
コード例 #3
0
 private void addLibraryResourceFolders(List<String> commands) {
   for (Artifact artifact : getTransitiveDependencyArtifacts()) {
     getLog().debug("Considering dep artifact : " + artifact);
     if (artifact.getType().equals(APKLIB) || artifact.getType().equals(AAR)) {
       final File apklibResDirectory = getUnpackedLibResourceFolder(artifact);
       if (apklibResDirectory.exists()) {
         getLog().debug("Adding apklib or aar resource folder : " + apklibResDirectory);
         commands.add("-S");
         commands.add(apklibResDirectory.getAbsolutePath());
       }
     }
   }
 }
コード例 #4
0
  /**
   * @return
   * @throws Exception
   */
  public String getClassPath() throws Exception {
    StringBuilder classPath = new StringBuilder();
    for (Object obj : pluginArtifacts) {
      Artifact artifact = (Artifact) obj;
      if ("jar".equals(artifact.getType())) {
        if (classPath.length() > 0) {
          classPath.append(File.pathSeparator);
        }
        classPath.append(artifact.getFile().getAbsolutePath());
      }
    }

    // Any jars that we need from the plugin environment (like the ones containing Starter class)
    Set<Artifact> extraJars = getExtraJars();
    for (Artifact a : extraJars) {
      classPath.append(File.pathSeparator);
      classPath.append(a.getFile().getAbsolutePath());
    }

    // Any jars that we need from the project's dependencies because we're useProvided
    List<String> providedJars = getProvidedJars();
    if (providedJars != null && !providedJars.isEmpty()) {
      for (String jar : providedJars) {
        classPath.append(File.pathSeparator);
        classPath.append(jar);
        if (getLog().isDebugEnabled()) getLog().debug("Adding provided jar: " + jar);
      }
    }

    return classPath.toString();
  }
コード例 #5
0
 public static boolean hasStaticNativeLibraryArtifact(
     Set<Artifact> resolveNativeLibraryArtifacts, File unpackDirectory, String ndkArchitecture) {
   for (Artifact resolveNativeLibraryArtifact : resolveNativeLibraryArtifacts) {
     if ("a".equals(resolveNativeLibraryArtifact.getType())) {
       return true;
     }
     if (APKLIB.equals(resolveNativeLibraryArtifact.getType())) {
       File[] aFiles =
           listNativeFiles(resolveNativeLibraryArtifact, unpackDirectory, ndkArchitecture, true);
       if (aFiles != null && aFiles.length > 0) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #6
0
 public static boolean hasSharedNativeLibraryArtifact(
     Set<Artifact> resolveNativeLibraryArtifacts, File unpackDirectory, String ndkArchitecture) {
   for (Artifact resolveNativeLibraryArtifact : resolveNativeLibraryArtifacts) {
     if (Const.ArtifactType.NATIVE_SYMBOL_OBJECT.equals(resolveNativeLibraryArtifact.getType())) {
       return true;
     }
     if (APKLIB.equals(resolveNativeLibraryArtifact.getType())) {
       File[] soFiles =
           listNativeFiles(resolveNativeLibraryArtifact, unpackDirectory, ndkArchitecture, false);
       if (soFiles != null && soFiles.length > 0) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #7
0
  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);
  }
コード例 #8
0
  /**
   * Log Projects and their resolved dependencies via MavenProject.getArtifacts().
   *
   * @param reactorProjects MavenProjects in the current reactor
   */
  private void checkReactor(final List<MavenProject> reactorProjects) {
    for (final MavenProject reactorProject : reactorProjects) {
      final String msg =
          "Check resolved Artifacts for: "
              + "\ngroudId:    "
              + reactorProject.getGroupId()
              + "\nartifactId: "
              + reactorProject.getArtifactId()
              + "\nversion:    "
              + reactorProject.getVersion();
      if (getLog().isDebugEnabled()) getLog().debug(msg);

      if (reactorProject.getArtifacts() == null || reactorProject.getArtifacts().isEmpty()) {
        if (getLog().isDebugEnabled())
          getLog().debug("+  Dependencies not resolved or Reactor-Project has no dependencies!");
      } else {
        for (final Artifact artifact : reactorProject.getArtifacts()) {
          if (getLog().isDebugEnabled())
            getLog()
                .debug(
                    "  + "
                        + artifact.getGroupId()
                        + " : "
                        + artifact.getArtifactId()
                        + " : "
                        + artifact.getVersion()
                        + " : "
                        + artifact.getType()
                        + " : "
                        + artifact.getFile());
        }
      }
    }
  }
コード例 #9
0
  /**
   * Merge WsdlOptions that point to the same file by adding the extraargs to the first option and
   * deleting the second from the options list
   *
   * @param options
   */
  @SuppressWarnings("unchecked")
  private Artifact resolveRemoteWsdlArtifact(List<?> remoteRepos, Artifact artifact)
      throws MojoExecutionException {

    /**
     * First try to find the artifact in the reactor projects of the maven session. So an artifact
     * that is not yet built can be resolved
     */
    List<MavenProject> rProjects = mavenSession.getSortedProjects();
    for (MavenProject rProject : rProjects) {
      if (artifact.getGroupId().equals(rProject.getGroupId())
          && artifact.getArtifactId().equals(rProject.getArtifactId())
          && artifact.getVersion().equals(rProject.getVersion())) {
        Set<Artifact> artifacts = rProject.getArtifacts();
        for (Artifact pArtifact : artifacts) {
          if ("wadl".equals(pArtifact.getType())) {
            return pArtifact;
          }
        }
      }
    }

    /** If this did not work resolve the artifact using the artifactResolver */
    try {
      artifactResolver.resolve(artifact, remoteRepos, localRepository);
    } catch (ArtifactResolutionException e) {
      throw new MojoExecutionException("Error downloading wsdl artifact.", e);
    } catch (ArtifactNotFoundException e) {
      throw new MojoExecutionException("Resource can not be found.", e);
    }

    return artifact;
  }
コード例 #10
0
  @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;
  }
コード例 #11
0
  private boolean match(Dependency dependency, Artifact artifact) {
    boolean match =
        dependency.getGroupId().equals(artifact.getGroupId())
            && dependency.getArtifactId().equals(artifact.getArtifactId())
            && dependency.getVersion().equals(artifact.getVersion());

    if (match) {
      if (dependency.getClassifier() == null) {
        match = artifact.getClassifier() == null;
      } else {
        match = dependency.getClassifier().equals(artifact.getClassifier());
      }
    }

    if (match) {
      String type = artifact.getType();
      if (dependency.getType() == null) {
        match = type == null || type.equals("jar");
      } else {
        match = dependency.getType().equals(type);
      }
    }

    return match;
  }
コード例 #12
0
  private List<ResourceDirectory> arrangeAsDependency(
      File overlayDirectory, File[] artifactIdDirs) {
    Set dependencyArtifacts = getMavenProject().getDependencyArtifacts();
    final Iterator it = dependencyArtifacts.iterator();

    final List<ResourceDirectory> result = new ArrayList<ResourceDirectory>();
    while (it.hasNext()) {
      ResourceDirectory resourceDirectory = null;
      Artifact artifact = (Artifact) it.next();
      if ("js".equals(artifact.getType())) {
        File resource = getJsArtifactAsResource(overlayDirectory, artifact);
        resourceDirectory =
            new ResourceDirectory(
                resource, ResourceDirectory.DEFAULT_INCLUDES, ResourceDirectory.DEFAULT_EXCLUDES);
      } else {
        resourceDirectory = getArtifactAsResource(artifact, artifactIdDirs);
      }

      if (resourceDirectory != null) {
        result.add(resourceDirectory);
      }
    }

    return result;
  }
コード例 #13
0
  // used by "initialize", "dist" and "war" mojos
  protected Artifact findFrameworkArtifact(boolean minVersionWins) {
    Artifact result = null;

    Set<?> artifacts = project.getArtifacts();
    for (Iterator<?> iter = artifacts.iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();
      if ("zip".equals(artifact.getType())) {
        if ("framework".equals(artifact.getClassifier())) {
          result = artifact;
          if (!minVersionWins) {
            break;
          }
          // System.out.println( "added framework: " + artifact.getGroupId() + ":" +
          // artifact.getArtifactId()
          // );
          // don't break, maybe there is "framework-min" artifact too
        }
        // "module-min" overrides "module" (if present)
        else if ("framework-min".equals(artifact.getClassifier())) {
          result = artifact;
          // System.out.println( "added framework-min: " + artifact.getGroupId() + ":"
          // + artifact.getArtifactId() );
          if (minVersionWins) {
            break;
          }
        }
      }
    }
    return result;
  }
コード例 #14
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;
  }
コード例 #15
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;
  }
コード例 #16
0
 @Before
 public void setUp() {
   artifact = Mockito.mock(Artifact.class);
   Mockito.when(artifact.getArtifactId()).thenReturn(ArtifactConstants.ARTIFACTID);
   Mockito.when(artifact.getGroupId()).thenReturn(ArtifactConstants.GROUPID);
   Mockito.when(artifact.getVersion()).thenReturn(ArtifactConstants.VERSION);
   Mockito.when(artifact.getClassifier()).thenReturn(ArtifactConstants.CLASSIFIER);
   Mockito.when(artifact.getType()).thenReturn(ArtifactConstants.JAR_TYPE);
 }
コード例 #17
0
 public static boolean hasSharedNativeLibraryArtifact(
     Set<Artifact> resolveNativeLibraryArtifacts) {
   for (Artifact resolveNativeLibraryArtifact : resolveNativeLibraryArtifacts) {
     if ("so".equals(resolveNativeLibraryArtifact.getType())) {
       return true;
     }
   }
   return false;
 }
コード例 #18
0
  /**
   * @return
   * @throws MalformedURLException
   * @throws IOException
   */
  private List<Artifact> getWarArtifacts() throws MalformedURLException, IOException {
    List<Artifact> warArtifacts = new ArrayList<Artifact>();
    for (Iterator<Artifact> iter = project.getArtifacts().iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();

      if (artifact.getType().equals("war")) warArtifacts.add(artifact);
    }

    return warArtifacts;
  }
コード例 #19
0
  /**
   * Removes any Grails plugin artifacts from the supplied list of dependencies. A Grails plugin is
   * any artifact whose type is equal to "grails-plugin" or "zip"
   *
   * @param artifact The list of artifacts to be cleansed.
   * @return list of plugins
   */
  private Set<Artifact> removePluginArtifacts(final Set<Artifact> artifact) {
    final Set<Artifact> pluginArtifacts = new HashSet<Artifact>();

    if (artifact != null) {
      for (final Iterator<Artifact> iter = artifact.iterator(); iter.hasNext(); ) {
        final Artifact dep = iter.next();
        if (dep.getType() != null
            && (dep.getType().equals("grails-plugin")
                || dep.getType().equals("zip")
                || (dep.getType().equals("grails-plugin2")
                    && "plugin".equals(dep.getClassifier())))) {
          pluginArtifacts.add(dep);
          //          System.out.println("removing " + dep.toString());
          iter.remove();
        }
      }
    }

    return pluginArtifacts;
  }
コード例 #20
0
  private Artifact setupMaven() throws MojoExecutionException, MojoFailureException {
    if (mavenArtifact == null) {
      mavenArtifact = new MavenArtifact("org.apache.maven", "apache-maven", "bin", "tar.gz");
    }
    Artifact artifact = getMavenArtifact(mavenArtifact);

    if (!this.markerExist("maven")) {
      unpack(artifact.getFile(), mavenLocation, artifact.getType());
      this.createMarkerFile("maven");
    }

    return artifact;
  }
コード例 #21
0
ファイル: RunMojo.java プロジェクト: jmesnil/wildfly-swarm
  Path findBootstrap() throws MojoFailureException {

    Set<Artifact> artifacts = this.project.getArtifacts();

    for (Artifact each : artifacts) {
      if (each.getGroupId().equals("org.wildfly.swarm")
          && each.getArtifactId().equals("wildfly-swarm-bootstrap")
          && each.getType().equals("jar")) {
        return each.getFile().toPath();
      }
    }

    return null;
  }
コード例 #22
0
  private MavenProject buildProjectStub(final Artifact depArtifact) {
    final Model model = new Model();
    model.setGroupId(depArtifact.getGroupId());
    model.setArtifactId(depArtifact.getArtifactId());
    model.setVersion(depArtifact.getBaseVersion());
    model.setPackaging(depArtifact.getType());

    model.setDescription("Stub for " + depArtifact.getId());

    final MavenProject project = new MavenProject(model);
    project.setArtifact(depArtifact);

    return project;
  }
コード例 #23
0
  /**
   * Returns the ejb file type from the artifact list
   *
   * @param inArtifacts - the dependency artifacts
   * @return the File object corresponding to the ejb jar type from the artifact list
   */
  public static File getEjbJarFileName(final Set inArtifacts) {
    if (inArtifacts == null || inArtifacts.isEmpty()) {
      throw new IllegalArgumentException("EJB jar not found in artifact list.");
    }

    final Iterator iter = inArtifacts.iterator();
    while (iter.hasNext()) {
      Artifact artifact = (Artifact) iter.next();
      if ("ejb".equals(artifact.getType())) {
        return artifact.getFile();
      }
    }
    throw new IllegalArgumentException("EJB jar not found in artifact list.");
  }
コード例 #24
0
  protected Map<String, Artifact> findAllModuleArtifacts(boolean minVersionWins) {
    Map<String, Artifact> result = new HashMap<String, Artifact>();

    Set<?> artifacts = project.getArtifacts();
    for (Iterator<?> iter = artifacts.iterator(); iter.hasNext(); ) {
      Artifact artifact = (Artifact) iter.next();
      if ("zip".equals(artifact.getType())) {
        if ("module".equals(artifact.getClassifier())
            || "module-min".equals(artifact.getClassifier())) {
          String moduleName = artifact.getArtifactId();
          if (moduleName.startsWith("play-")) {
            moduleName = moduleName.substring("play-".length());
          }

          if ("module".equals(artifact.getClassifier())) {
            if (!minVersionWins || result.get(moduleName) == null) {
              result.put(moduleName, artifact);
              // System.out.println("added module: " + artifact.getGroupId() + ":" +
              // artifact.getArtifactId());
            }
          } else
          // "module-min"
          {
            if (minVersionWins || result.get(moduleName) == null) {
              result.put(moduleName, artifact);
              // System.out.println("added module-min: " + artifact.getGroupId() + ":" +
              // artifact.getArtifactId());
            }
          }
        }
      } else if ("play".equals(artifact.getType())) {
        String moduleName = artifact.getArtifactId();
        result.put(moduleName, artifact);
      }
    }
    return result;
  }
コード例 #25
0
  /**
   * Returns the fully qualified path to an war file in the artifact list.
   *
   * @param inArtifacts - the set of artifacts
   * @param fileName - the file name we are looking for in the aftifact list
   * @return the fully qualified path to an war file in the artifact list.
   */
  public static File getWarFileName(final Set inArtifacts, String fileName) {
    if (inArtifacts == null || inArtifacts.isEmpty()) {
      throw new IllegalArgumentException("WAR not found in artifact list.");
    }

    final Iterator iter = inArtifacts.iterator();
    while (iter.hasNext()) {
      Artifact artifact = (Artifact) iter.next();

      if ("war".equals(artifact.getType()) && artifact.getFile().getName().contains(fileName)) {
        return artifact.getFile();
      }
    }
    throw new IllegalArgumentException("WAR not found in artifact list.");
  }
コード例 #26
0
ファイル: ExecuteMojo.java プロジェクト: kurtharriger/gmaven
  /**
   * Allow the script to work with every JAR dependency of both the project and plugin, including
   * optional and provided dependencies. Runtime classpath elements are loaded first, so that legacy
   * behavior is not modified. Additional elements are added first in the order of project
   * artifacts, then in the order of plugin artifacts.
   */
  protected List getProjectClasspathElements() throws DependencyResolutionRequiredException {
    Set results = new LinkedHashSet();

    for (Iterator i = project.getRuntimeClasspathElements().iterator(); i.hasNext(); ) {
      String cpe = (String) i.next();
      try {
        results.add(new File(cpe).getCanonicalPath());
      } catch (IOException e) {
        throw new RuntimeException("Classpath element not found: " + cpe, e);
      }
    }

    for (Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) {
      Artifact artifact = (Artifact) i.next();
      if (artifact.getType().equals("jar") && artifact.getClassifier() == null) {
        try {
          results.add(artifact.getFile().getCanonicalPath());
        } catch (IOException e) {
          throw new RuntimeException("Maven artifact file not found: " + artifact.toString(), e);
        }
      }
    }

    for (Iterator i = pluginArtifacts.iterator(); i.hasNext(); ) {
      Artifact artifact = (Artifact) i.next();
      if (artifact.getType().equals("jar") && artifact.getClassifier() == null) {
        try {
          results.add(artifact.getFile().getCanonicalPath());
        } catch (IOException e) {
          throw new RuntimeException(
              "Maven plugin-artifact file not found: " + artifact.toString(), e);
        }
      }
    }
    return new ArrayList(results);
  }
コード例 #27
0
ファイル: CreateBranchMojo.java プロジェクト: jensaug/fabric8
 /** unzips any dependent zips into the git directory */
 protected void addProfileZips() throws MojoExecutionException, IOException, GitAPIException {
   Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();
   for (Artifact artifact : dependencyArtifacts) {
     if ("zip".equals(artifact.getType())) {
       File file = artifact.getFile();
       if (file != null) {
         getLog().info("Unzipping file: " + file);
         addZipFile(file);
       } else {
         getLog().warn("Could not resolve file for " + artifact);
       }
     }
   }
   git.add().addFilepattern("fabric").call();
 }
コード例 #28
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;
  }
コード例 #29
0
  private void copyExtraResources() throws MojoExecutionException, MojoFailureException {
    for (MavenArtifact extraResource : getExtraResourcesArtifacts()) {
      Artifact artifact = getMavenArtifact(extraResource);

      File dest;
      if (extraResource.getOutputDirectory() != null) {
        dest = extraResource.getOutputDirectory();
      } else if (extraResource.getOutputProperty() != null) {
        dest = new File(project.getProperties().getProperty(extraResource.getOutputProperty()));
      } else {
        dest = resourcesDestinationLocation;
      }
      unpack(artifact.getFile(), dest, artifact.getType());
    }
  }
コード例 #30
0
 /**
  * @throws MojoExecutionException
  * @throws MojoFailureException
  */
 protected void deployDependencies() throws MojoExecutionException, MojoFailureException {
   Set<Artifact> directDependentArtifacts = project.getDependencyArtifacts();
   if (directDependentArtifacts != null) {
     for (Artifact artifact : directDependentArtifacts) {
       String type = artifact.getType();
       if (type.equals(APK)) {
         getLog()
             .debug(
                 "Detected apk dependency " + artifact + ". Will resolve and deploy to device...");
         final File targetApkFile = resolveArtifactToFile(artifact);
         getLog().debug("Deploying " + targetApkFile + " to device...");
         deployApk(targetApkFile);
       }
     }
   }
 }