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

cljx leaking as dependency #47

Closed
weavejester opened this issue Aug 26, 2014 · 10 comments
Closed

cljx leaking as dependency #47

weavejester opened this issue Aug 26, 2014 · 10 comments
Milestone

Comments

@weavejester
Copy link

The README states:

cljx itself will be added as a project dependency (this will only affect REPL processes, and won't leak out into your project's pom.xml, influencing downstream users of your library, if you're writing one)

However, cljx does leak out. For example, the Medley 0.5.0 has a dependency on cljx 0.4.0.

@hugoduncan
Copy link

I think this is caused by the cljx.plugin/middleware unconditionally adding cljx to the dependencies. As a workaround, you can specify the cljx plugin inside the :dev profile.

@cemerick
Copy link
Collaborator

Yeah, @hugoduncan is right. I always put cljx in :dev, which explains the README inaccuracy.

It's been a long while since I've had my hand in lein pom stuff. What needs to be changed to prevent the dep from being included, regardless of the profile in which the plugin is situated? (Making the dep optional would be an easy fix, but I'd like the pom to be clean in all cases.)

@hugoduncan
Copy link

I think that the cljx task should add the dependency, rather than doing it in middleware, assuming that the task is the only thing that requires the dependency being on the project's classpath.

@weavejester
Copy link
Author

Currently, Leiningen just unmerges the :default profile from the project map before generating the pom. The :default profile is defined as [:base :system :user :provided :dev], but can be overridden.

I can see several options here:

  1. Create a new :cljx profile for the dependencies, and add it to the :default profile.
  2. Add the dependencies to the :dev profile automatically
  3. Clearly document in the README that the plugin should be used in a profile, not at the top level.

I'm personally inclined toward option 1. It would give people the ability to turn cljx on and off just by toggling the profile, while at the same time providing unsurprising default behaviour when deploying or generating jars.

@cemerick
Copy link
Collaborator

The dependency is also required at runtime for the REPL support, etc.

@cemerick
Copy link
Collaborator

I've updated the README to demonstrate and advise :dev profile use.

Happy to take a PR that implements option 1 as described by @weavejester.

@hugoduncan
Copy link

Some profiles for common configuration scenarios would be nice to add too. eg. cljx only source project with cljx sources under src, or a clj and cljx project (with src/clj and src/cljx). These profiles could be explicitly used by a consuming project to avoid repetitive and error prone manual configuration of the project.

hugoduncan added a commit to hugoduncan/cljx that referenced this issue Aug 30, 2014
Use named profiles to prevent cljx dependencies leaking into jar.

Fixes lynaghk#47
@cemerick
Copy link
Collaborator

cemerick commented Sep 4, 2014

Another thought: why shouldn't the dependency just be added in a repl task hook? Should eliminate all the profile business entirely.

@weavejester
Copy link
Author

I forgot to mention that I posted to the Leiningen mailing list about how best to solve this. @technomancy's response was that there isn't currently a good way of doing this in Leiningen as yet... though it appears as though @hugoduncan has submitted a PR along these lines.

@cemerick cemerick added this to the 0.5.0 — Making configuration / interop w/ other tools easier milestone Sep 5, 2014
@cemerick
Copy link
Collaborator

cemerick commented Sep 5, 2014

A fix for this is now on develop/0.5.0, and available for testing as [org.clojars.cemerick "0.5.0-SNAPSHOT"]. The plugin's middleware now only adds the dependency if the :repl profile is activated, indicating that the REPL is about to start. In my testing, this prevents cljx from ever getting near the pom.

More capable profile/configuration management is an interesting notion, but I'd like to consider that separately, as long as the current proposed fix works.

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

3 participants