zio / zio-quickstarts

A minimal quickstart ZIO application for writing a RESTful Web Service
https://zio.dev/guides/#quickstart-guides
60 stars 39 forks source link

Make zio-quickstart-hello-world work the way README.md says it should #35

Closed gnp closed 1 year ago

gnp commented 1 year ago

The old build.sbt file did not work if you cd-ed into the zio-quickstart-hellow-world directory and ran sbt run. Now, it does.

gusost commented 1 year ago

Works as intended!

gnp commented 1 year ago

Does not work the way one would expect from README.md. Here's what happens:

% git clone git@github.com:zio/zio-quickstarts.git
Cloning into 'zio-quickstarts'...
remote: Enumerating objects: 951, done.
remote: Counting objects: 100% (141/141), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 951 (delta 114), reused 115 (delta 95), pack-reused 810
Receiving objects: 100% (951/951), 113.41 KiB | 1001.00 KiB/s, done.
Resolving deltas: 100% (342/342), done.
% cd zio-quickstarts/zio-quickstart-hello-world 
% sbt run
[info] Updated file /Users/gregor/TEMP/zio-quickstarts/zio-quickstart-hello-world/project/build.properties: set sbt.version to 1.8.3
[info] welcome to sbt 1.8.3 (Eclipse Adoptium Java 17.0.6)
[info] loading global plugins from /Users/gregor/.sbt/1.0/plugins
[info] loading project definition from /Users/gregor/TEMP/zio-quickstarts/zio-quickstart-hello-world/project
/Users/gregor/TEMP/zio-quickstarts/zio-quickstart-hello-world/build.sbt:3: error: not found: value stdSettings
    .settings(stdSettings())
              ^
/Users/gregor/TEMP/zio-quickstarts/zio-quickstart-hello-world/build.sbt:4: error: not found: value enableZIO
    .settings(enableZIO())
              ^
sbt.compiler.EvalException: Type error in expression
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)

Also does not work this way one might try, even though different from what README.md says:

# same checkout
% sbt
[info] welcome to sbt 1.8.3 (Eclipse Adoptium Java 17.0.6)
[info] loading global plugins from /Users/gregor/.sbt/1.0/plugins
[info] loading settings for project zio-quickstarts-build from plugins.sbt ...
[info] loading project definition from /Users/gregor/TEMP/zio-quickstarts/project
[info] loading settings for project root from build.sbt ...
[info] loading settings for project zio-quickstart-hello-world from build.sbt ...
[info] loading settings for project zio-quickstart-restful-webservice from build.sbt ...
[info] loading settings for project zio-quickstart-restful-webservice-configurable-app from build.sbt ...
[info] loading settings for project zio-quickstart-restful-webservice-custom-logger from build.sbt ...
[info] loading settings for project zio-quickstart-restful-webservice-dockerize from build.sbt ...
[info] loading settings for project zio-quickstart-restful-webservice-logging from build.sbt ...
[info] loading settings for project zio-quickstart-restful-webservice-metrics from build.sbt ...
[info] loading settings for project zio-quickstart-kafka from build.sbt ...
[info] loading settings for project zio-quickstart-graphql-webservice from build.sbt ...
[info] loading settings for project zio-quickstart-streams from build.sbt ...
[info] loading settings for project zio-quickstart-encode-decode-json from build.sbt ...
[info] resolving key references (14673 settings) ...
[info]                ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄   ▄▄ ▄                                 
[info]          ▀▀ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀  ▄▄▄▄▄    ▄▄▄▄▄▄▄▄▄▄▄                 
[info]                         ▀▀▀▀▀▀▄▄▄▄▄▄▄▄▄▄▀  ▀▄▄▄▄   ▄▄▄▄▄▀▀▀▀▄▄▄▄▄               
[info]                           ▄▄▄▄▄▄▄▄▄▄▄▀      ▄▄▄▄   ▄▄▀        ▀▄▄▄              
[info]                     ▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄       ▄▄▄                ▀▄▄▄             
[info]                    ▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀▀▀       ▄▄▄                 ▄▄              
[info]                  ▄▄▄▄▄▄▀▀     ▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄  ▄▄ ▄▄    ▄▄▄▄▄ 
[info]              ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄▄▀▀▀▀▀▀▀▀▀       ▄▄               
[info]            ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀      ▄▄      ▄      ▄▄▄▄▀               
[info]        ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀                ▄       ▀▀▄▄▄▄▄▄▀▀                 
[info]      ▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀                                                            
[info]    ▄▄▄▄▄▄▀▀▀▀          root v.0.0.0+85-55100a04-SNAPSHOT                                                     
[info]                                                                                 
[info] Useful sbt tasks:
[info] > lint                                    Verifies that all source files are properly formatted and have had all scalafix rules applied.
[info] > fmt                                     Formats source files using scalafmt.
[info] > fix                                     Fixes source files using using scalafix
[info] > prepare                                 Prepares sources by applying scalafmt and running scalafix.
[info] > quiet                                   `quite on` mutes the welcome banner whilst `quiet off` un-mutes it.
[info] > publish-all                             Signs and publishes all artifacts to Maven Central.
[info] > enableStrictCompile                     Enables strict compilation e.g. warnings become errors.
[info] > disableStrictCompile                    Disables strict compilation e.g. warnings are no longer treated as errors.
[info] > ~compile                                Compiles all modules (file-watch enabled)
[info] > test                                    Runs all tests
[info] > testOnly *.YourSpec -- -t \"YourLabel\" Only runs tests with matching term e.g.
[info]       
[info] sbt server started at local:///Users/gregor/.sbt/1.0/server/3b417bdb44ab8ed73a7c/sock
[info] started sbt server
sbt:root> project zio-quickstart-hello-world
[info] set current project to zio-quickstart-hello-world (in build file:/Users/gregor/TEMP/zio-quickstarts/)
sbt:zio-quickstart-hello-world> run
[error] java.lang.RuntimeException: No main class detected.
[error]     at scala.sys.package$.error(package.scala:30)
[error] stack trace is suppressed; run last Compile / bgRun for the full output
[error] (Compile / bgRun) No main class detected.
[error] Total time: 2 s, completed May 31, 2023, 7:10:28 AM
gnp commented 1 year ago

Given these are examples to get people started quickly, I'd argue that each sub-project's build.sbt should be self-contained, not leveraging build particularities to zio org present in the main directory build.sbt. In fact, some of the sub-projects do have simple no-zio-org-isms build.sbt files. Two that do not are this one and the kafka one.

Currently, if someone were to copy-paste the zio-quickstart-hello-world directory contents to their own folder and try to run it outside the toplevel project it would not work, either. That makes it less useful for getting someone started because the build.sbt + source they see in the project folder is not usable as-is.

khajavi commented 1 year ago

@gnp Are you done with your work in this PR?

gnp commented 1 year ago

Yes @khajavi