Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to the Gradle extension plugin #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ tmp*
.idea

out
build
build
bin/
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

164 changes: 39 additions & 125 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to move it we should probably drop a tombstone on the old coordinates


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'
}
}
}
}
}

Expand Down Expand Up @@ -103,88 +64,16 @@ 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"
exceptionFormat "full"
}
}

assemble.dependsOn clean, jar

publishMainPublicationToMavenLocal.dependsOn jar
publishMainPublicationToGitHubPackagesRepository.dependsOn jar

task addGitTag {
doLast {
println "git tag ${version}".execute().text
Expand Down Expand Up @@ -217,23 +106,48 @@ 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
}
}
}

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'))
}
}
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions settings.gradle

This file was deleted.

Loading
Loading