Upload artifacts from component model

From what I can tell, the only upload artifacts if you pass a configuration to RuleSource via an extension. Is there another way to do this / a roadmap for when this will be supported?

Is it possible to retrieve a model in a legacy plugin to bridge this gap?

Publishing with the software model is something that remains to be addressed. This is obviously on the roadmap, as it’s something that is necessary in order for it to be realistically usable.

I think you could potentially get this to work with the new publishing plugins (which also have one foot in model land and the other in the legacy world). You can certainly define a publication using model rules since the publishing extension itself is registered with the model.

For anyone else interested, here is what I ended up doing:

  public static class Rules extends RuleSource {

    @Mutate
    public void publishBinaries(PublishingExtension publishingExtension, ModelMap<BinarySpec> specs) {
      final PublicationContainer publications = publishingExtension.getPublications();
      for (final MyBinarySpec spec : specs.withType(MyBinarySpec.class)) {
        if(publications.findByName(spec.getName()) != null) { //prevents the same spec from being called twice.
          continue;
        }
        for (PublishingTask publishingTask : spec.getTasks().withType(PublishingTask.class)) {
          publications.create(spec.getName(), IvyPublication.class, new IvyPublishAction(publishingTask));
        }
      }
    }
  }

  private static class IvyPublishAction implements Action<IvyPublication> {

    private final PublishingTask buildTask;

    private IvyPublishAction(PublishingTask buildTask) {
      this.buildTask = buildTask;
    }

    @Override
    public void execute(IvyPublication ivyPublication) {
      logger.lifecycle("Task name: {}", buildTask.getName());
      PublishArtifact artifact = buildTask.getFileToPublish();
      ivyPublication.artifact(artifact);
    }
  }

public interface PublishingTask extends Task {
  PublishArtifact getFileToPublish();
}