Skip to content

Commit

Permalink
Refactor Gradle build
Browse files Browse the repository at this point in the history
This commit refactors the Gradle build with the following:

* use of the dependency management plugin
* import the Spring Boot BOM for dependency management
* add support for publishing artifacts
  • Loading branch information
bclozel committed Sep 15, 2020
1 parent 5741e3f commit 06f91d0
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 99 deletions.
88 changes: 37 additions & 51 deletions build.gradle
@@ -1,54 +1,40 @@
import java.text.SimpleDateFormat

subprojects {

apply plugin: 'java'
apply plugin: 'maven'


sourceCompatibility = 1.8
targetCompatibility = 1.8
version = "0.1"
group = 'org.springframework'

ext {
graphqlJavaVersion = "15.0"
springVersion = "5.2.8.RELEASE"
springBootVersion = "2.3.2.RELEASE"
jacksonVersion = "2.9.8"
assertJVersion = "3.16.1"
}

repositories {
mavenCentral()
mavenLocal()
}

task sourcesJar(type: Jar) {
dependsOn classes
classifier 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

javadoc {
options.encoding = 'UTF-8'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE' apply false
}

task myWrapper(type: Wrapper) {
gradleVersion = '6.5.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
subprojects {
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven'

group = 'org.springframework.experimental'
version = "0.1.0-SNAPSHOT"
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
dependencies {
dependency 'com.graphql-java:graphql-java:15.0'
}
}

dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

apply from: "${rootDir}/gradle/publishing.gradle"
}

104 changes: 104 additions & 0 deletions gradle/publishing.gradle
@@ -0,0 +1,104 @@
apply plugin: "maven-publish"

javadoc {
description = "Generates project-level javadoc for use in -javadoc jar"

options.encoding = "UTF-8"
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = project.name
options.use = true
options.addStringOption("Xdoclint:none", "-quiet")

// Suppress warnings due to cross-module @see and @link references.
// Note that global 'api' task does display all warnings.
logging.captureStandardError LogLevel.INFO
logging.captureStandardOutput LogLevel.INFO // suppress "## warnings" message
}

task sourcesJar(type: Jar, dependsOn: classes) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

task javadocJar(type: Jar) {
archiveClassifier.set("javadoc")
from javadoc
}

publishing {
publications {
mavenJava(MavenPublication) {
pom {
afterEvaluate {
name = project.description
description = project.description
}
url = "https://github.com/spring-projects-experimental/spring-graphql"
organization {
name = "Spring IO"
url = "https://spring.io/projects"
}
licenses {
license {
name = "Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0"
distribution = "repo"
}
}
scm {
url = "https://github.com/spring-projects-experimental/spring-graphql"
connection = "scm:git:git://github.com/spring-projects-experimental/spring-graphql"
developerConnection = "scm:git:git://github.com/spring-projects-experimental/spring-graphql"
}
developers {
developer {
id = "andimarek"
name = "Andi Marek"
email = "andimarek@fastmail.fm"
}
developer {
id = "rstoyanchev"
name = "Rossen Stoyanchev"
email = "rstoyanchev@vmware.com"
}
developer {
id = "bclozel"
name = "Brian Clozel"
email = "bclozel@vmware.com"
}
}
issueManagement {
system = "GitHub"
url = "https://github.com/spring-projects-experimental/spring-graphql/issues"
}
}
versionMapping {
usage('java-api') {
fromResolutionResult()
}
usage('java-runtime') {
fromResolutionResult()
}
}
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}

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"
}
}
}
}
10 changes: 5 additions & 5 deletions spring-graphql-boot-starter-webflux/build.gradle
@@ -1,9 +1,9 @@
description = "GraphQL Java Spring Boot starter Webmvc"
description = "Starter for building GraphQL Java applications with Spring WebFlux"

dependencies {
implementation "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
implementation project(':spring-graphql-webflux')
implementation 'org.springframework.boot:spring-boot-autoconfigure'

testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "org.springframework.boot:spring-boot-starter-webflux:$springBootVersion"

testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.springframework.boot:spring-boot-starter-webflux'
}
9 changes: 5 additions & 4 deletions spring-graphql-boot-starter-webmvc/build.gradle
@@ -1,8 +1,9 @@
description = "GraphQL Java Spring Boot starter Webmvc"
description = "Starter for building GraphQL Java applications with Spring WebFlux"

dependencies {
implementation "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
implementation project(':spring-graphql-webmvc')
implementation 'org.springframework.boot:spring-boot-autoconfigure'

testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.springframework.boot:spring-boot-starter-web'
}
16 changes: 4 additions & 12 deletions spring-graphql-common/build.gradle
@@ -1,15 +1,7 @@
description = "GraphQL Java Spring Common"

apply plugin: 'java-library'
description = "Common module for GraphQL Java Spring support"

dependencies {
implementation "org.springframework:spring-web:$springVersion"
api 'io.projectreactor:reactor-core:3.3.8.RELEASE'
api "com.graphql-java:graphql-java:$graphqlJavaVersion"

testImplementation("org.assertj:assertj-core:$assertJVersion")
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testImplementation "org.springframework:spring-test:$springVersion"
testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'
testImplementation "org.mockito:mockito-core:2.+"
api 'io.projectreactor:reactor-core'
api "com.graphql-java:graphql-java"
implementation "org.springframework:spring-web"
}
19 changes: 6 additions & 13 deletions spring-graphql-webflux/build.gradle
@@ -1,17 +1,10 @@
description = "GraphQL Java Spring Webmvc integration"

apply plugin: 'java-library'
description = "GraphQL Java Spring WebFlux integration"

dependencies {
implementation "org.springframework:spring-webflux:$springVersion"
implementation "org.springframework:spring-context:$springVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
api "com.graphql-java:graphql-java:$graphqlJavaVersion"
implementation project(':spring-graphql-common')
api 'com.graphql-java:graphql-java'

testImplementation("org.assertj:assertj-core:$assertJVersion")
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testImplementation "org.springframework:spring-test:$springVersion"
testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'
testImplementation "org.mockito:mockito-core:2.+"
implementation project(':spring-graphql-common')
implementation 'org.springframework:spring-context'
implementation 'org.springframework:spring-webflux'
implementation 'com.fasterxml.jackson.core:jackson-databind'
}
20 changes: 6 additions & 14 deletions spring-graphql-webmvc/build.gradle
@@ -1,18 +1,10 @@
description = "GraphQL Java Spring Webmvc integration"

apply plugin: 'java-library'
description = "GraphQL Java Spring MVC integration"

dependencies {
implementation "org.springframework:spring-webmvc:$springVersion"
implementation "org.springframework:spring-context:$springVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
api "com.graphql-java:graphql-java:$graphqlJavaVersion"
implementation project(':spring-graphql-common')
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
api 'com.graphql-java:graphql-java'

testImplementation("org.assertj:assertj-core:$assertJVersion")
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testImplementation "org.springframework:spring-test:$springVersion"
testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'
testImplementation "org.mockito:mockito-core:2.+"
implementation project(':spring-graphql-common')
implementation 'org.springframework:spring-webmvc'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'javax.servlet:javax.servlet-api'
}

0 comments on commit 06f91d0

Please sign in to comment.