use of org.gradle.api.publish.PublishingExtension in project gradle by gradle.
the class ProjectDependencyPublicationResolver method resolve.
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
Project dependencyProject = dependency.getDependencyProject();
((ProjectInternal) dependencyProject).evaluate();
PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);
if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
// Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
}
// See if all publications have the same identifier
Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
Iterator<? extends PublicationInternal> iterator = publications.iterator();
ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
while (iterator.hasNext()) {
ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
if (!candidate.equals(alternative)) {
throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
}
}
return candidate;
}
use of org.gradle.api.publish.PublishingExtension in project spring-security by spring-projects.
the class SpringSigningPlugin method sign.
private void sign(Project project) {
SigningExtension signing = project.getExtensions().findByType(SigningExtension.class);
signing.setRequired(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return project.getGradle().getTaskGraph().hasTask("publishArtifacts");
}
});
String signingKeyId = (String) project.findProperty("signingKeyId");
String signingKey = (String) project.findProperty("signingKey");
String signingPassword = (String) project.findProperty("signingPassword");
if (signingKeyId != null) {
signing.useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword);
} else {
signing.useInMemoryPgpKeys(signingKey, signingPassword);
}
project.getPlugins().withType(PublishAllJavaComponentsPlugin.class).all(new Action<PublishAllJavaComponentsPlugin>() {
@Override
public void execute(PublishAllJavaComponentsPlugin publishingPlugin) {
PublishingExtension publishing = project.getExtensions().findByType(PublishingExtension.class);
Publication maven = publishing.getPublications().getByName("mavenJava");
signing.sign(maven);
}
});
}
use of org.gradle.api.publish.PublishingExtension in project spring-security by spring-projects.
the class PublishAllJavaComponentsPlugin method apply.
@Override
public void apply(Project project) {
project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getPublications().create("mavenJava", MavenPublication.class, new Action<MavenPublication>() {
@Override
public void execute(MavenPublication maven) {
project.getPlugins().withType(JavaPlugin.class, (plugin) -> {
maven.from(project.getComponents().getByName("java"));
});
project.getPlugins().withType(JavaPlatformPlugin.class, (plugin) -> {
maven.from(project.getComponents().getByName("javaPlatform"));
});
}
});
});
}
use of org.gradle.api.publish.PublishingExtension in project spring-security by spring-projects.
the class PublishLocalPlugin method apply.
@Override
public void apply(Project project) {
project.getPlugins().withType(MavenPublishPlugin.class).all(new Action<MavenPublishPlugin>() {
@Override
public void execute(MavenPublishPlugin mavenPublish) {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getRepositories().maven(new Action<MavenArtifactRepository>() {
@Override
public void execute(MavenArtifactRepository maven) {
maven.setName("local");
maven.setUrl(new File(project.getRootProject().getBuildDir(), "publications/repos"));
}
});
}
});
}
use of org.gradle.api.publish.PublishingExtension in project coffeenet-starter by coffeenet.
the class ConventionsPlugin method applyMavenConventions.
private void applyMavenConventions(Project project) {
// J-
// @formatter:off
project.getPlugins().withType(MavenPublishPlugin.class, (mavenPublish) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
publishing.getPublications().withType(MavenPublication.class).all((publication) -> {
customizePom(publication.getPom(), project);
});
});
project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> {
JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
extension.withJavadocJar();
extension.withSourcesJar();
});
// @formatter:on
// J+
}
Aggregations