Document getting started with Maven in more detail
See original GitHub issueFirst, forgive me for the really basic questions as it has been a million years since Iāve worked with Java projects and am a java noob š I think some possibly basic maven setup information is missing in this guide, hopefully the information here can help figure that out, and I will happily update the getting started guides to be more total-java-noob friendly.
I tried following the getting started guides on the bolt docs (in particular, the Socket Mode Getting Started Guide), but got stuck pretty quickly.
First in the āProject Setupā section:
After you create your Maven project
There is nothing linked here, so I googled and followed the Maven quickstart instructions. I was able to create a maven project using mvn generate
and then compile the basic project using mvn package
. Finally, I could run the built project using java -cp
- so I thought I was ok.
Next I added the dependencies listed under the Maven section of Project Setup of the Bolt Getting Started Guide. However, the last note in this section confused me:
If you use Java-WebSocket library, add the artifact instead of tyrus-standalone-client.
I donāt know if Iām using Java-WebSocket or not by default, so I donāt know if I should add the relevant artifact and remove the tyrus-standalone-client 𤷠ā
Next I moved on to the āRun Your Bolt App in 3 Minutesā section of the getting started guide. However, there is no Maven-specific instructions here - only instructions for changing a build.gradle file - so I skipped to copying the code for MyApp.java into my maven project.
Next section I moved to is āStart the App with Two Env Variablesā. I set the two environment variables, but the running instructions here are again gradle-specific and nothing Maven-specific. So I assumed the same package and running instructions relevant to the maven quickstart applied. However, running mvn package
with the basic socket mode app code in place yields:
12:05:12 in ~/src/slapp-BoltJavaApp
ā mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< ca.filmaj.boltjavaapp:boltjavaapp >------------------
[INFO] Building boltjavaapp 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ boltjavaapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/fmaj/src/slapp-BoltJavaApp/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ boltjavaapp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/fmaj/src/slapp-BoltJavaApp/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/fmaj/src/slapp-BoltJavaApp/src/main/java/ca/filmaj/boltjavaapp/MyApp.java:[11,38] lambda expressions are not supported in -source 7
(use -source 8 or higher to enable lambda expressions)
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.784 s
[INFO] Finished at: 2022-05-20T12:05:17-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project boltjavaapp: Compilation failure
[ERROR] /Users/fmaj/src/slapp-BoltJavaApp/src/main/java/ca/filmaj/boltjavaapp/MyApp.java:[11,38] lambda expressions are not supported in -source 7
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The page URLs
More Context
My mvn and java versions:
ā mvn --version
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /usr/local/Cellar/maven/3.8.5/libexec
Java version: 11.0.15, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@11/11.0.15/libexec/openjdk.jdk/Contents/Home
Default locale: en_CA, platform encoding: UTF-8
OS name: "mac os x", version: "12.3.1", arch: "x86_64", family: "mac"
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
@filmaj Thanks for this feedback!
First of all, my basic stance is that this document is not for Java beginners but for Java developers that would like to know how to use this SDK. For this reason, I believe that itās fine to skip some very details. That being said, I agree that it would be great if we make the documents even more friendly.
Both Tyrus and Java-WebSocket are optional dependencies of slack-api-package / bolt-socket-mode. The default recommendation is Tyrus as it is the reference implementation of the standard WebSocket client spec in Java. However, some developers may prefer using the alternative: Java-WebSocket. Thatās the case here. I agree that the part can be clearer. Can you send a pull request for it?
Do you mean that we should add pom.xml part here? The document already mentioned how to configure a project with Maven in the previous āProject Setupā part. For this reason, I didnāt repeat the same thing. If you think that this is not developer-friendly (frankly, I donāt think so), we can add the dependencies part to the section as an improvement.
I donāt think that majority of Maven developers can be confused here but itās fine to make the part more friendly by adding pom.xml example or saying that āOf course, you can use Maven for setting this project up!ā.
Your build settings force the compilation with Java 1.7. Itās a common practice to set source / target language version: https://github.com/slackapi/java-slack-sdk/blob/v1.22.1/pom.xml#L44-L45
This is not specific to this SDK at all but if you think that we should tell this to the document visitors to make the documents even more inclusive, it would be okay to add an extra sentence about this.
I do understand that some things might be confusing to you. If you are keen to make our documents even more friendly to everyone (beyond the common expectations to SDK docs), I am happy to work with you on updating the documents.
My bad, I missed the extra configuration step in
build.gradle
for setting up the run task that maps the debug logging flag to the correct property. Once I added this to mybuild.gradle
, things worked fine: