Ezwen/bandcamp-collection-downloader

Issue running jar after build

metric152 opened this issue · 13 comments

I'm building this on mac 10.15. I've downloaded gradle via brew and ran the build script.

I get this error when trying to just run the built jar.

Error: Could not find or load main class bandcampcollectiondownloader.MainKt
Ezwen commented

Thanks for the report! To better investigate, can you if possible give:

  • the gradle version and the java version you are using?
  • the exact build command you are running, and the logs produced by the command?
  • the exact command you are using to run the jar?

Gradle version

------------------------------------------------------------
Gradle 6.8
------------------------------------------------------------

Build time:   2021-01-08 16:38:46 UTC
Revision:     b7e82460c5373e194fb478a998c4fcfe7da53a7e

Kotlin:       1.4.20
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.9 (Oracle Corporation 11.0.9+11)
OS:           Mac OS X 10.15.7 x86_64

Build command

gradle fatJar

CLI command

java -jar ./bandcamp-collection-downloader.jar --cookies-file=cookies.json --download-folder=~/Downloads/bc-lib/ ernest

CLI result

C02C413BMD6N:libs eleitch$ java -jar bandcamp-collection-downloader.jar 
Error: Could not find or load main class bandcampcollectiondownloader.MainKt
Caused by: java.lang.ClassNotFoundException: bandcampcollectiondownloader.MainKt

The cli command worked when I downloaded the compiled jar.

Ezwen commented

Thank you! Can you also share the textual output you obtain after running the build command?

C02C413BMD6N:bandcamp-collection-downloader eleitch$ gradle fatJar
Starting a Gradle Daemon (subsequent builds will be faster)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 12s
2 actionable tasks: 2 executed

with --warning-mode all

C02C413BMD6N:bandcamp-collection-downloader eleitch$ gradle fatJar --warning-mode all

> Configure project :
The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the implementation configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.8/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
        at build_dcwbgvzi0z17chloqbybue81t$_run_closure3.doCall(/Users/eleitch/tmp/bandcamp-collection-downloader/build.gradle:13)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The testCompile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the testImplementation configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.8/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
        at build_dcwbgvzi0z17chloqbybue81t$_run_closure3.doCall(/Users/eleitch/tmp/bandcamp-collection-downloader/build.gradle:22)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The testRuntime configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the testRuntimeOnly configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.8/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
        at build_dcwbgvzi0z17chloqbybue81t$_run_closure3.doCall(/Users/eleitch/tmp/bandcamp-collection-downloader/build.gradle:23)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The compile configuration has been deprecated for resolution. This will fail with an error in Gradle 7.0. Please resolve the compileClasspath configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.8/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
        at build_dcwbgvzi0z17chloqbybue81t$_run_closure6$_closure10.doCall(/Users/eleitch/tmp/bandcamp-collection-downloader/build.gradle:42)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

BUILD SUCCESSFUL in 680ms
2 actionable tasks: 2 up-to-date
Ezwen commented

OK so it seems that quite a lot of things changed with the Gradle 6.8 release (that you appear to be using), while currently all my builds are made with 6.7. It's likely that the build.gradle file of the projet is only compatible with Gradle 6.7.

If you have the opportunity to try again with Gradle 6.7, I'd be interested to know if that solves your problem!

I've installed gradle 6.7

eleitch@C02C413BMD6N bandcamp-collection-downloader % gradle --version

------------------------------------------------------------
Gradle 6.7
------------------------------------------------------------

Build time:   2020-10-14 16:13:12 UTC
Revision:     312ba9e0f4f8a02d01854d1ed743b79ed996dfd3

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          11.0.9 (Oracle Corporation 11.0.9+11)
OS:           Mac OS X 10.15.7 x86_64

I've pulled your code back down just to make sure I didn't break anything.

eleitch@C02C413BMD6N bandcamp-collection-downloader % gradle fatJar

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 3s
2 actionable tasks: 2 executed
eleitch@C02C413BMD6N bandcamp-collection-downloader % 

Here's the result of trying to run it

eleitch@C02C413BMD6N libs % java -jar ./bandcamp-collection-downloader.jar 
Error: Could not find or load main class bandcampcollectiondownloader.MainKt
Caused by: java.lang.ClassNotFoundException: bandcampcollectiondownloader.MainKt
eleitch@C02C413BMD6N libs % 

Same error for me.

My configuration:

  • GNU/Linux, Ubuntu 20.04
  • openjdk 11.0.9.1 2020-11-04
  • gradle 6.7.1

Output:

$ gradle fatjar

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 881ms
2 actionable tasks: 2 up-to-date

$ java -jar ./build/libs/bandcamp-collection-downloader.jar

Error: Could not find or load main class bandcampcollectiondownloader.MainKt
Caused by: java.lang.ClassNotFoundException: bandcampcollectiondownloader.MainKt

I'm making it working with git checkout v2020-12-15 before recompiling.

The issue should come from the next commits.

Edit: an it works with gradle version 6.8.1 too ;)

Ezwen commented

@lepieru Thank you for the extra testing! I could finally reproduce the problem, and it turns out it was indeed a regression as you suggested. In short, I forgot to update a package name in the build.gradle file…

I'm pretty sure the problem is fixed now, but you can all try pulling and compiling if you'd like to try :)

@Ezwen Just pulled down your new code and it works perfect! Thanks for fixing this.

I confirm 👍

Ezwen commented

Great, let's close then