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

Consider not requiring core ns in env/dev/user.clj #297

Open
socksy opened this issue Jul 11, 2017 · 3 comments
Open

Consider not requiring core ns in env/dev/user.clj #297

socksy opened this issue Jul 11, 2017 · 3 comments

Comments

@socksy
Copy link

socksy commented Jul 11, 2017

I was getting byzantine errors when trying to (:import) a java class we had in our :java-source-paths in the project.clj, saying it wouldn't import. It turns out, that by having a reference to the core NS causes some form of dependency chain that makes the java file fail to be compiled and imported.

See here, here and here for a sample of such errors.

The solution for us was to remove the reference to the core ns, and remove the REPL server definition there (so we don't need to except it in the (start) and (stop) functions). We added a new (init) fn which did require that NS, making the start and stop work again.

Possibly there are cleaner ways of solving it, but the current template is broken as soon as you want to import local java files.

@yogthos
Copy link
Member

yogthos commented Jul 11, 2017

I wonder if it might be better to document the issue. I personally favor the approach of compiling Java sources in a separate profile. The approach James Reeves mentions with using a dev.clj to bootstrap the user namespace is also an option, but that creates an extra step for the development process and it doesn't appear that this is a common situation.

@socksy
Copy link
Author

socksy commented Jul 12, 2017

Not sure how/if compiling Java sources in a separate profile effects things?

Can you expand? I wouldn't mind trying it out. The main requirement is that I need to emit a protobuf encoded object as part of a handling function (and protoc generates Java files).

Also, there may be a way to automate the init with :init-ns etc, as Weavesjester mentioned in the /r/Clojure topic.

@yogthos
Copy link
Member

yogthos commented Jul 12, 2017

I was thinking something like:

:profiles {:protobuf
                {:source-paths ["src/java"]
                 :target-path "/target/classes"}
                ...}

Then you could add an alias to compile java assets before starting, e.g:

:aliases {"run"
               ["do"
                   ["with-profile" "protobuf" "javac" "compile"]
                   ["run"]]}

Also, have you looked at using :prep-tasks, e.g: :prep-tasks [["protobuf" "compile"] "javac" "compile"].

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

No branches or pull requests

2 participants