Karate: com.intuit.karate:karate-netty:0.9.5 not in maven ?

Created on 18 Jun 2020  路  18Comments  路  Source: intuit/karate

I'm trying to use jbang.dev with karate and for that it would be great to have the Main class in a mvn repo.

It should be in com.intuit.karate:karate-netty according to metadata in the main karate jar, but but the latest release is com.intuit.karate:karate-netty:0.9.2

Can you help locate it ?

enhancement fixed

All 18 comments

fyi, see https://gist.github.com/maxandersen/7bc4e55467f48847167c94eb0be6b4c2 if interested in what I'm trying to do.

@maxandersen there is no more karate-netty it is part of karate-core

there is a main class here: https://github.com/intuit/karate/blob/master/karate-core/src/main/java/com/intuit/karate/cli/Main.java - but it may need karate-apache on the classpath

the karate.jar is not mavenized, that holds the "other" main class: https://github.com/intuit/karate/tree/master/karate-netty#standalone-jar

okey, just that the main jar comes out of karate-netty; and if you use this repo it is there.

But if you say karate-apache is the right one I'll use that instead :)

karate.cli.Main is not the same as the karate.Main that is used in karate.jar.

I still only see that in the karate-netty module here: https://github.com/intuit/karate/blob/master/karate-netty/src/main/java/com/intuit/karate/Main.java

@maxandersen it is 95% the same. eventually they will merge but it should work for what you are trying to do. karate.jar is not mavenized it is too big. if you want you can build it

did that help :| https://github.com/intuit/karate/wiki/Developer-Guide#build-standalone-jar-and-zip

well, I for now can just use jitpack to get it as a mvn dependency:

from https://gist.github.com/maxandersen/7bc4e55467f48847167c94eb0be6b4c2:

//REPOS jitpack
//DEPS com.github.intuit.karate:karate-netty:v0.9.5

is what I do for now to work around it since the two cli's are very different in behavior afaics.

@maxandersen yes I realized later that some more things are missing: e.g. mocks. those who use Java use the API and those who use the fatjar use the CLI

don't know much about jbang but you can write groovy-like code right ? for e.g. to start a mock: https://github.com/intuit/karate/tree/master/karate-netty#embedding

so something like this:

var file = new java.io.File(myFile)
var server = com.intuit.karate.netty.FeatureServer.start(file, 0, false, null);

feel free to submit a PR if you really want a better CLI ;) no one has requested yet

jbang (see https://jbang.dev) is to easily write and run java scripts/snippets.
I wasn't try to code against the karate api even though I could, but for now just wanted to making it easier to run karate ;)

For karate which is "just a jar" to run you could have a URL have the latest release containing:

//usr/bin/env jbang "$0" "$@" ; exit $?
//REPOS jitpack
//DEPS com.github.intuit.karate:karate-netty:v0.9.5
class karate {

public static void main(String... args) {
 com.intuit.karate.Main.main(args);
 }
 }

(could also use master or SNAPSHOT as version to get latest greatest)

and then you can just run:

jbang https://gist.github.com/maxandersen/7bc4e55467f48847167c94eb0be6b4c2 and skip a download step.

but I think I might just add jbang <url to jar> support to make this even easier :)

@maxandersen cool. yes url to jar sounds like a good idea !

@maxandersen max - we finally got rid of the extra CLI. there is only one artifact. karate-core everything is in this one dependency. hope you get a change to try it sometime, I don't think your existing tests would break, but in case: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

made change as per twitter discussion: https://twitter.com/maxandersen/status/1334826965577117699

fyi, with latest jbang install if you put a jbang-catalog.json into intuit/karate with alias for karate jar you can do things like:

curl -Ls https://sh.jbang.dev | bash -s - app setup; jbang app install karate@intuit/karate

this will have karate installed in path including downloading jbang + java if needed.

you could also make a intuit/jbang-catalog then the name would just be karate@intuit.

note, jbang app install --name karate http://com.intuit.karate:karate-core:0.9.9.RC1 works today.

@maxandersen that is awesome. I think the command above has a cut-and-paste error it should be (no http://)

jbang app install --name karate com.intuit.karate:karate-core:0.9.9.RC1

I started a new shell, but karate doesn't work, does it need the main-class manifest ? that will be in the next version

INTUL177117d7e:~ pthomas3$ jbang app install --name karate --verbose com.intuit.karate:karate-core:0.9.9.RC1
[jbang] Resolving dependencies...
[jbang]     Resolving com.intuit.karate:karate-core:0.9.9.RC1...Done
[jbang] Dependencies resolved
[jbang] Command installed: karate
[jbang] Added Jbang setup lines /Users/pthomas3/.bashrc
[jbang] Added Jbang setup lines /Users/pthomas3/.zshrc
[jbang] Setting up Jbang environment...
Please start a new Shell for changes to take effect

Yes, still need a main to be there :)

For people who would like to run karate mocks from within IDE like eclipse, it seems that com.intuit.karate.netty.Main or equivalent is needed so that one could run the MainRunner that starts the mock server. Then one can run karate tests against it. That way the feature does not know if it runs against mock or actual server. This is really useful when one is developing contract tests. @ptrthomas is this something we can hope for in the next release?

@xbranko this is done. try 0.9.9.RC2 and please look at this: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

Was this page helpful?
0 / 5 - 0 ratings