Search in sources :

Example 51 with TaskAction

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

the class GenerateModuleMetadata method run.

@TaskAction
void run() {
    File file = outputFile.get().getAsFile();
    PublicationInternal publication = (PublicationInternal) this.publication.get();
    List<PublicationInternal> publications = Cast.uncheckedCast(this.publications.get());
    try {
        Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf8"));
        try {
            new ModuleMetadataFileGenerator(getBuildInvocationScopeId(), getProjectDependencyPublicationResolver()).generateTo(publication, publications, writer);
        } finally {
            writer.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException("Could not generate metadata file " + outputFile.get(), e);
    }
}
Also used : ModuleMetadataFileGenerator(org.gradle.api.publish.internal.ModuleMetadataFileGenerator) PublicationInternal(org.gradle.api.publish.internal.PublicationInternal) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) File(java.io.File) OutputFile(org.gradle.api.tasks.OutputFile) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) BufferedWriter(java.io.BufferedWriter) TaskAction(org.gradle.api.tasks.TaskAction)

Example 52 with TaskAction

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

the class TomEEEmbeddedTask method runTomEEEmbedded.

@TaskAction
public void runTomEEEmbedded() {
    fixConfig();
    final Thread thread = Thread.currentThread();
    final ClassLoader tccl = thread.getContextClassLoader();
    thread.setContextClassLoader(createLoader(tccl));
    try {
        doRun();
    } finally {
        thread.setContextClassLoader(tccl);
    }
}
Also used : FilterGradleClassLoader(org.apache.tomee.gradle.embedded.classloader.FilterGradleClassLoader) URLClassLoader(java.net.URLClassLoader) TaskAction(org.gradle.api.tasks.TaskAction)

Example 53 with TaskAction

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

the class JacocoReport method generate.

@TaskAction
public void generate() {
    final Spec<File> fileExistsSpec = new Spec<File>() {

        @Override
        public boolean isSatisfiedBy(File file) {
            return file.exists();
        }
    };
    new AntJacocoReport(getAntBuilder()).execute(getJacocoClasspath(), getProject().getName(), getAllClassDirs().filter(fileExistsSpec), getAllSourceDirs().filter(fileExistsSpec), getExecutionData(), getReports());
}
Also used : AntJacocoReport(org.gradle.internal.jacoco.AntJacocoReport) Spec(org.gradle.api.specs.Spec) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Example 54 with TaskAction

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

the class PublishToIvyRepository method publish.

@TaskAction
public void publish() {
    IvyPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }
    IvyArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }
    doPublish(publicationInternal, repository);
}
Also used : IvyPublicationInternal(org.gradle.api.publish.ivy.internal.publication.IvyPublicationInternal) InvalidUserDataException(org.gradle.api.InvalidUserDataException) IvyArtifactRepository(org.gradle.api.artifacts.repositories.IvyArtifactRepository) TaskAction(org.gradle.api.tasks.TaskAction)

Example 55 with TaskAction

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

the class JacocoCoverageVerification method check.

@TaskAction
public void check() {
    final Spec<File> fileExistsSpec = new Spec<File>() {

        @Override
        public boolean isSatisfiedBy(File file) {
            return file.exists();
        }
    };
    JacocoCheckResult checkResult = new AntJacocoCheck(getAntBuilder()).execute(getJacocoClasspath(), getProject().getName(), getAllClassDirs().filter(fileExistsSpec), getAllSourceDirs().filter(fileExistsSpec), getExecutionData(), getViolationRules());
    if (!checkResult.isSuccess()) {
        throw new GradleException(checkResult.getFailureMessage());
    }
}
Also used : GradleException(org.gradle.api.GradleException) AntJacocoCheck(org.gradle.internal.jacoco.AntJacocoCheck) Spec(org.gradle.api.specs.Spec) File(java.io.File) JacocoCheckResult(org.gradle.internal.jacoco.JacocoCheckResult) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TaskAction (org.gradle.api.tasks.TaskAction)92 File (java.io.File)40 MtlBaseTaskAction (com.taobao.android.builder.tasks.manager.MtlBaseTaskAction)22 GradleException (org.gradle.api.GradleException)15 ArrayList (java.util.ArrayList)11 InputFile (org.gradle.api.tasks.InputFile)11 AwbBundle (com.taobao.android.builder.dependency.model.AwbBundle)10 OutputFile (org.gradle.api.tasks.OutputFile)10 AndroidDependencyTree (com.taobao.android.builder.dependency.AndroidDependencyTree)9 IOException (java.io.IOException)8 Project (org.gradle.api.Project)8 WorkResult (org.gradle.api.tasks.WorkResult)8 BuildOperationLogger (org.gradle.internal.operations.logging.BuildOperationLogger)8 ExecutorServicesHelper (com.taobao.android.builder.tools.concurrent.ExecutorServicesHelper)7 InvalidUserDataException (org.gradle.api.InvalidUserDataException)7 HashSet (java.util.HashSet)6 SoLibrary (com.taobao.android.builder.dependency.model.SoLibrary)5 AndroidLibrary (com.android.builder.model.AndroidLibrary)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4