Hello, I need to start a wm server using standalo...
# help
r
Hello, I need to start a wm server using standalone jar, along with it I have to add the behavior of wm extensions to the same server. But I cannot use custom extension jar as the remote machine I am using doesn't allow custom jars to be stored in it for security reasons. I'm currently exploring the ways to add extensions without using the jar (by using .class files or something) Can someone help me with this?
t
You can apply extensions as long as they’re on the classpath, so in principle you could compile your extension to a folder full of .class files and then include those in the classpath when you start WireMock from the command line.
t
i'm also exploring something similar and am a bit confused. looking at the test extension, is it possible to compile a standalone jar with custom extensions that reference the necessary wiremock
interface
types, and then run the wiremock standalone jar & extension jar together? is there a different approach that makes more sense?
t
Yes, you can also build your own JAR with the extensions in it
t
ahh great! i'm not a java developer typically, so forgive me a couple rudimentary questions. 1. how would the extension jar import that wiremock interfaces? would i include wiremock as a depenedency in the gradle file? 2. how is the extension jar linked into the execution of the standalone? would it mean running something like:
java -jar wiremock.jar -cp extensions.jar
(and also not using the npm package)?
t
1. Yes, you can create an extension project with WireMock as its compile-time dependency. Here’s an example project: https://github.com/wiremock/wiremock-jwt-extension 2. You need to add the WireMock JAR and your extension JAR to the classpath and run the entrypoint class, like this:
Copy code
java -cp wiremock-standalone-3.13.0.jar:my-extension.jar wiremock.Run [WireMock CLI parameters]
t
gotcha thanks =) i'll give that a shot. hope you have a good sunday!
👍 1