Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slim/genclass #39

Merged
merged 9 commits into from
Jun 4, 2023
Merged

Conversation

slimslenderslacks
Copy link
Contributor

No description provided.

@slimslenderslacks slimslenderslacks marked this pull request as draft April 19, 2023 21:23
@slimslenderslacks
Copy link
Contributor Author

@jlesquembre this isn't ready to merge yet but I was just looking at how we might verify that the main-ns has a :gen-class in mkCljBin. I was having a hard time getting the Latest SNAPSHOT version is used in mvn-deps-test to pass. Should I be updating that expected version for that test since the SNAPSHOT has moved?

I'm also seeing that one of the integration tests is hanging for me but I wouldn't have thought it was related to my change.

So far, I'm only warning about missing :gen-class for deps.edn projects but I'm not actually failing the build yet. I still need to figure out whether I can run the same check for both deps.edn and leiningen projects.

@jlesquembre
Copy link
Owner

thanks for working on it!
Some notes:

  • Adding new dependencies to deps.edn is tricky. After adding (or updating) a dependency, you have to update builder-lock.json. It's bootstrapping issue, I should write some documentation about it. But in short, those dependencies are used by clj-nix when you build your clojure project. We read builder-lock.json and generate a CLASSPATH with nix. To simplify the process, the deps.edn file in clj-nix has some restrictions. In this PR you are adding a new dependecy, rewrite-clj, which is a transitive dependency of rewrite-edn (which we already have). rewrite-edn currently depends on rewrite-clj 1.1.45. At nix build time, clj-nix will use that version (we generate the CLASSPATH with nix here: https://github.com/jlesquembre/clj-nix/blob/main/pkgs/cljBuilder.nix) Not sure if that is a problem, but something to keep in mind. I'd prefer to remove rewrite-clj from deps.edn and use the same version used by rewrite-edn
  • The SNAPSHOT tests are fragile, if a new SNAPSHOT version is released, the test fails and we have to update it manually. I tried to pick old version for those tests, expecting no new SNAPSHOT releases. Also, I think that the real issue here is that you are on a darwin architecture, I suspect that maven is doing something different depending on the architecture.
  • About leiningen projects, it's ok to add a check only for deps.edn projects, we can add it later if needed. But the only reason I added leiningen support was to build babashka, I don't think many clj-nix users use leiningen

@slimslenderslacks
Copy link
Contributor Author

Okay, now that I know that aarch64-darwin might be the issue, I'll look into it more deeply. I think you're probably right about that too. I've been seeing some odd things with inconsistent nar hashing so I'll drill into a little bit more deeply and let you know what I find.

@slimslenderslacks
Copy link
Contributor Author

@jlesquembre it turned out that the unit tests were probably failing on darwin because of the artifact->pom function. I made a change to sort the glob results so that any SNAPSHOT poms would be first in the list (there should be only one SNAPSHOT pom file in any directory in an .m2/repository so that should work).

I've made the :gen-class test mandatory since it sounds like we don't need to support mkCljBin running on projects that don't have a deps.edn at the root. And main-ns is really a mandatory parameter for mkCljBin, right? I'm treating it like it's mandatory but maybe we should add a more explicit error message if main-ns is nil.

@slimslenderslacks slimslenderslacks marked this pull request as ready for review May 1, 2023 22:02
@jlesquembre
Copy link
Owner

jlesquembre commented May 28, 2023

@slimslenderslacks Thanks, and sorry for the late reply.
It makes sense to make the :gen-class test mandatory. main-ns is mandatory, I agree with you in that we should add a better error message if is null.
I'm testing your changes, it looks good :)

One question I have is why you added pkgs.diffutils.

Before merging it, could you take a look to my comments? The only thing I'd like to change before merging are the formatting changes. BTW, do you use a clojure formatter? I'm thinking about adding one to the project, but I'm not sure about it.

And is fine if you are not interested on doing those changes, I can do that on top of your PR.

deps.edn Outdated
@@ -6,7 +6,8 @@
version-clj/version-clj {:mvn/version "2.0.2"}
borkdude/rewrite-edn {:mvn/version "0.2.0"}
io.github.clojure/tools.build {:git/tag "v0.8.2"
:git/sha "ba1a2bf421838802e7bdefc541b41f57582e53b6"}}
:git/sha "ba1a2bf421838802e7bdefc541b41f57582e53b6"}
rewrite-clj/rewrite-clj {:mvn/version "1.1.47"}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to update borkdude/rewrite-edn to its latest version, and use the rewrite-clj provided by rewrite-edn. But I can do that after merging this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ya! Good idea. I'll change that now.

@@ -106,7 +106,7 @@ stdenv.mkDerivation ({
buildPhase =
''
runHook preBuild

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you undo the format changes? There are also some in the clojure files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've undone all of the formatting changes.

@slimslenderslacks
Copy link
Contributor Author

@jlesquembre I added pkgs.diffutils to the devshell because there was a cmp binary used somewhere ... Ya, it was https://github.com/jlesquembre/clj-nix/blob/main/test/new_project.bats#L38 and I didn't have it on my system so I thought it was probably appropriate to have this in the devshell. It was unrelated to my change I guess but I was trying to run those tests.

@jlesquembre
Copy link
Owner

I added pkgs.diffutils to the devshell because there was a cmp binary used somewhere ... Ya, it was https://github.com/jlesquembre/clj-nix/blob/main/test/new_project.bats#L38 and I didn't have it on my system

Good catch, I missed it, thanks :)

It looks good, I have some time planned to work on clj-nix this weekend, and merge this PR.

@jlesquembre jlesquembre merged commit 36440a3 into jlesquembre:main Jun 4, 2023
@jlesquembre
Copy link
Owner

@slimslenderslacks Thanks again, merged :)

@slimslenderslacks slimslenderslacks deleted the slim/genclass branch June 5, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants