Fork me on GitHub
#polylith
<
2021-12-22
>
nickik01:12:32

Hi all. So I am trying to start a new project and I am just using a simple log component to test. I tried running this in cursive, but somehow it always end up telling me that my components/log/interface.clj is not a Source Root.

nickik01:12:52

I do know that there is a difference between extra-paths and extra-deps.

nickik01:12:05

I did it exactly like it is in the realworld-example.

nickik01:12:22

It works when I load realworld-example, but not on my own project.

nickik01:12:42

It just 'poly create workspace ' add the log component from 'realworld' and update top-level deps.edn to include extra-paths:

"components/log/src"
"components/log/resources"
Then I load the project into Cursive and it fails to resolve. Is there some kind of additional thing that needs to be done?

seancorfield01:12:22

Hi @U0JE93A5V! We like to use threads as much as possible in the #polylith channel. Can you share your deps.edn and workspace.edn files so we can take a look?

nickik01:12:46

Sure, sorry about that.

seancorfield01:12:15

If you're using :extra-paths, I think Cursive should be happy -- but it doesn't understand local roots in :extra-deps, unfortunately, which is the recommended way to set things up.

nickik01:12:32

What's the best way to post code?

seancorfield01:12:47

I suspect you may have omitted the step in Cursive where you tell it to use the :dev alias when you set up the project?

nickik01:12:48

:extra-paths ["development/src"
                                 "components/log/src"
                                 "components/log/resources"]

seancorfield01:12:06

The whole deps.edn file.

seancorfield01:12:08

Looks right. Did you see my comment about telling Cursive about the :dev alias?

nickik01:12:29

├── bases ├── components │ └── log │ ├── deps.edn │ ├── resources │ │ └── log │ ├── src │ │ └── ch │ │ └── wiki │ │ └── historyatlas │ │ └── log │ │ ├── config.clj │ │ ├── core.clj │ │ └── interface.clj │ └── test │ └── ch │ └── wiki │ └── historyatlas │ └── log │ └── interface_test.clj ├── deps.edn ├── development │ └── src ├── history-atlas.iml ├── logo.png ├── projects ├── readme.md └── workspace.edn

seancorfield01:12:33

Otherwise, it won't know to read those :extra-paths and :extra-deps

nickik01:12:56

Yes, I added those.

nickik01:12:03

dev,test,rebl

seancorfield01:12:12

(and don't forget to add "components/log/test" to the :extra-paths under the :test alias -- and you'll also need a SHA in that :sha "" line if you want to use clojure -M:poly as opposed to the O/S-installed poly command)

nickik01:12:58

Unrleated questions, why not make the poly tool into a binary with graalvm to avoid startup?

nickik01:12:08

But 'log' will not have tests right? Its not in that list in the example app.

seancorfield01:12:31

You have test/ch/wiki/historyatlas/log/interface_test.clj already.

nickik01:12:00

I guess that was automatically created with the poly tool.

nickik01:12:12

So the sha is just a random hash?

seancorfield01:12:54

SHA is from GitHub

nickik01:12:35

What is interesting, I tested deleting everything from example app that wasn't needed and I also delete the .idea folder. When I reopned the project I have the same problem there.

seancorfield01:12:24

88c1f4cca32d8a30a2ef298b1d96880c6417faf9 is the SHA for alpha 13, 8cd415f0da54e28f117c74848c32f91d23c805d4 is what is current on master for https://github.com/polyfy/polylith

seancorfield01:12:07

Sounds like you're going to need help from someone who uses Cursive, sorry. Not sure when they'll be online but they're mostly in a different TZ...

seancorfield01:12:23

