Skip to content

Commit 0458f15

Browse files
committed
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.
1 parent c43c0be commit 0458f15

File tree

5 files changed

+58
-21
lines changed

5 files changed

+58
-21
lines changed

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ext {
1212
description = "Spring for GraphQL"
1313

1414
subprojects {
15+
apply plugin: 'org.springframework.graphql.compiler'
16+
apply plugin: 'org.springframework.graphql.deployment'
17+
1518
group = 'org.springframework.graphql'
1619

1720
repositories {
@@ -28,7 +31,6 @@ subprojects {
2831
configure(moduleProjects) {
2932
apply plugin: 'java-library'
3033
apply plugin: 'java-test-fixtures'
31-
apply plugin: 'org.springframework.graphql.compiler'
3234

3335
java {
3436
toolchain {

buildSrc/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ gradlePlugin {
3030
id = "org.springframework.graphql.compiler"
3131
implementationClass = "org.springframework.graphql.build.compile.CompilerConventionsPlugin"
3232
}
33+
deploymentConventionsPlugin {
34+
id = "org.springframework.graphql.deployment"
35+
implementationClass = "org.springframework.graphql.build.deployment.DeploymentConventionsPlugin"
36+
}
3337
}
3438
}
3539

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2020-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.graphql.build.deployment;
18+
19+
import org.gradle.api.Plugin;
20+
import org.gradle.api.Project;
21+
import org.gradle.api.publish.PublishingExtension;
22+
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
23+
24+
/**
25+
* Convention that configures a local deployment Maven repository on the CI
26+
* so that the Concourse resource can later push it to a remote repository.
27+
*
28+
* @author Brian Clozel
29+
*/
30+
public class DeploymentConventionsPlugin implements Plugin<Project> {
31+
32+
@Override
33+
public void apply(Project project) {
34+
project.getPlugins().apply(MavenPublishPlugin.class);
35+
project.getPlugins().withType(MavenPublishPlugin.class).forEach((mavenPublishPlugin) -> {
36+
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
37+
if (project.hasProperty("deploymentRepository")) {
38+
publishing.getRepositories().maven((mavenArtifactRepository) -> {
39+
mavenArtifactRepository.setUrl(project.property("deploymentRepository"));
40+
mavenArtifactRepository.setName("deployment");
41+
});
42+
}
43+
});
44+
}
45+
}

gradle/publishing.gradle

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,3 @@ plugins.withType(JavaPlugin) {
101101
}
102102
}
103103
}
104-
105-
106-
configureDeploymentRepository(project)
107-
108-
void configureDeploymentRepository(Project project) {
109-
project.plugins.withType(MavenPublishPlugin.class).all {
110-
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
111-
if (project.hasProperty("deploymentRepository")) {
112-
publishing.repositories.maven {
113-
it.url = project.property("deploymentRepository")
114-
it.name = "deployment"
115-
}
116-
}
117-
}
118-
}

spring-graphql-docs/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ configurations {
99
asciidoctorExtensions
1010
}
1111

12+
dependencies {
13+
asciidoctorExtensions 'io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.2'
14+
}
15+
1216
jar {
1317
enabled = false
1418
}
@@ -17,9 +21,6 @@ javadoc {
1721
enabled = false
1822
}
1923

20-
dependencies {
21-
asciidoctorExtensions 'io.spring.asciidoctor.backends:spring-asciidoctor-backends:0.0.2'
22-
}
2324

2425
repositories {
2526
maven {
@@ -91,6 +92,8 @@ asciidoctor {
9192
'spring-boot-version': bootVersion
9293
}
9394

95+
asciidoctor.mustRunAfter "check"
96+
9497
/**
9598
* Zip all docs into a single archive
9699
*/
@@ -106,8 +109,6 @@ task docsZip(type: Zip, dependsOn: ['api', 'asciidoctor']) {
106109
}
107110
}
108111

109-
apply from: "${rootDir}/gradle/publishing.gradle"
110-
111112
publishing {
112113
publications {
113114
mavenJava(MavenPublication) {

0 commit comments

Comments
 (0)