Convert Gradle plugin from Groovy to Java (#1480)

* Migrate ContractsCopyTask from Groovy to Java

* Convert code to Java

* Refactor ContractsCopyTask

* Migrate GenerateClientStubsFromDslTask from Groovy to Java.

* Refactor GenerateClientStubsFromDslTask

* Clean up configuration of stubsJar

* Migrate GenerateServerTestsTask from Groovy to Java

* Refactor GenerateServerTestsTask

* Migrate PublishStubsToScmTask from Groovy to Java

* Refactor PublishStubsToScmTask

* Remove dead code

* Add additional test to ensure merged contract repository settings works the same as it did before. Add .get() calls to trigger task configuration otherwise, we can miss errors with task configuration.

* Fixup all visibility modifiers and drop any deprecated functionality

* Migrate plugin from Groovy to Java

* Refactor plugin from Groovy to Java

* Fixup project.version where it might not be correctly available yet

* Fix tests that were broken

* Fix functional testing that was failing

* Update functional tests to ensure that up-to-date checks are running as expected

* Added comment around deleteStubsAfterTest in each of the tasks where it is used, to remind editors what the property is for.

* Enable support for build cache

* Reconcile documentation with code

* Remove TODO that has been answered

* Add documentation on how to customize the verifierStubsJar

* Fix failing test

* Allow contractsDirectory to be null

* Fix failing tests

* Move all main source code to java source set
This commit is contained in:
Shannon Pamperl
2020-10-02 10:39:53 -05:00
committed by GitHub
parent b12fc7ae32
commit e91b91efba
25 changed files with 1724 additions and 1460 deletions

View File

@@ -81,7 +81,7 @@ dependencies {
}
}
test {
contractTest {
useJUnitPlatform()
systemProperty 'spring.profiles.active', 'gradle'
testLogging {
@@ -97,6 +97,25 @@ test {
}
}
publishing {
publications {
maven(MavenPublication) {
artifact bootJar
artifact verifierStubsJar
// https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/273
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
clean.doFirst {
delete "~/.m2/repository/com/example/http-server-dsl-gradle"
}

View File

@@ -4,7 +4,6 @@ plugins {
id "io.spring.dependency-management"
id "maven-publish"
id "maven"
id "org.springframework.cloud.contract"
}
group = 'com.example'
@@ -36,10 +35,6 @@ dependencies {
testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock'
}
contracts {
failOnNoContracts = false
}
test {
useJUnitPlatform()
systemProperty 'spring.profiles.active', 'gradle'
@@ -83,6 +78,25 @@ task copyClasses(type: Copy) {
into "${project.buildDir}/stubs/"
}
publishing {
publications {
maven(MavenPublication) {
artifact bootJar
artifact stubsJar
// https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/273
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
clean.doFirst {
delete 'target/snippets/stubs'
delete "~/.m2/repository/com/example/http-server-restdocs-gradle"