Search in sources :

Example 91 with TaskAction

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

the class MeecrowaveTask method bake.

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

Example 92 with TaskAction

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

the class CgenTask method generate.

@TaskAction
public void generate() {
    File dataMapFile = getDataMapFile();
    Injector injector = DIBootstrap.createInjector(new ToolsModule(LoggerFactory.getLogger(CgenTask.class)));
    CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction(injector);
    loaderAction.setMainDataMapFile(dataMapFile);
    CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
    filterAction.setClient(client);
    filterAction.setNameFilter(NamePatternMatcher.build(getLogger(), includeEntities, excludeEntities));
    try {
        loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
        ClassGenerationAction generator = this.createGenerator();
        DataMap dataMap = loaderAction.getMainDataMap();
        generator.setLogger(getLogger());
        if (this.force || getProject().hasProperty("force")) {
            generator.setForce(true);
        }
        generator.setTimestamp(dataMapFile.lastModified());
        generator.setDataMap(dataMap);
        generator.addEntities(filterAction.getFilteredEntities(dataMap));
        generator.addEmbeddables(dataMap.getEmbeddables());
        generator.addQueries(dataMap.getQueryDescriptors());
        generator.execute();
    } catch (Exception exception) {
        throw new GradleException("Error generating classes: ", exception);
    }
}
Also used : Injector(org.apache.cayenne.di.Injector) GradleException(org.gradle.api.GradleException) File(java.io.File) InputFile(org.gradle.api.tasks.InputFile) ToolsModule(org.apache.cayenne.dbsync.reverse.configuration.ToolsModule) GradleException(org.gradle.api.GradleException) InvalidUserDataException(org.gradle.api.InvalidUserDataException) ClientClassGenerationAction(org.apache.cayenne.gen.ClientClassGenerationAction) ClassGenerationAction(org.apache.cayenne.gen.ClassGenerationAction) DataMap(org.apache.cayenne.map.DataMap) 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