question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document getting started with Maven in more detail

See original GitHub issue

First, 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:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
seratchcommented, May 20, 2022

@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.

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 🤷 ā“

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?

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

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.

  • so I skipped to copying the code for MyApp.java into my maven project.

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!ā€.

[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)

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.

0reactions
filmajcommented, May 27, 2022

One extra note about the gradle output above, it does not seem like the slackLogLevel=debug flag passed to gradle run creates any additional debug logging - not sure if that is a bug or something. I tried searching through the codebase for slackLogLevel but nothing showed up other than in the docs.

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 my build.gradle, things worked fine:

run {
    // gradle run -DslackLogLevel=debug
    systemProperty "org.slf4j.simpleLogger.log.com.slack.api", System.getProperty("slackLogLevel")
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven Getting Started Guide
Documentation ; Reporting; Dependencies; SCMs; Releases; Distribution. If you want more background information on Maven you can check out The Philosophy of Maven...
Read more >
How to get started with Maven - freeCodeCamp
validate : Checks if all necessary information is available for the project; compile: Used to compile the source files. Run the following commandĀ ......
Read more >
Getting Started | Building Java Projects with Maven - Spring
First you'll need to setup a Java project for Maven to build. To keep the focus on Maven, make the project as simple...
Read more >
Getting Started with Maven in Less Than 10 Minutes - Part 1
Maven helps you create simple projects, to easily get you started with your work. Maven has defined a set of so-called 'archetypes',Ā ...
Read more >
Apache Maven Tutorial - Baeldung
A Maven plugin is a collection of one or more goals. Goals are executed in phases, which helps to determine the order in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found