public VisualStudioProjectConfiguration lookupProjectConfiguration(
     NativeBinarySpec nativeBinary) {
   // Looks in the correct project registry for this binary
   ProjectInternal componentProject = getComponentProject(nativeBinary);
   VisualStudioExtension visualStudioExtension =
       componentProject
           .getModelRegistry()
           .get(ModelPath.path("visualStudio"), ModelType.of(VisualStudioExtension.class));
   VisualStudioProjectRegistry projectRegistry =
       ((VisualStudioExtensionInternal) visualStudioExtension).getProjectRegistry();
   return projectRegistry.getProjectConfiguration(nativeBinary);
 }
 /** Invoked by transformed DSL creation rules */
 public <T> void create(String modelPathString, Class<T> type, Closure<?> closure) {
   SourceLocation sourceLocation = ruleLocationExtractor.transform(closure);
   ModelPath modelPath = ModelPath.path(modelPathString);
   ModelRuleDescriptor descriptor = toDescriptor(sourceLocation, modelPath);
   try {
     NodeInitializerRegistry nodeInitializerRegistry =
         modelRegistry.realize(
             DefaultNodeInitializerRegistry.DEFAULT_REFERENCE.getPath(),
             DefaultNodeInitializerRegistry.DEFAULT_REFERENCE.getType());
     NodeInitializer nodeInitializer =
         nodeInitializerRegistry.getNodeInitializer(ModelType.of(type));
     modelRegistry.create(
         ModelCreators.of(modelPath, nodeInitializer).descriptor(descriptor).build());
   } catch (ModelTypeInitializationException e) {
     throw new InvalidModelRuleDeclarationException(descriptor, e);
   }
   registerAction(modelPath, type, descriptor, ModelActionRole.Initialize, closure);
 }
示例#3
0
  public void apply(final Project project) {
    RepositoryHandler repositories = publicationServices.createRepositoryHandler();
    PublicationContainer publications =
        instantiator.newInstance(DefaultPublicationContainer.class, instantiator);

    // TODO Registering an extension should register it with the model registry as well
    final PublishingExtension extension =
        project
            .getExtensions()
            .create(
                PublishingExtension.NAME,
                DefaultPublishingExtension.class,
                repositories,
                publications);

    project.afterEvaluate(
        new Action<Project>() {
          public void execute(Project project) {
            for (Publication publication : extension.getPublications()) {
              PublicationInternal internalPublication = (PublicationInternal) publication;
              publicationRegistry.registerPublication(
                  project.getPath(),
                  new DefaultProjectPublication(internalPublication.getCoordinates()));
            }
          }
        });

    ModelPath extensionModelPath = ModelPath.path(PublishingExtension.NAME);

    modelRules.register(extensionModelPath.toString(), extension);

    modelRules.rule(
        new ModelRule() {
          public void triggerDeferredConfigurables(PublishingExtension publishingExtension) {
            project.getExtensions().getByType(DefaultPublishingExtension.class);
          }
        });

    Task publishLifecycleTask = project.getTasks().create(PUBLISH_LIFECYCLE_TASK_NAME);
    publishLifecycleTask.setDescription("Publishes all publications produced by this project.");
    publishLifecycleTask.setGroup(PUBLISH_TASK_GROUP);
  }
 /** Invoked by transformed DSL configuration rules */
 public void configure(String modelPathString, Closure<?> closure) {
   SourceLocation sourceLocation = ruleLocationExtractor.transform(closure);
   ModelPath modelPath = ModelPath.path(modelPathString);
   ModelRuleDescriptor descriptor = toDescriptor(sourceLocation, modelPath);
   registerAction(modelPath, Object.class, descriptor, ModelActionRole.Mutate, closure);
 }