-1

2 hours ago, I ws working a java (gradle) project which needed jgit. I aded it in my build.gradle, ran ./gradlew build, and tried to java -jar the build output. It does not work anymore, but removing the dependency makes it work again. Note that it compile without errors. Here is my build.gradle if it can help. https://gist.github.com/Fungie2134/cb81cd1bd7d767d4d1f5d6317e71665d

Aang23
  • 11
  • 6

2 Answers2

1

you might be lacking the repository configuration for Maven Central:

repositories {
    jcenter()

    // add this one:
    mavenCentral()

    maven { url "https://jitpack.io" }
}

please add further details (relevant error logs), in case this should not answer the question.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • Thanks for the answer ! But unfortunately it did not work. But when using the Eclipse or Intellij compiler, no issues. Here is the only error I got : https://gist.github.com/Fungie2134/e7457d57356631de105cb8b2f172c2d5 – Aang23 Aug 05 '18 at 16:08
  • @AAng23 please add the log from the console; else this is guessing around. – Martin Zeitler Aug 05 '18 at 16:12
  • I have just added the only ones I got here : https://gist.github.com/Fungie2134/e7457d57356631de105cb8b2f172c2d5 There is no said error unless the java -jar one. – Aang23 Aug 05 '18 at 16:13
  • @AAng23 this answer explains how such launcher class should look alike: https://stackoverflow.com/a/26532803/549372 – Martin Zeitler Aug 05 '18 at 16:13
  • It is already like this one (https://gist.github.com/Fungie2134/3b2e1fbaea70aaea69996e679552f329). It works fines with Eclipse's compiler, and works with gradle when the Jgit dependency is not declared. – Aang23 Aug 05 '18 at 16:15
  • you might not have the launcher in the expected location, which may be `src/main/{packageName}/`... `main/Launcher.class` (do not confuse the one `main` which refers to the source-set with the other `main`, which refers to a package-name). – Martin Zeitler Aug 05 '18 at 16:27
  • Fixed. Thanks for you help tough. – Aang23 Aug 05 '18 at 16:31
0

I have found the problem. The way I was making my fat jar was wrong. Using this

configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }

with this kind of libraries happens to prevent the .jar creation to be done correctly. The solution was to use Shadow . Now the jar creation is done by ./gradlew shadowJar and the jar is named Launcher-all.jar

Aang23
  • 11
  • 6