Java 类org.gradle.api.internal.ClosureBackedAction 实例源码

项目:Pushjet-Android    文件:NonTransformedModelDslBacking.java   
private void registerConfigurationAction(final Closure<?> action) {
    modelRegistry.mutate(new ModelMutator<Object>() {
        public ModelReference<Object> getSubject() {
            return ModelReference.untyped(modelPath);
        }

        public void mutate(Object object, Inputs inputs) {
            new ClosureBackedAction<Object>(action).execute(object);
        }

        public ModelRuleDescriptor getDescriptor() {
            return new SimpleModelRuleDescriptor("model." + modelPath);
        }

        public List<ModelReference<?>> getInputs() {
            return Collections.emptyList();
        }
    });
}
项目:Reer    文件:DefaultGroovyMavenDeployer.java   
private RemoteRepository createRepository(Map properties, Closure closure) {
    RemoteRepository repository = new MavenRemoteRepository();
    ConfigureUtil.configureByMap(properties, repository);
    // Should be using ConfigureUtil (with DELEGATE_FIRST strategy), however for backwards compatibility need to use OWNER_FIRST
    new ClosureBackedAction<RemoteRepository>(closure, Closure.OWNER_FIRST).execute(repository);
    return repository;
}
项目:Reer    文件:NonTransformedModelDslBacking.java   
private void registerConfigurationAction(final Closure<?> action) {
    modelRegistry.configure(ModelActionRole.Mutate,
        new NoInputsModelAction<Object>(
            ModelReference.untyped(modelPath),
            new SimpleModelRuleDescriptor("model." + modelPath), new ClosureBackedAction<Object>(action)
        ));
}
项目:Reer    文件:NonTransformedModelDslBacking.java   
public void configure(Closure<?> action) {
    executingDsl.set(true);
    try {
        ClosureBackedAction.execute(this, action);
    } finally {
        executingDsl.set(false);
    }
}
项目:Reer    文件:DefaultIsolatedAntBuilder.java   
public void execute(final Closure antClosure) {
    classLoaderCache.withCachedClassLoader(libClasspath, gradleApiGroovyLoader, antAdapterGroovyLoader,
        new Factory<ClassLoader>() {
            @Override
            public ClassLoader create() {
                return new VisitableURLClassLoader(baseAntLoader, libClasspath);
            }
        }, new Action<CachedClassLoader>() {
            @Override
            public void execute(CachedClassLoader cachedClassLoader) {
                ClassLoader classLoader = cachedClassLoader.getClassLoader();
                Object antBuilder = newInstanceOf("org.gradle.api.internal.project.ant.BasicAntBuilder");
                Object antLogger = newInstanceOf("org.gradle.api.internal.project.ant.AntLoggingAdapter");

                // This looks ugly, very ugly, but that is apparently what Ant does itself
                ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(classLoader);

                try {
                    configureAntBuilder(antBuilder, antLogger);

                    // Ideally, we'd delegate directly to the AntBuilder, but its Closure class is different to our caller's
                    // Closure class, so the AntBuilder's methodMissing() doesn't work. It just converts our Closures to String
                    // because they are not an instanceof its Closure class.
                    Object delegate = new AntBuilderDelegate(antBuilder, classLoader);
                    ClosureBackedAction.execute(delegate, antClosure);
                } finally {
                    Thread.currentThread().setContextClassLoader(originalLoader);
                    disposeBuilder(antBuilder, antLogger);
                }
            }
        });
}
项目:Reer    文件:DefaultProject.java   
public void model(Closure<?> modelRules) {
    ModelRegistry modelRegistry = getModelRegistry();
    if (TransformedModelDslBacking.isTransformedBlock(modelRules)) {
        ClosureBackedAction.execute(new TransformedModelDslBacking(modelRegistry, this.getRootProject().getFileResolver()), modelRules);
    } else {
        new NonTransformedModelDslBacking(modelRegistry).configure(modelRules);
    }
}
项目:Reer    文件:ConfigureUtil.java   
private static <T> void configureTarget(Closure configureClosure, T target, ConfigureDelegate closureDelegate) {
    if (!(configureClosure instanceof GeneratedClosure)) {
        new ClosureBackedAction<T>(configureClosure, Closure.DELEGATE_FIRST, false).execute(target);
        return;
    }

    // Hackery to make closure execution faster, by short-circuiting the expensive property and method lookup on Closure
    Closure withNewOwner = configureClosure.rehydrate(target, closureDelegate, configureClosure.getThisObject());
    new ClosureBackedAction<T>(withNewOwner, Closure.OWNER_ONLY, false).execute(target);
}
项目:intellij-ce-playground    文件:AndroidTaskRegistry.java   
public synchronized AndroidTask<Task> create(
        TaskFactory taskFactory,
        String taskName,
        Closure configAction) {

    taskFactory.create(taskName, DefaultTask.class, new ClosureBackedAction<Task>(configAction));
    final AndroidTask<Task> newTask = new AndroidTask<Task>(taskName, Task.class);
    tasks.put(taskName, newTask);

    return newTask;
}
项目:intellij-ce-playground    文件:AndroidTaskRegistry.java   
public synchronized <T extends Task> AndroidTask<T> create(
        TaskFactory taskFactory,
        String taskName,
        Class<T> taskClass,
        Closure configAction) {

    taskFactory.create(taskName, taskClass, new ClosureBackedAction<T>(configAction));
    final AndroidTask<T> newTask = new AndroidTask<T>(taskName, taskClass);
    tasks.put(taskName, newTask);

    return newTask;
}
项目:Pushjet-Android    文件:NonTransformedModelDslBacking.java   
public void configure(Closure<?> action) {
    executingDsl.set(true);
    try {
        new ClosureBackedAction<Object>(action).execute(this);
    } finally {
        executingDsl.set(false);
    }
}
项目:Pushjet-Android    文件:ClosureBackedModelMutator.java   
public void mutate(final Object object, Inputs inputs) {
    RuleInputAccessBacking.runWithContext(inputs, new Runnable() {
        public void run() {
            new ClosureBackedAction<Object>(action).execute(object);
        }
    });
}
项目:Pushjet-Android    文件:GroovyModelDsl.java   
public void configure(Closure<?> action) {
    executingDsl.set(true);
    try {
        new ClosureBackedAction<Object>(action).execute(this);
    } finally {
        executingDsl.set(false);
    }
}
项目:jarjar    文件:JarjarController.java   
@Nonnull
public FileCollection repackage(@Nonnull String name, @Nonnull Closure<?> c) {
    JarjarTask jarjar = project.getTasks().create(
            name,
            JarjarTask.class,
            new ClosureBackedAction<JarjarTask>(c));
    return jarjar.getOutputs().getFiles();
}
项目:bazel    文件:JarjarController.java   
@Nonnull
public FileCollection repackage(@Nonnull String name, @Nonnull Closure<?> c) {
    JarjarTask jarjar = project.getTasks().create(
            name,
            JarjarTask.class,
            new ClosureBackedAction<JarjarTask>(c));
    return jarjar.getOutputs().getFiles();
}
项目:Reer    文件:Pmd.java   
/**
 * Configures the reports to be generated by this task.
 */
