Hi - question about the wiremock-grpc extension. I...
# general
e
Hi - question about the wiremock-grpc extension. I’m including version 0.2.0 in my project
Copy code
<dependency>
		  <groupId>org.wiremock</groupId>
		  <artifactId>wiremock-grpc-extension</artifactId>
		  <version>${wiremock-grpc.version}</version>
		  <scope>test</scope>
	  </dependency>
but i’m finding that maven is complaining about a missing dependency:
Copy code
╰─ ./mvnw clean package -DskipTests -U
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------< io.quarkus.sample.super-heroes:rest-fights >-------------
[INFO] Building Quarkus Sample :: Super-Heroes :: Fights Microservice 1.0
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: <https://repo1.maven.org/maven2/io/grpc/grpc-bom/1.58.0/grpc-bom-1.58.0.jar>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.454 s
[INFO] Finished at: 2023-10-23T19:10:07-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project rest-fights: Could not resolve dependencies for project io.quarkus.sample.super-heroes:rest-fights:jar:1.0: The following artifacts could not be resolved: io.grpc:grpc-bom:jar:1.58.0 (absent): Could not find artifact io.grpc:grpc-bom:jar:1.58.0 in central (<https://repo1.maven.org/maven2/>) -> [Help 1]
When I look in maven central I don’t see a grpc-bom-1.58.0.jar artifact. I see a .pom artifact… https://repo1.maven.org/maven2/io/grpc/grpc-bom/1.58.0/grpc-bom-1.58.0.pom
t
This works OK with Gradle so I guess it’s an artefact of how Maven resolves dependencies, or your specific configuration. A BOM artifact should only have a POM file since it’s just a manifest. Are you on the latest version of Maven?
e
Copy code
╰─ ./mvnw --version                                        
Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Maven home: /Users/edeandre/.m2/wrapper/dists/apache-maven-3.9.3-bin/326f10f4/apache-maven-3.9.3
Java version: 17.0.8, vendor: Eclipse Adoptium, runtime: /Users/edeandre/.sdkman/candidates/java/17.0.8-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "14.0", arch: "aarch64", family: "mac"
i agree that a BOM artifact should only have a POM file
when I look at the
wiremock-grpc-extension
pom (https://central.sonatype.com/artifact/org.wiremock/wiremock-grpc-extension) it clearly defines a jar dependency on grpc-bom
it does not import the grpc-bom as a pom import
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="<http://maven.apache.org/POM/4.0.0>" xsi:schemaLocation="<http://maven.apache.org/POM/4.0.0> <https://maven.apache.org/xsd/maven-4.0.0.xsd>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.wiremock</groupId>
  <artifactId>wiremock-grpc-extension</artifactId>
  <version>0.2.0</version>
  <dependencies>
    <dependency>
      <groupId>org.wiremock</groupId>
      <artifactId>wiremock</artifactId>
      <version>3.2.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-bom</artifactId>
      <version>1.58.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
      <version>1.58.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-stub</artifactId>
      <version>1.58.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-servlet-jakarta</artifactId>
      <version>1.58.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java-util</artifactId>
      <version>3.24.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>1.3.2</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  <description>Mock gRPC services with WireMock</description>
  <name>WireMock Extension for gRPC</name>
  <url><https://wiremock.org></url>
  <scm>
    <connection><https://github.com/wiremock/wiremock-grpc-extension.git></connection>
    <developerConnection><https://github.com/wiremock/wiremock-grpc-extension.git></developerConnection>
    <url><https://github.com/wiremock/wiremock-grpc-extension></url>
  </scm>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url><http://www.apache.org/license/LICENSE-2.0.txt></url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>tomakehurst</id>
      <name>Tom Akehurst</name>
    </developer>
  </developers>
</project>
instead, it should have
Copy code
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-bom</artifactId>
      <version>1.58.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
I was able to work around this by doing this
Copy code
<dependency>
		  <groupId>org.wiremock</groupId>
		  <artifactId>wiremock-grpc-extension</artifactId>
		  <version>${wiremock-grpc.version}</version>
		  <scope>test</scope>
		  <exclusions>
			  <exclusion>
				  <groupId>io.grpc</groupId>
				  <artifactId>grpc-bom</artifactId>
			  </exclusion>
		  </exclusions>
	  </dependency>
i’ve excluded the grpc-bom, since its brought in already by other dependencies in my project
t
I guess we need to add some additional parameter/modifier to the gradle dependency to fix this at source, although I’m not sure what that is at the moment.
e
It’s because in the
build.gradle
file, the
grpc-bom
dependency is declared as
api "io.grpc:grpc-bom:$versions.grpc"
You could change the dependencies block to be this:
Copy code
api "org.wiremock:wiremock:$versions.wiremock"

  api platform("io.grpc:grpc-bom:$versions.grpc")
  api "io.grpc:grpc-protobuf"
  api "io.grpc:grpc-stub"

  implementation "io.grpc:grpc-servlet-jakarta"
  implementation "com.google.protobuf:protobuf-java-util:$versions.protobuf"

  implementation 'javax.annotation:javax.annotation-api:1.3.2'

  //  testImplementation project(":")
  testImplementation(platform('org.junit:junit-bom:5.10.0'))
  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"
And this would produce
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="<http://maven.apache.org/POM/4.0.0>" xsi:schemaLocation="<http://maven.apache.org/POM/4.0.0> <https://maven.apache.org/xsd/maven-4.0.0.xsd>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>">
  <!-- This module was also published with a richer model, Gradle metadata,  -->
  <!-- which should be used instead. Do not delete the following line which  -->
  <!-- is to indicate to Gradle or any Gradle module metadata file consumer  -->
  <!-- that they should prefer consuming it instead. -->
  <!-- do_not_remove: published-with-gradle-metadata -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.wiremock</groupId>
  <artifactId>wiremock-grpc-extension</artifactId>
  <version>0.1.0</version>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-bom</artifactId>
        <version>1.58.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.wiremock</groupId>
      <artifactId>wiremock</artifactId>
      <version>3.2.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-protobuf</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-stub</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-servlet-jakarta</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java-util</artifactId>
      <version>3.24.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <version>1.3.2</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  <description>Mock gRPC services with WireMock</description>
  <name>WireMock Extension for gRPC</name>
  <url><https://wiremock.org></url>
  <scm>
    <connection><https://github.com/wiremock/wiremock-grpc-extension.git></connection>
    <developerConnection><https://github.com/wiremock/wiremock-grpc-extension.git></developerConnection>
    <url><https://github.com/wiremock/wiremock-grpc-extension></url>
  </scm>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url><http://www.apache.org/license/LICENSE-2.0.txt></url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>tomakehurst</id>
      <name>Tom Akehurst</name>
    </developer>
  </developers>
</project>
I’m happy to do a pull request if you’d like
(I did run
./gradlew clean check
to make sure tests all still pass