Move deployment repository config to a Gradle convention

This commit moves the configuration of a local Maven deployment
repository in a dedicated Gradle convention and applies it to all
sub-projects. This separates the publishing configuration for actual
project modules (that are meant to be published on Maven Central) from
the infrastructure sub-projects such as the documentation one.
This commit is contained in:
Brian Clozel
2022-12-06 11:23:39 +01:00
parent c43c0bec2e
commit 0458f15ddd
5 changed files with 58 additions and 21 deletions

View File

@@ -12,6 +12,9 @@ ext {
description = "Spring for GraphQL"
subprojects {
apply plugin: 'org.springframework.graphql.compiler'
apply plugin: 'org.springframework.graphql.deployment'
group = 'org.springframework.graphql'
repositories {
@@ -28,7 +31,6 @@ subprojects {
configure(moduleProjects) {
apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
apply plugin: 'org.springframework.graphql.compiler'
java {
toolchain {

View File

@@ -30,6 +30,10 @@ gradlePlugin {
id = "org.springframework.graphql.compiler"
implementationClass = "org.springframework.graphql.build.compile.CompilerConventionsPlugin"
}
deploymentConventionsPlugin {
id = "org.springframework.graphql.deployment"
implementationClass = "org.springframework.graphql.build.deployment.DeploymentConventionsPlugin"
}
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2020-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.graphql.build.deployment;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
/**
* Convention that configures a local deployment Maven repository on the CI
* so that the Concourse resource can later push it to a remote repository.
*
* @author Brian Clozel
*/
public class DeploymentConventionsPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getPlugins().apply(MavenPublishPlugin.class);
project.getPlugins().withType(MavenPublishPlugin.class).forEach((mavenPublishPlugin) -> {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
if (project.hasProperty("deploymentRepository")) {
publishing.getRepositories().maven((mavenArtifactRepository) -> {
mavenArtifactRepository.setUrl(project.property("deploymentRepository"));
mavenArtifactRepository.setName("deployment");
});
}
});
}
}

View File

@@ -101,18 +101,3 @@ plugins.withType(JavaPlugin) {
}
}
}
configureDeploymentRepository(project)
void configureDeploymentRepository(Project project) {
project.plugins.withType(MavenPublishPlugin.class).all {
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
if (project.hasProperty("deploymentRepository")) {
publishing.repositories.maven {
it.url = project.property("deploymentRepository")
it.name = "deployment"
}
}
}
}

View File

@@ -9,6 +9,10 @@ configurations {
asciidoctorExtensions
}
dependencies {
asciidoctorExtensions 'io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.2'
}
jar {
enabled = false
}
@@ -17,9 +21,6 @@ javadoc {
enabled = false
}
dependencies {
asciidoctorExtensions 'io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.2'
}
repositories {
maven {
@@ -91,6 +92,8 @@ asciidoctor {
'spring-boot-version': bootVersion
}
asciidoctor.mustRunAfter "check"
/**
* Zip all docs into a single archive
*/
@@ -106,8 +109,6 @@ task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor']) {
}
}
apply from: "${rootDir}/gradle/publishing.gradle"
publishing {
publications {
mavenJava(MavenPublication) {