public PmdReports reports(@DelegatesTo(value = PmdReports.class, strategy = Closure.DELEGATE_FIRST) Closure closure) {
    return reports(new ClosureBackedAction<PmdReports>(closure));
}
项目:Reer    文件:CodeNarc.java   
/**
 * Configures the reports to be generated by this task.
 */
public CodeNarcReports reports(Closure closure) {
    return reports(new ClosureBackedAction<CodeNarcReports>(closure));
}
项目:Reer    文件:NodeBackedModelSet.java   
public void create(Closure<?> closure) {
    create(ClosureBackedAction.of(closure));
}
项目:Reer    文件:NodeBackedModelSet.java   
public void afterEach(Closure<?> closure) {
    afterEach(ClosureBackedAction.of(closure));
}
项目:Reer    文件:NodeBackedModelSet.java   
public void beforeEach(Closure<?> closure) {
    beforeEach(ClosureBackedAction.of(closure));
}
项目:Reer    文件:ModelMapGroovyView.java   
public void create(String name, Closure<? super I> configAction) {
    create(name, new ClosureBackedAction<I>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public <S extends I> void create(String name, Class<S> type, Closure<? super S> configAction) {
    create(name, type, new ClosureBackedAction<I>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public void named(String name, Closure<? super I> configAction) {
    named(name, new ClosureBackedAction<I>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public void all(Closure<? super I> configAction) {
    all(new ClosureBackedAction<I>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public <S> void withType(Class<S> type, Closure<? super S> configAction) {
    withType(type, new ClosureBackedAction<S>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public void beforeEach(Closure<? super I> configAction) {
    beforeEach(new ClosureBackedAction<I>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public <S> void beforeEach(Class<S> type, Closure<? super S> configAction) {
    beforeEach(type, new ClosureBackedAction<S>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public void afterEach(Closure<? super I> configAction) {
    afterEach(new ClosureBackedAction<I>(configAction));
}
项目:Reer    文件:ModelMapGroovyView.java   
public <S> void afterEach(Class<S> type, Closure<? super S> configAction) {
    afterEach(type, new ClosureBackedAction<S>(configAction));
}
项目:Reer    文件:AbstractGradleExecuter.java   
public void beforeExecute(@DelegatesTo(GradleExecuter.class) Closure action) {
    beforeExecute.add(new ClosureBackedAction<GradleExecuter>(action));
}
项目:Reer    文件:AbstractGradleExecuter.java   
public void afterExecute(@DelegatesTo(GradleExecuter.class) Closure action) {
    afterExecute.add(new ClosureBackedAction<GradleExecuter>(action));
}
项目:Reer    文件:NonTransformedModelDslBacking.java   
private <T> void register(Class<T> type, Closure<?> closure) {
    register(type, new ClosureBackedAction<T>(closure));
}
项目:Reer    文件:DefaultScalaSourceSet.java   
public ScalaSourceSet scala(Closure configureClosure) {
    return scala(ClosureBackedAction.of(configureClosure));
}
项目:Reer    文件:DefaultConfiguration.java   
@Override
public Configuration resolutionStrategy(Closure closure) {
    return resolutionStrategy(ClosureBackedAction.of(closure));
}
项目:Reer    文件:HtmlRenderContext.java   
public void render(Closure<?> renderAction) {
    ClosureBackedAction.execute(markupBuilder, renderAction);
}
项目:Reer    文件:JacocoReport.java   
/**
 * Configures the reports to be generated by this task.
 */
@Override
public JacocoReportsContainer reports(Closure closure) {
    return reports(new ClosureBackedAction<JacocoReportsContainer>(closure));
}
项目:Reer    文件:HtmlDependencyReportTask.java   
@Override
public DependencyReportContainer reports(Closure closure) {
    return reports(new ClosureBackedAction<DependencyReportContainer>(closure));
}
项目:Reer    文件:AbstractCopyTask.java   
/**
 * {@inheritDoc}
 */
public AbstractCopyTask from(Object sourcePath, final Closure c) {
    getMainSpec().from(sourcePath, new ClosureBackedAction<CopySpec>(c));
    return this;
}
项目:Reer    文件:AbstractModuleDependency.java   
public DependencyArtifact artifact(Closure configureClosure) {
    return artifact(ClosureBackedAction.of(configureClosure));
}
项目:Reer    文件:CompositeFileTree.java   
public FileTree matching(Closure filterConfigClosure) {
    return matching(ClosureBackedAction.<PatternFilterable>of(filterConfigClosure));
}
项目:Reer    文件:CompositeFileTree.java   
public FileTree visit(Closure visitor) {
    return visit(ClosureBackedAction.<FileVisitDetails>of(visitor));
}