use of org.gradle.api.publish.maven.MavenPublication in project spring-boot by spring-projects.
the class DeployedPlugin method apply.
@Override
@SuppressWarnings("deprecation")
public void apply(Project project) {
project.getPlugins().apply(MavenPublishPlugin.class);
project.getPlugins().apply(MavenRepositoryPlugin.class);
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
MavenPublication mavenPublication = publishing.getPublications().create("maven", MavenPublication.class);
project.afterEvaluate((evaluated) -> {
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
if (((Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME)).isEnabled()) {
project.getComponents().matching((component) -> component.getName().equals("java")).all((javaComponent) -> mavenPublication.from(javaComponent));
}
});
});
project.getPlugins().withType(JavaPlatformPlugin.class).all((javaPlugin) -> project.getComponents().matching((component) -> component.getName().equals("javaPlatform")).all((javaComponent) -> mavenPublication.from(javaComponent)));
}
use of org.gradle.api.publish.maven.MavenPublication in project gradle by gradle.
the class MavenPluginPublishPlugin method createMavenMarkerPublication.
private void createMavenMarkerPublication(PluginDeclaration declaration, final MavenPublication coordinates, PublicationContainer publications) {
String pluginId = declaration.getId();
String pluginGroupId = coordinates.getGroupId();
String pluginArtifactId = coordinates.getArtifactId();
String pluginVersion = coordinates.getVersion();
MavenPublicationInternal publication = (MavenPublicationInternal) publications.create(declaration.getName() + "PluginMarkerMaven", MavenPublication.class);
publication.setAlias(true);
publication.setArtifactId(pluginId + PLUGIN_MARKER_SUFFIX);
publication.setGroupId(pluginId);
publication.getPom().withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
Element root = xmlProvider.asElement();
Document document = root.getOwnerDocument();
Node dependencies = root.appendChild(document.createElement("dependencies"));
Node dependency = dependencies.appendChild(document.createElement("dependency"));
Node groupId = dependency.appendChild(document.createElement("groupId"));
groupId.setTextContent(pluginGroupId);
Node artifactId = dependency.appendChild(document.createElement("artifactId"));
artifactId.setTextContent(pluginArtifactId);
Node version = dependency.appendChild(document.createElement("version"));
version.setTextContent(pluginVersion);
}
});
publication.getPom().getName().set(declaration.getDisplayName());
publication.getPom().getDescription().set(declaration.getDescription());
}
use of org.gradle.api.publish.maven.MavenPublication in project gradle by gradle.
the class MavenPluginPublishingRules method createMavenMarkerPublication.
private void createMavenMarkerPublication(PluginDeclaration declaration, final MavenPublication coordinates, PublicationContainer publications) {
String pluginId = declaration.getId();
MavenPublicationInternal publication = (MavenPublicationInternal) publications.create(declaration.getName() + "PluginMarkerMaven", MavenPublication.class);
publication.setAlias(true);
publication.setArtifactId(pluginId + PLUGIN_MARKER_SUFFIX);
publication.setGroupId(pluginId);
publication.getPom().withXml(new Action<XmlProvider>() {
@Override
public void execute(XmlProvider xmlProvider) {
Element root = xmlProvider.asElement();
Document document = root.getOwnerDocument();
Node dependencies = root.appendChild(document.createElement("dependencies"));
Node dependency = dependencies.appendChild(document.createElement("dependency"));
Node groupId = dependency.appendChild(document.createElement("groupId"));
groupId.setTextContent(coordinates.getGroupId());
Node artifactId = dependency.appendChild(document.createElement("artifactId"));
artifactId.setTextContent(coordinates.getArtifactId());
Node version = dependency.appendChild(document.createElement("version"));
version.setTextContent(coordinates.getVersion());
}
});
}
use of org.gradle.api.publish.maven.MavenPublication in project gradle by gradle.
the class MavenPluginPublishingRules method createMavenPluginPublication.
private void createMavenPluginPublication(SoftwareComponent component, PublicationContainer publications) {
MavenPublication publication = publications.maybeCreate("pluginMaven", MavenPublication.class);
publication.from(component);
}
use of org.gradle.api.publish.maven.MavenPublication in project shipkit by mockito.
the class JavaPublishPlugin method apply.
public void apply(final Project project) {
final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
project.getPlugins().apply(JavaLibraryPlugin.class);
project.getPlugins().apply("maven-publish");
final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK);
final Jar javadocJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.JAVADOC_JAR_TASK);
GradleDSLHelper.publications(project, new Action<PublicationContainer>() {
public void execute(PublicationContainer publications) {
MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, new Action<MavenPublication>() {
public void execute(MavenPublication publication) {
publication.from(project.getComponents().getByName("java"));
publication.artifact(sourcesJar);
publication.artifact(javadocJar);
publication.setArtifactId(((Jar) project.getTasks().getByName("jar")).getBaseName());
PomCustomizer.customizePom(project, conf, publication);
}
});
LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId());
}
});
// so that we flesh out problems with maven publication during the build process
project.getTasks().getByName("build").dependsOn("publishToMavenLocal");
}
Aggregations