@TaskAction
  public void doGenerate() {
    XmlTransformer xmlTransformer = new XmlTransformer();
    Action<? super XmlProvider> xmlAction = getXmlAction();
    if (xmlAction != null) {
      xmlTransformer.addAction(xmlAction);
    }

    IvyModuleDescriptorInternal descriptorInternal = toIvyModuleDescriptorInternal(getDescriptor());

    ModuleDescriptorConverter moduleDescriptorConverter =
        publicationServices.getDescriptorFileModuleConverter();
    ModuleDescriptor moduleDescriptor =
        moduleDescriptorConverter.convert(
            descriptorInternal.getConfigurations(), descriptorInternal.getModule());
    IvyModuleDescriptorWriter ivyModuleDescriptorWriter =
        publicationServices.getIvyModuleDescriptorWriter();
    ivyModuleDescriptorWriter.write(moduleDescriptor, getDestination(), xmlTransformer);
  }
Exemple #2
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);
  }