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; }
public static File[] listNativeFiles( Artifact a, File unpackDirectory, final String ndkArchitecture, final boolean staticLibrary) { File libsFolder = new File( AbstractAndroidMojo.getLibraryUnpackDirectory(unpackDirectory, a), ApklibMojo.NATIVE_LIBRARIES_FOLDER + File.separator + ndkArchitecture); if (libsFolder.exists()) { File[] libFiles = libsFolder.listFiles( new FilenameFilter() { public boolean accept(final File dir, final String name) { return name.startsWith("lib") && name.endsWith((staticLibrary ? ".a" : ".so")); } }); return libFiles; } return null; }
/** * @param apkLibraryArtifact * @return */ protected String getLibraryUnpackDirectory(Artifact apkLibraryArtifact) { return AbstractAndroidMojo.getLibraryUnpackDirectory( unpackedApkLibsDirectory, apkLibraryArtifact); }
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; }
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; }