(although it's 2:30 am for you, right?)

nickik01:12:14

Yeah but I have vaccation

nickik01:12:20

Ok thanks.

seancorfield01:12:57

Heh, I'm on vacation now until I go back on Monday.

nickik01:12:32

Btw, I have been using Clojure since Clojure 1 days and you have done so many great projects. Thanks for that.

😊 1
seancorfield01:12:44

Do you use Cursive because you also do Java or some other JVM language?

seancorfield01:12:36

I've tried several different versions of IntelliJ over the years and I've never liked it. I used Eclipse for years and preferred it to IntelliJ but the Clojure extension for Eclipse stopped being maintained years ago, so I went through a lot of editors before ending up on Atom for several years and then moved to VS Code (last year I think?).

nickik01:12:43

Yes, we use it for work for Java. I used Emacs back in the early days but it drove me crazy and I have never been an emacs person.

nickik01:12:55

Not sure what other options are.

nickik01:12:18

I didn't really know VS Code was an option, does that work on linux?

nickik02:12:53

I figured out at least one thing, nrepl is required, just using 'clojure.main' doesn't work.

nickik02:12:22

But that intellj still doesn't allow me to do that, only works with the example project.

seancorfield02:12:09

I use VS Code on macOS and Windows. For the latter, I use WSL2 with Ubuntu and run all my Clojure stuff runs on Ubuntu, with the remote-wsl2 extension in VS Code to make it feel like a native experience. But, yeah, there is a Linux version too: https://code.visualstudio.com/docs/setup/linux

seancorfield02:12:14

As for nREPL, yeah, if you're using Cursive you need nREPL. I think, for Socket REPLs, the only options are inf-clojure in Emacs, Chlorine in Atom, and Clover in VS Code?

furkan3ayraktar06:12:32

Hi! Maybe you are missing the last step at https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app/blob/master/how-to.md#create-components where you add the dev and test aliases to the Clojure Deps Project tab.

furkan3ayraktar06:12:10

This screenshot specifically

furkan3ayraktar06:12:49

Those two checkboxes should be checked for Cursive to resolve the source paths. Also there is this issue to improve the Polylith support in Cursive: https://github.com/cursive-ide/cursive/issues/2554

nickik03:12:33

I think I am not getting something here. I am playing around with the Example app. I thought, lets just pull out the 'store' namespace into a component and then provide two different implmentations, one that uses jdbc, and a new on that would use datahike (datomic sort of). poly create component name:store-jdbc interface:store poly create component name:store-dh interface:store This however just seems to be creating components that have the wrong path. Do I need to create a thrid component 'store' that is only an interface? Or where does the pure interface code live?

seancorfield04:12:36

You might also find the Swappable Implementations section of this blog post helpful @U0JE93A5V https://corfield.org/blog/2021/10/13/deps-edn-monorepo-7/

seancorfield04:12:55

Each project depends on whichever implementation brick it wants. The development project uses the :+default profile (alias) by default but you can select any other profile. You can therefore test by project and get whichever dep the projects declare or, for :dev, whichever profile you declare.

nickik04:12:56

I think I understand that part, what I don't yet understand how exactly this is structured. I didn't realize that there was documentation on that under profiles.

nickik05:12:14

I will go to sleep now haha.

seancorfield05:12:47

It's nearly morning for you 🙂

seancorfield05:12:29

Hit me up on DM tomorrow if you're still stuck on it and I'll try to walk you through what we've done, with two HTTP client implementations of the same interface.

emccue03:12:58

the interface code is “duplicated” across all implementors

emccue03:12:57

i think of the interface pluggability strategy like .c and .h files except the linking is “explicit”

nickik03:12:35

So essentially there is an identical 'interface.clj' in each component?

emccue03:12:47

not “identical”, but being declaring same namespace and same symbols

emccue03:12:19

so picking an implementation is a “static” thing

nickik03:12:49

So my assumption above would be correct you pick a specific name for the component and general name for the interface?

nickik03:12:12

Or how would a file tree look like.

nickik03:12:41

And what about test, I assume you would want to have a general sets to test an interface, ignoring the implementation. Would you duplicate much of the test code as well?

emccue04:12:32

im not a full enough convert to explain that i dont think

seancorfield04:12:34

Please use threads.