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

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

Closed
maxandersen opened this issue Jun 18, 2020 · 19 comments
Closed

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

maxandersen opened this issue Jun 18, 2020 · 19 comments
Assignees

Comments

@maxandersen
Copy link
Contributor

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 ?

@maxandersen
Copy link
Contributor Author

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

@ptrthomas
Copy link
Member

@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

@maxandersen
Copy link
Contributor Author

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 :)

@maxandersen
Copy link
Contributor Author

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

@ptrthomas
Copy link
Member

@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

@ptrthomas
Copy link
Member

@maxandersen
Copy link
Contributor Author

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.

@ptrthomas
Copy link
Member

ptrthomas commented Jun 19, 2020

@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

@maxandersen
Copy link
Contributor Author

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 :)

@ptrthomas
Copy link
Member

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

@ptrthomas
Copy link
Member

@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

@ptrthomas ptrthomas reopened this Dec 4, 2020
ptrthomas added a commit that referenced this issue Dec 4, 2020
also cli can start an app server using our new stuff
@ptrthomas
Copy link
Member

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

@maxandersen
Copy link
Contributor Author

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.

@maxandersen
Copy link
Contributor Author

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

@ptrthomas
Copy link
Member

@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

@maxandersen
Copy link
Contributor Author

Yes, still need a main to be there :)

@xbranko
Copy link

xbranko commented Dec 28, 2020

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?

@ptrthomas
Copy link
Member

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

@ptrthomas
Copy link
Member

1.0 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants