Search in sources :

Example 6 with TaskAction

use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.

the class AwoFullApkBuildTask method doTask.

@TaskAction
public void doTask() throws IOException, SigningException {
    baseApkFile = getBaseApkFile();
    destPath = getDestPath();
    awoFile = getAwoFile();
    zipAlign = getZipAlign();
    outApkFile = getOutApkFile();
    ZipUtils.addFileToZipFile(baseApkFile, outApkFile, awoFile, destPath, true);
    File signFile = new File(outApkFile.getParent(), outApkFile.getName().replace(".apk", "-signed.apk"));
    AtlasBuildContext.androidSigner.signFile(outApkFile, signFile, getSigningConfig());
    if (null != zipAlign && zipAlign) {
        File signAndZipAlignedFile = ZipAlignUtils.doZipAlign(androidBuilder, getProject(), signFile);
        FileUtils.deleteQuietly(outApkFile);
        FileUtils.moveFile(signAndZipAlignedFile, outApkFile);
    }
}
Also used : File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile) InputFile(org.gradle.api.tasks.InputFile) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 7 with TaskAction

use of org.gradle.api.tasks.TaskAction in project atlas by alibaba.

the class PreProcessManifestTask method preProcess.

@TaskAction
public void preProcess() throws IOException, DocumentException, InterruptedException {
    getLogger().info("[MTLPlugin]Start PreProcess Lib manifest files,main manifestFile is:" + getMainManifestFile());
    ExecutorServicesHelper executorServicesHelper = new ExecutorServicesHelper("preProcessDex", getLogger(), 0);
    List<Runnable> runnables = new ArrayList<>();
    ManifestFileObject mainManifestFileObject = ManifestFileUtils.getManifestFileObject(mainManifestFile);
    mainManifestFileObject.init();
    for (File file : getLibraryManifests()) {
        runnables.add(new Runnable() {

            @Override
            public void run() {
                try {
                    ManifestFileUtils.updatePreProcessManifestFile(file, mainManifestFileObject, true);
                } catch (Throwable e) {
                    throw new GradleException("preprocess manifest", e);
                }
            }
        });
    }
    executorServicesHelper.execute(runnables);
    //ManifestFileUtils.preProcessManifests(getMainManifestFile(), getLibraryManifests(), true);
    //BundleInfoUtils.setupAwbBundleInfos(appVariantOutputContext.getVariantContext());
    //collectBundleInfo();
    addAwbManifest2Merge();
}
Also used : ExecutorServicesHelper(com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper) ManifestFileObject(com.taobao.android.builder.tools.manifest.ManifestFileObject) GradleException(org.gradle.api.GradleException) ArrayList(java.util.ArrayList) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) MtlBaseTaskAction(com.taobao.android.builder.tasks.manager.MtlBaseTaskAction) TaskAction(org.gradle.api.tasks.TaskAction)

Example 8 with TaskAction

use of org.gradle.api.tasks.TaskAction in project Entitas-Java by Rubentxu.

the class CodeGenerationTask method run.

@TaskAction
public void run() {
    entitasProject = new EntitasGradleProject(getProject());
    CodeGenerator codeGenerator = entitasProject.getCodeGenerator();
    codeGenerator.generate();
}
Also used : CodeGenerator(ilargia.entitas.codeGeneration.CodeGenerator) TaskAction(org.gradle.api.tasks.TaskAction)

Example 9 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class GenerateIvyDescriptor method doGenerate.

@TaskAction
public void doGenerate() {
    IvyModuleDescriptorSpecInternal descriptorInternal = toIvyModuleDescriptorInternal(getDescriptor());
    IvyDescriptorFileGenerator ivyGenerator = new IvyDescriptorFileGenerator(descriptorInternal.getProjectIdentity());
    ivyGenerator.setStatus(descriptorInternal.getStatus());
    ivyGenerator.setBranch(descriptorInternal.getBranch());
    ivyGenerator.setExtraInfo(descriptorInternal.getExtraInfo().asMap());
    for (IvyConfiguration ivyConfiguration : descriptorInternal.getConfigurations()) {
        ivyGenerator.addConfiguration(ivyConfiguration);
    }
    for (IvyArtifact ivyArtifact : descriptorInternal.getArtifacts()) {
        ivyGenerator.addArtifact(ivyArtifact);
    }
    for (IvyDependencyInternal ivyDependency : descriptorInternal.getDependencies()) {
        ivyGenerator.addDependency(ivyDependency);
    }
    ivyGenerator.withXml(descriptorInternal.getXmlAction()).writeTo(getDestination());
}
Also used : IvyDescriptorFileGenerator(org.gradle.api.publish.ivy.internal.publisher.IvyDescriptorFileGenerator) IvyDependencyInternal(org.gradle.api.publish.ivy.internal.dependency.IvyDependencyInternal) IvyModuleDescriptorSpecInternal(org.gradle.api.publish.ivy.internal.publication.IvyModuleDescriptorSpecInternal) IvyConfiguration(org.gradle.api.publish.ivy.IvyConfiguration) IvyArtifact(org.gradle.api.publish.ivy.IvyArtifact) TaskAction(org.gradle.api.tasks.TaskAction)

Example 10 with TaskAction

use of org.gradle.api.tasks.TaskAction in project gradle by gradle.

the class AbstractJettyRunTask method start.

@TaskAction
protected void start() {
    ClassLoader originalClassloader = Server.class.getClassLoader();
    List<File> additionalClasspath = new ArrayList<File>();
    for (File additionalRuntimeJar : getAdditionalRuntimeJars()) {
        additionalClasspath.add(additionalRuntimeJar);
    }
    URLClassLoader jettyClassloader = new URLClassLoader(new DefaultClassPath(additionalClasspath).getAsURLArray(), originalClassloader);
    try {
        Thread.currentThread().setContextClassLoader(jettyClassloader);
        startJetty();
    } finally {
        Thread.currentThread().setContextClassLoader(originalClassloader);
    }
}
Also used : URLClassLoader(java.net.URLClassLoader) ArrayList(java.util.ArrayList) URLClassLoader(java.net.URLClassLoader) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskAction (org.gradle.api.tasks.TaskAction)167 File (java.io.File)66 GradleException (org.gradle.api.GradleException)38 IOException (java.io.IOException)35 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)32 ArrayList (java.util.ArrayList)29 Project (org.gradle.api.Project)18 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)16 InputFile (org.gradle.api.tasks.InputFile)16 OutputFile (org.gradle.api.tasks.OutputFile)15 FileCollection (org.gradle.api.file.FileCollection)13 AtlasDependencyTree (com.taobao.android.builder.dependency.AtlasDependencyTree)12 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)12 Map (java.util.Map)12 DefaultTask (org.gradle.api.DefaultTask)12 HashMap (java.util.HashMap)10 InvalidUserDataException (org.gradle.api.InvalidUserDataException)9 AndroidLibrary (com.android.builder.model.AndroidLibrary)8 URLClassLoader (java.net.URLClassLoader)8 WorkResult (org.gradle.api.tasks.WorkResult)8