Package org.gradle.model.internal.registry

Examples of org.gradle.model.internal.registry.ModelRegistry


        }

        services = serviceRegistryFactory.createFor(this);
        taskContainer = services.newInstance(TaskContainerInternal.class);

        final ModelRegistry modelRegistry = services.get(ModelRegistry.class);

        modelRegistry.create(
                ModelCreators.of(ModelReference.of("serviceRegistry", ServiceRegistry.class), services)
                        .simpleDescriptor("Project.<init>.serviceRegistry()")
                        .build()
        );

        modelRegistry.create(
                ModelCreators.of(ModelReference.of("buildDir", File.class), new Factory<File>() {
                    public File create() {
                        return getBuildDir();
                    }
                })
                        .simpleDescriptor("Project.<init>.buildDir()")
                        .build()
        );

        modelRegistry.create(
                ModelCreators.of(ModelReference.of("projectIdentifier", ProjectIdentifier.class), this)
                        .simpleDescriptor("Project.<init>.projectIdentifier()")
                        .build()
        );

        modelRegistry.create(
                ModelCreators.of(ModelReference.of("extensions", ExtensionContainer.class), new Factory<ExtensionContainer>() {
                    public ExtensionContainer create() {
                        return getExtensions();
                    }
                })
                        .simpleDescriptor("Project.<init>.extensions()")
                        .build()
        );

        modelRegistry.create(
                ModelCreators.of(ModelReference.of(TaskContainerInternal.MODEL_PATH, ModelType.of(TaskContainer.class)), taskContainer)
                        .simpleDescriptor("Project.<init>.tasks()")
                        .withProjection(new PolymorphicDomainObjectContainerModelProjection<TaskContainerInternal, Task>(taskContainer, Task.class))
                        .build());

        taskContainer.all(new Action<Task>() {
            public void execute(final Task task) {
                final String name = task.getName();
                final ModelPath modelPath = TaskContainerInternal.MODEL_PATH.child(name);

                ModelState state = modelRegistry.state(modelPath);
                if (state == null || state.getStatus() != ModelState.Status.IN_CREATION) {
                    modelRegistry.create(
                            ModelCreators.of(ModelReference.of(modelPath, ModelType.typeOf(task)), task)
                                    .simpleDescriptor("Project.<init>.tasks." + name + "()")
                                    .build()
                    );
                }
            }
        });

        taskContainer.whenObjectRemoved(new Action<Task>() {
            public void execute(Task task) {
                modelRegistry.remove(TaskContainerInternal.MODEL_PATH.child(task.getName()));
            }
        });

        extensibleDynamicObject = new ExtensibleDynamicObject(this, services.get(Instantiator.class));
        if (parent != null) {
View Full Code Here

TOP

Related Classes of org.gradle.model.internal.registry.ModelRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.