diff --git a/.gitignore b/.gitignore index e7222d0..12653e2 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ tmp* .idea out -build \ No newline at end of file +build +bin/ diff --git a/README.md b/README.md index 827291b..8ee2bb6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,10 @@ all of WireMock’s response definition features including Templating can be use ![gRPC Mocking Schema](./docs/images/intro_schema.png) -The extension is distributed through Maven Central: `org.wiremock:grpc-extension` +The extension is distributed through Maven Central: + +> **NOTE:** in the 0.5.0 release the artifact name was changed from `org.wiremock.extensions:wiremock-grpc-extension` +> to comply with the Extension naming recommendations ## Examples @@ -25,4 +28,3 @@ See [wiremock/wiremock-grpc-demos](https://github.com/wiremock/wiremock-grpc-dem ## Read More See [the documentation](https://wiremock.org/docs/grpc/) for more information. - diff --git a/build.gradle b/build.gradle index 622c98a..4e8484f 100644 --- a/build.gradle +++ b/build.gradle @@ -8,62 +8,23 @@ buildscript { } plugins { - id 'java-library' - id 'signing' - id 'maven-publish' - id 'idea' id 'eclipse' id 'project-report' id 'com.diffplug.spotless' version '6.22.0' id "com.google.protobuf" version "0.9.4" - id 'io.github.gradle-nexus.publish-plugin' version "1.3.0" + id 'org.wiremock.tools.gradle.wiremock-extension-convention' version '0.1.2' } -repositories { - mavenLocal() - mavenCentral() -} - -group 'org.wiremock' +group 'org.wiremock.extensions' allprojects { - version = "0.4.0" - - sourceCompatibility = 11 - targetCompatibility = 11 ext { versions = [ - wiremock: "3.2.0", + wiremock: "3.3.1", grpc : "1.59.0", protobuf: "3.25.0" ] - - repoUser = this.hasProperty('sonatypeUser') ? sonatypeUser : 'default' - repoPassword = this.hasProperty('sonatypePassword') ? sonatypePassword : 'default' - - pomInfo = { - name 'WireMock Extension for gRPC' - url 'https://wiremock.org' - scm { - connection 'https://github.com/wiremock/wiremock-grpc-extension.git' - developerConnection 'https://github.com/wiremock/wiremock-grpc-extension.git' - url 'https://github.com/wiremock/wiremock-grpc-extension' - } - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/license/LICENSE-2.0.txt' - distribution 'repo' - } - } - developers { - developer { - id 'tomakehurst' - name 'Tom Akehurst' - } - } - } } } @@ -103,76 +64,9 @@ dependencies { implementation 'javax.annotation:javax.annotation-api:1.3.2' - // testImplementation project(":") - testImplementation(platform('org.junit:junit-bom:5.10.1')) - testImplementation "org.junit.jupiter:junit-jupiter" - testImplementation "org.hamcrest:hamcrest-core:2.2" - testImplementation "org.hamcrest:hamcrest-library:2.2" - testImplementation 'org.awaitility:awaitility:4.2.0' - testImplementation "io.grpc:grpc-okhttp" } -task sourcesJar(type: Jar, dependsOn: classes) { - archiveClassifier.set('sources') - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - archiveClassifier.set('javadoc') - from javadoc.destinationDir -} - -task testJar(type: Jar, dependsOn: testClasses) { - archiveClassifier.set('tests') - from sourceSets.test.output -} - -signing { - // Docs: https://github.com/wiremock/community/blob/main/infra/maven-central.md - required { - !version.toString().contains("SNAPSHOT") && (gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("publish") || gradle.taskGraph.hasTask("publishToMavenLocal")) - } - def signingKey = providers.environmentVariable("OSSRH_GPG_SECRET_KEY").orElse("").get() - def signingPassphrase = providers.environmentVariable("OSSRH_GPG_SECRET_KEY_PASSWORD").orElse("").get() - if (!signingKey.isEmpty() && !signingPassphrase.isEmpty()) { - println "Using PGP key from env vars" - useInMemoryPgpKeys(signingKey, signingPassphrase) - } else { - println "Using default PGP key" - } - - sign(publishing.publications) -} - -publishing { - repositories { - maven { - name = "GitHubPackages" - url = "https://maven.pkg.github.com/wiremock/wiremock-grpc-extension" - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } - } - } - - publications { - main(MavenPublication) { publication -> - from components.java - artifact sourcesJar - artifact javadocJar - artifact testJar - - pom.packaging 'jar' - pom.withXml { - asNode().appendNode('description', 'Mock gRPC services with WireMock') - asNode().children().last() + pomInfo - } - } - } -} - test { testLogging { events "PASSED", "FAILED", "SKIPPED" @@ -180,11 +74,6 @@ test { } } -assemble.dependsOn clean, jar - -publishMainPublicationToMavenLocal.dependsOn jar -publishMainPublicationToGitHubPackagesRepository.dependsOn jar - task addGitTag { doLast { println "git tag ${version}".execute().text @@ -217,6 +106,7 @@ protobuf { task.generateDescriptorSet = true task.descriptorSetOptions.path = "$projectDir/src/test/resources/wiremock/grpc/services.dsc" task.descriptorSetOptions.includeImports = true + // NOTE: Shadow does not set it } } } @@ -224,16 +114,40 @@ protobuf { processTestResources.dependsOn generateProto processTestResources.dependsOn generateTestProto -nexusPublishing { - // See https://github.com/wiremock/community/blob/main/infra/maven-central.md - repositories { - sonatype { - def envUsername = providers.environmentVariable("OSSRH_USERNAME").orElse("").get() - def envPassword = providers.environmentVariable("OSSRH_TOKEN").orElse("").get() - if (!envUsername.isEmpty() && !envPassword.isEmpty()) { - username.set(envUsername) - password.set(envPassword) - } - } +shadowJar { + relocate "io.grpc", 'wiremock.grpc.io.grpc' + relocate "io.perfmark", 'wiremock.grpc.io.perfmark' + + relocate "org.mortbay", 'wiremock.org.mortbay' + relocate "org.eclipse", 'wiremock.org.eclipse' + relocate "org.codehaus", 'wiremock.org.codehaus' + relocate "com.google", 'wiremock.com.google' + relocate "com.google.thirdparty", 'wiremock.com.google.thirdparty' + relocate "com.fasterxml.jackson", 'wiremock.com.fasterxml.jackson' + relocate "org.apache", 'wiremock.org.apache' + relocate "org.xmlunit", 'wiremock.org.xmlunit' + relocate "org.hamcrest", 'wiremock.org.hamcrest' + relocate "org.skyscreamer", 'wiremock.org.skyscreamer' + relocate "org.json", 'wiremock.org.json' + relocate "net.minidev", 'wiremock.net.minidev' + relocate "com.jayway", 'wiremock.com.jayway' + relocate "org.objectweb", 'wiremock.org.objectweb' + relocate "org.custommonkey", "wiremock.org.custommonkey" + relocate "net.javacrumbs", "wiremock.net.javacrumbs" + relocate "net.sf", "wiremock.net.sf" + relocate "com.github.jknack", "wiremock.com.github.jknack" + relocate "org.antlr", "wiremock.org.antlr" + relocate "jakarta.servlet", "wiremock.jakarta.servlet" + relocate "org.checkerframework", "wiremock.org.checkerframework" + relocate "org.hamcrest", "wiremock.org.hamcrest" + relocate "org.slf4j", "wiremock.org.slf4j" + relocate "joptsimple", "wiremock.joptsimple" + exclude 'joptsimple/HelpFormatterMessages.properties' + relocate "org.yaml", "wiremock.org.yaml" + relocate "com.ethlo", "wiremock.com.ethlo" + relocate "com.networknt", "wiremock.com.networknt" + + dependencies { + exclude(dependency('org.slf4j:slf4j-api')) } } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..c344702 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,7 @@ +baseArtifact=wiremock-grpc-extension +version=0.5.0-SNAPSHOT +description=This extension allows you to use WireMock to mock gRPC services +githubRepo=wiremock-grpc-extension +developer.id=tomakehurst +developer.name=Tom Akehurst +developer.email=N/A diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fc10b60..3499ded 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 820a9dc..0000000 --- a/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = 'wiremock-grpc-extension' - -include 'wiremock-grpc-extension-standalone' diff --git a/wiremock-grpc-extension-standalone/build.gradle b/wiremock-grpc-extension-standalone/build.gradle deleted file mode 100644 index 8ea1bf2..0000000 --- a/wiremock-grpc-extension-standalone/build.gradle +++ /dev/null @@ -1,175 +0,0 @@ -buildscript { - repositories { - maven { - url "https://oss.sonatype.org" - } - mavenCentral() - } -} - -plugins { - id 'java-library' - id 'signing' - id 'maven-publish' - id 'idea' - id 'eclipse' - id 'project-report' - id 'com.diffplug.spotless' version '6.22.0' - id 'com.github.johnrengelman.shadow' version '8.1.1' - id "com.google.protobuf" version "0.9.4" -} - -repositories { - mavenLocal() - mavenCentral() -} - -group 'org.wiremock' - -dependencies { - api project(":") -} - -task sourcesJar(type: Jar, dependsOn: classes) { - archiveClassifier.set('sources') - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - archiveClassifier.set('javadoc') - from javadoc.destinationDir -} - -task testJar(type: Jar, dependsOn: testClasses) { - archiveClassifier.set('tests') - from sourceSets.test.output -} - -publishing { - repositories { - maven { - name = "GitHubPackages" - url = "https://maven.pkg.github.com/wiremock/wiremock-grpc-extension" - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } - } - } - - publications { - standalone(MavenPublication) { publication -> - artifactId = "${jar.getArchiveBaseName().get()}" - - artifact shadowJar - artifact sourcesJar - artifact javadocJar - artifact testJar - - pom.packaging 'jar' - pom.withXml { - asNode().appendNode('description', 'Mock gRPC services with WireMock standalone') - asNode().children().last() + pomInfo - } - } - } -} - -signing { - // Docs: https://github.com/wiremock/community/blob/main/infra/maven-central.md - required { - !version.toString().contains("SNAPSHOT") && (gradle.taskGraph.hasTask("uploadArchives") || gradle.taskGraph.hasTask("publish") || gradle.taskGraph.hasTask("publishToMavenLocal")) - } - def signingKey = providers.environmentVariable("OSSRH_GPG_SECRET_KEY").orElse("").get() - def signingPassphrase = providers.environmentVariable("OSSRH_GPG_SECRET_KEY_PASSWORD").orElse("").get() - if (!signingKey.isEmpty() && !signingPassphrase.isEmpty()) { - println "Using PGP key from env vars" - useInMemoryPgpKeys(signingKey, signingPassphrase) - } else { - println "Using default PGP key" - } - - sign publishing.publications -} - -assemble.dependsOn clean, shadowJar - -signStandalonePublication.dependsOn shadowJar -publishStandalonePublicationToMavenLocal.dependsOn signStandalonePublication -publishStandalonePublicationToGitHubPackagesRepository.dependsOn signStandalonePublication -publishStandalonePublicationToSonatypeRepository.dependsOn signStandalonePublication - - -task localRelease { - dependsOn clean, assemble, publishToMavenLocal -} - -tasks.findAll { it.name == 'jar' }.each { it.enabled = false } - -shadowJar { - archiveBaseName.set('wiremock-grpc-extension-standalone') - archiveClassifier = null - - relocate "io.grpc", 'wiremock.grpc.io.grpc' - relocate "io.perfmark", 'wiremock.grpc.io.perfmark' - - relocate "org.mortbay", 'wiremock.org.mortbay' - relocate "org.eclipse", 'wiremock.org.eclipse' - relocate "org.codehaus", 'wiremock.org.codehaus' - relocate "com.google", 'wiremock.com.google' - relocate "com.google.thirdparty", 'wiremock.com.google.thirdparty' - relocate "com.fasterxml.jackson", 'wiremock.com.fasterxml.jackson' - relocate "org.apache", 'wiremock.org.apache' - relocate "org.xmlunit", 'wiremock.org.xmlunit' - relocate "org.hamcrest", 'wiremock.org.hamcrest' - relocate "org.skyscreamer", 'wiremock.org.skyscreamer' - relocate "org.json", 'wiremock.org.json' - relocate "net.minidev", 'wiremock.net.minidev' - relocate "com.jayway", 'wiremock.com.jayway' - relocate "org.objectweb", 'wiremock.org.objectweb' - relocate "org.custommonkey", "wiremock.org.custommonkey" - relocate "net.javacrumbs", "wiremock.net.javacrumbs" - relocate "net.sf", "wiremock.net.sf" - relocate "com.github.jknack", "wiremock.com.github.jknack" - relocate "org.antlr", "wiremock.org.antlr" - relocate "jakarta.servlet", "wiremock.jakarta.servlet" - relocate "org.checkerframework", "wiremock.org.checkerframework" - relocate "org.hamcrest", "wiremock.org.hamcrest" - relocate "org.slf4j", "wiremock.org.slf4j" - relocate "joptsimple", "wiremock.joptsimple" - exclude 'joptsimple/HelpFormatterMessages.properties' - relocate "org.yaml", "wiremock.org.yaml" - relocate "com.ethlo", "wiremock.com.ethlo" - relocate "com.networknt", "wiremock.com.networknt" - - dependencies { - exclude(dependency('org.slf4j:slf4j-api')) - } -} - -protobuf { - protoc { - artifact = "com.google.protobuf:protoc:3.25.0" - } - - plugins { - grpc { - artifact = "io.grpc:protoc-gen-grpc-java:$versions.grpc" - } - } - generateProtoTasks { - all()*.plugins { - grpc { - outputSubDir = 'java' - } - } - - all().each { task -> - task.generateDescriptorSet = true - task.descriptorSetOptions.path = "$projectDir/src/test/resources/wiremock/grpc/services.dsc" - } - } -} - -processTestResources.dependsOn generateProto -processTestResources.dependsOn generateTestProto