@Mutate public void addMainPublication(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment, ServiceRegistry services) { if (!pluginDevelopment.isAutomatedPublishing()) { return; } SoftwareComponentContainer componentContainer = services.get(SoftwareComponentContainer.class); SoftwareComponent component = componentContainer.getByName("java"); PublicationContainer publications = publishing.getPublications(); createMavenPluginPublication(component, publications); }
@Mutate public void addMainPublication(PublishingExtension publishing, GradlePluginDevelopmentExtension pluginDevelopment, ServiceRegistry services) { if (!pluginDevelopment.isAutomatedPublishing()) { return; } SoftwareComponentContainer componentContainer = services.get(SoftwareComponentContainer.class); SoftwareComponent component = componentContainer.getByName("java"); PublicationContainer publications = publishing.getPublications(); createIvyPluginPublication(component, publications); }
@Inject public SoftwareComponentContainer getComponents() { // Decoration takes care of the implementation throw new UnsupportedOperationException(); }
protected SoftwareComponentContainer createSoftwareComponentContainer() { Instantiator instantiator = get(Instantiator.class); return instantiator.newInstance(DefaultSoftwareComponentContainer.class, instantiator); }
/** * Create the default Maven publication * * @param publishingExtension Publishing extension where the publication is created * @param projectContext Project context to access project information * @param projectConfig Project configuration * @param mavenConfig Maven configuration * @param configurations Container to access configurations * @param services Service manager to obtain service objects */ @Mutate public void createPublications(PublishingExtension publishingExtension, ProjectContext projectContext, ProjectConfig projectConfig, MavenConfig mavenConfig, ConfigurationContainer configurations, ServiceRegistry services) { SoftwareComponentContainer components = services.get(SoftwareComponentContainer.class); JavaLibrary javaComponent = components.withType(JavaLibrary.class).getByName("java"); for (MavenPublicationConfig publicationConfig : mavenConfig.getPublications()) { Configuration configuration = configurations .getByName(publicationConfig.getArchivesConfiguration()); publishingExtension.getPublications().create(publicationConfig.getName(), MavenPublication.class, p -> { p.setArtifactId(publicationConfig.getArtifactId()); List<@NonNull Configuration> runtimeConfigurations = publicationConfig .getRuntimeConfigurations().stream().map(c -> configurations.getByName(c)) .collect(Collectors.toList()); List<@NonNull Configuration> compileConfigurations = publicationConfig .getCompileConfigurations().stream().map(c -> configurations.getByName(c)) .collect(Collectors.toList()); List<@NonNull PublishArtifact> artifacts = Collections.emptyList(); if (publicationConfig.isAddProjectArtifacts()) { artifacts = javaComponent.getUsages().stream() .flatMap(u -> u.getArtifacts().stream()).collect(Collectors.toList()); } PomConfigurator configurator = new PomConfigurator(projectContext, projectConfig, Validate.notNull(runtimeConfigurations), Validate.notNull(compileConfigurations)); p.pom(pom -> pom.withXml(xml -> configurator.configurePom(Validate.notNull(xml)))); for (PublishArtifact a : configuration.getArtifacts()) { p.artifact(a); } }); } }
public SoftwareComponentContainer getComponents() { return softwareComponentContainer; }
/** * Returns the software components produced by this project. * * @return The components for this project. */ @Incubating SoftwareComponentContainer getComponents();