GroovyLanguageServer / groovy-language-server

A language server for Groovy — designed for Moonshine IDE, but may be useful in other environments
https://moonshine-ide.com/
Apache License 2.0
185 stars 61 forks source link

Compilation error: "property 'mainClassName' doesn't have a configured value" #77

Closed tomrss closed 5 months ago

tomrss commented 1 year ago

Hello,

with repo cloned at last commit (4866a3f2c180f628405b1e4efbde0949a1418c10) I have the following error in compilation:

$ ./gradlew build
Note: /home/tomrss/.emacs.d/.cache/groovy-language-server/src/main/java/net/prominic/groovyls/GroovyLanguageServer.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

> Task :shadowJar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':shadowJar' (type 'ShadowJar').
  - In plugin 'com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin' type 'com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar' property 'mainClassName' doesn't have a configured value.

    Reason: This property isn't marked as optional and no value has been configured.

    Possible solutions:
      1. Assign a value to 'mainClassName'.
      2. Mark property 'mainClassName' as optional.

    Please refer to https://docs.gradle.org/7.6.1/userguide/validation_problems.html#value_not_set for more details about this problem.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
7 actionable tasks: 7 executed

This can be solved by applying the following patch:

diff --git a/build.gradle b/build.gradle
index 1b9effa..e9e923b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -12,16 +12,11 @@ test {
   useJUnitPlatform()
 }

+mainClassName = "net.prominic.groovyls.GroovyLanguageServer"
 ext.mainClass = "net.prominic.groovyls.GroovyLanguageServer"

 tasks.build.dependsOn tasks.shadowJar

-shadowJar {
-  manifest {
-    attributes "Main-Class": "net.prominic.groovyls.GroovyLanguageServer"
-  }
-}
-
 repositories  {
   mavenCentral()
 }

With this, the build runs correctly and the jar manifest META-INF/MANIFEST.MF is:

Manifest-Version: 1.0
Main-Class: net.prominic.groovyls.GroovyLanguageServer

I can submit a PR for this.

Thanks, Tommaso

joshtynjala commented 5 months ago

I updated to Gradle 8.8, and everything seems to be working without changes. Closing.