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

Cannot run after using Gradle to build jar file. #66

Closed
doggie1989 opened this issue May 31, 2016 · 8 comments
Closed

Cannot run after using Gradle to build jar file. #66

doggie1989 opened this issue May 31, 2016 · 8 comments
Labels

Comments

@doggie1989
Copy link

No description provided.

@nmihajlovski
Copy link
Contributor

Can you please provide more context/information?

@doggie1989
Copy link
Author

@nmihajlovski
I can run in eclipse via main(),but after I build a jar, I could not run it.

@wmacgyver
Copy link

@doggie1989 are you using gradle's shadow plugin to build a uberjar? because I just tried it and it's working for me

@doggie1989
Copy link
Author

@wmacgyver
Hi Mate,Could you share the build.gradle file?
I was using gradle 'jar' plugin and build cmd.

@wmacgyver
Copy link

wmacgyver commented Jun 12, 2016

@doggie1989 ah yea, that won't work. because rapidoid comes with embedded server, so you have to run it as a uber jar.

here is my build.gradle

plugins {
    id 'com.github.johnrengelman.shadow' version '1.2.3'
}

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'my.app.Main'

repositories {
    mavenCentral()
}

dependencies {
    def rapidoidVersion = '5.1.4'
    def slf4jVersion = '1.7.21'

    compile "org.rapidoid:rapidoid-http-server:${rapidoidVersion}"
    compileOnly "org.rapidoid:rapidoid-watch:${rapidoidVersion}"
    runtime "org.slf4j:slf4j-simple:${slf4jVersion}"
}

you build the uber jar by doing gradle shadow, it will produce a uber jar in build/libs. when you do jar -jar foo.jar. it will run the class my.app.main as I defined here.

@doggie1989
Copy link
Author

@wmacgyver

Thanks brother.
All working well now!!!

I am migrating my app from spring boot...

@wmacgyver
Copy link

@doggie1989 yea, you didn't have to do this with spring boot for gradle because the spring boot plugin extends application. so it's silently doing it in the background as magic if you will. we too have moved from spring boot.

@doggie1989 doggie1989 reopened this Nov 11, 2016
@doggie1989
Copy link
Author

@wmacgyver hi mate, now I have some static files in static folder, when I start Rapidoid in eclipse,it works,but it does not work after packing it and run via java -jar...it looks that the static files have not ben packed into jar...do you know how to solve it?

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

No branches or pull requests

3 participants