Fork me on GitHub
#polylith
<
2023-01-17
>
oly13:01:47

@seancorfield continuing on with the build.clj for polylith I am noticing that you don't seem to call the basis function, in the below code I can see your puling in the config from deps to pass to the uber function

(doseq [p projects]
      (println "\nRunning: uber on" p)
      (let [project-dir (str "projects/" p)
            aliases     (with-dir (io/file project-dir) (get-project-aliases))]
        ;; ignore any projects that don't build as uberjars:
        (when-let [uberjar-opts (:uberjar aliases)]
          (binding [b/*project-root* project-dir]
            (bb/clean {})
            (bb/uber (assoc uberjar-opts :compile-opts {:direct-linking true}))))))
In the examples I have seen you often build the uber with these params
(b/uber {:class-dir jar-content
                 :uber-file uber-file-name
                 :basis     basis
                 :main      'api-rest.core})
I am kind of expecting to have to run this
(b/create-basis {:project (str project-folder "/deps.edn")})
which is erroring with
Local lib poly/offsite-conversions not found: /var/www/components/offsite-conversions
which I believe is due to setting the project root to the project dir. any reason you don't have a basis defined ? or if I should need one ? I have just noticed the path is completely wrong which is why its not found, but the question still stands on the basis part 🙂

seancorfield20:01:18

(b/create-basis {}) should be fine, inside the binding -- that's the default that build-clj uses behind the scenes: https://github.com/seancorfield/build-clj/blob/main/src/org/corfield/build.clj

seancorfield20:01:24

The purpose of binding the project root to the folder containing the deps.edn is for the build to run as if it is inside that folder,

oly14:01:07

cheers for that I now have 2 projects building from a single build.clj, now just to figureout why my connection pool does not work with tools.build but does with depstar, but thats a tools.build issue 🙂

seancorfield16:01:06

Happy to try to help with that too. What do you mean by "does not work"?

oly08:01:03

Sure that would be appreciated, so basically it seems to resolve around this metabase/connection-pool or one of its deps like c3p0, the strange thing is I have multiple projects they both call init-database which in turn sets up the connection pool, one works the other exits as soon as it trys to setup the pool. these both use tools.build now previously I used depstar which works and did not hit this issue, its like something that's required is being excluded from the jar. I have been diffing the jar contents but not spotted anything, they are large jars with a lot of files so I could easily be missing it, I chucked in a few (prn) statements and can see them before connection-pool/connection-pool-spec is called but the one directly after fails to be output, bit lost when it comes to diagnosing this sort of issue as I have not needed to previously. curious if there are any good articles out there on this subject, but would appreciate any help your able to give.

oly08:01:55

Worth pointing out init-database is a shared component for all projects and I can see that the db credentials are identical when running the generated jars.

seancorfield16:01:06

It just "exits"? No error message?

oly17:01:07

yeah no error or traceback, its a bit strange

seancorfield17:01:12

That is definitely strange. I'll think about it and see if I can suggest any debugging approaches... I don't suppose any of this code is public, is it?

Oliver Marks18:01:01

at home now, its an internal company project my only thought is perhaps if it tries to load a postgress class when creating the pool and its not available, I could probably grab the chunk of code from the repo, most likely I will have to create a new project to try and reproduce which is cut down. its strange being that its a shared component and working else where.

Oliver Marks18:01:50

the main difference is that one is a cli tool which works mainly for cron tasks the other is a ring api, which is the one failing.

Oliver Marks19:01:29

probably copying the project and base and removing things bit by bit would be a good path just time consuming