use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.
the class CopyAwoSolibTask method doFullTaskAction.
@TaskAction
public void doFullTaskAction() {
if (!outputDir.exists()) {
outputDir.mkdirs();
}
Set<String> removeSoFiles = new HashSet<String>();
Set<String> supportAbis = new HashSet<String>();
//为了兼容之前老的aar,awb格式
File libJniFolder = new File(awbBundle.getFolder(), "libs");
if (libJniFolder.exists() && libJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
File libJniFolder2 = new File(awbBundle.getFolder(), "jni");
if (libJniFolder2.exists() && libJniFolder2.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder2, outputDir, supportAbis, removeSoFiles, getILogger());
}
File libJniFolder3 = new File(awbBundle.getFolder(), "jniLibs");
if (libJniFolder3.exists() && libJniFolder3.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(libJniFolder3, outputDir, supportAbis, removeSoFiles, getILogger());
}
List<? extends AndroidLibrary> deps = awbBundle.getLibraryDependencies();
for (AndroidLibrary dep : deps) {
File depJniFolder = dep.getJniFolder();
if (depJniFolder.exists() && depJniFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(depJniFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
//为了兼容之前老的aar,awb格式
File depLibsFolder = new File(dep.getFolder(), "libs");
if (depLibsFolder.exists() && depLibsFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(depLibsFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
}
List<SoLibrary> solibs = awbBundle.getSoLibraries();
if (null != solibs) {
for (SoLibrary solib : solibs) {
File explodeFolder = solib.getFolder();
if (!explodeFolder.exists()) {
LibraryCache.unzipAar(solib.getSoLibFile(), explodeFolder, getProject());
}
if (explodeFolder.exists() && explodeFolder.isDirectory()) {
NativeSoUtils.copyLocalNativeLibraries(explodeFolder, outputDir, supportAbis, removeSoFiles, getILogger());
}
}
}
}
use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.
the class DiffDependencyTask method doTask.
@TaskAction
public void doTask() throws IOException {
apDependenciesFile = getApDependenciesFile();
diffOutFile = getDiffOutFile();
DependencyJson apDependencyJson = JSON.parseObject(FileUtils.readFileToString(apDependenciesFile), DependencyJson.class);
Set<String> apMainDependencies = Sets.newHashSet();
for (String mainDep : apDependencyJson.getMainDex()) {
String name = mainDep.substring(0, mainDep.lastIndexOf(":"));
apMainDependencies.add(name);
}
AwbBundle awbBundle = libVariantContext.getAwbBundle();
//aars
if (null != awbBundle.getLibraryDependencies()) {
for (int index = 0; index < awbBundle.getLibraryDependencies().size(); index++) {
AndroidLibrary libraryDependency = awbBundle.getLibraryDependencies().get(index);
MavenCoordinates mavenCoordinates = libraryDependency.getResolvedCoordinates();
String name = getMavenName(mavenCoordinates);
if (apMainDependencies.contains(name)) {
getLogger().info("[Remove]" + name);
awbBundle.getLibraryDependencies().remove(index);
} else {
inAwbDependencies.add(name);
}
}
}
//solibs
if (null != awbBundle.getSoLibraries()) {
for (int index = 0; index < awbBundle.getSoLibraries().size(); index++) {
SoLibrary soLibrary = awbBundle.getSoLibraries().get(index);
MavenCoordinates mavenCoordinates = soLibrary.getResolvedCoordinates();
String name = getMavenName(mavenCoordinates);
if (apMainDependencies.contains(name)) {
getLogger().info("[Remove]" + name);
awbBundle.getSoLibraries().remove(index);
} else {
inAwbDependencies.add(name);
}
}
}
// jars
if (null != awbBundle.getJavaDependencies()) {
Iterator<? extends JavaLibrary> iterator = awbBundle.getJavaDependencies().iterator();
while (iterator.hasNext()) {
JavaLibrary jarInfo = iterator.next();
MavenCoordinates mavenCoordinates = jarInfo.getResolvedCoordinates();
String name = getMavenName(mavenCoordinates);
if (apMainDependencies.contains(name)) {
getLogger().info("[Remove]" + name);
iterator.remove();
} else {
inAwbDependencies.add(name);
}
}
}
FileUtils.writeStringToFile(diffOutFile, StringUtils.join(inAwbDependencies, "\n"));
}
use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.
the class MtlParallelTask method run.
@TaskAction
void run() throws ExecutionException, InterruptedException {
if (null == parallelTask || parallelTask.isEmpty()) {
return;
}
if (concurrent) {
String taskName = uniqueTaskName;
if (StringUtils.isEmpty(taskName)) {
taskName = parallelTask.get(0).getClass().getSimpleName();
}
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
List<Runnable> runnables = new ArrayList<>();
for (final DefaultTask task : parallelTask) {
runnables.add(new Runnable() {
@Override
public void run() {
task.execute();
}
});
}
executorServicesHelper.execute(runnables);
} else {
for (final DefaultTask task : parallelTask) {
task.execute();
}
}
}
use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.
the class PrepareAwbTask method run.
@TaskAction
void run() throws ExecutionException, InterruptedException, IOException, DocumentException {
AndroidDependencyTree androidDependencyTree = AtlasBuildContext.androidDependencyTrees.get(getVariantName());
if (null == androidDependencyTree) {
return;
}
ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper(taskName, getLogger(), 0);
List<Runnable> runnables = new ArrayList<>();
Set<SoLibrary> soLibraries = androidDependencyTree.getALLSoLibDependencies();
for (final SoLibrary soLibrary : soLibraries) {
runnables.add(new Runnable() {
@Override
public void run() {
prepare(soLibrary.getSoLibFile(), soLibrary.getFolder(), false);
}
});
}
executorServicesHelper.execute(runnables);
runnables.clear();
List<AwbBundle> awbBundles = androidDependencyTree.getAwbBundles();
for (final AwbBundle awbBundle : awbBundles) {
runnables.add(new Runnable() {
@Override
public void run() {
prepare(awbBundle.getBundle(), awbBundle.getFolder(), true);
}
});
}
executorServicesHelper.execute(runnables);
runnables.clear();
Set<AarBundle> aarBundles = androidDependencyTree.getALLAarDependencies();
for (final AarBundle aarBundle : aarBundles) {
runnables.add(new Runnable() {
@Override
public void run() {
prepare(aarBundle.getBundle(), aarBundle.getFolder(), true);
}
});
}
executorServicesHelper.execute(runnables);
runnables.clear();
}
use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.
the class AwbDexTask method taskAction.
/**
* Actual entry point for the action.
* Calls out to the doTaskAction as needed.
*/
@TaskAction
public void taskAction() throws InterruptedException, ProcessException, IOException {
Collection<File> _inputFiles = getInputFiles();
File _inputDir = getInputDir();
if (_inputFiles == null && _inputDir == null) {
throw new StopExecutionException("Dex task " + getName() + ": inputDir and inputFiles cannot both be null");
}
doTaskAction(_inputFiles, _inputDir, false);
}
Aggregations