Rename :core-default to :leiningen/default.

This commit is contained in:
Phil Hagelberg 2014-09-09 16:04:31 -07:00
parent 60bb8e406e
commit 9a0448041a
4 changed files with 20 additions and 22 deletions

View file

@ -13,7 +13,8 @@ into a given profile and they will be merged into the project map when
that profile is activated. that profile is activated.
The example below adds a "dummy-data" resources directory during The example below adds a "dummy-data" resources directory during
development and a dependency upon "expectations" that's only used for tests. development and a dependency upon "expectations" that's only used for
tests/development.
```clj ```clj
(defproject myproject "0.5.0-SNAPSHOT" (defproject myproject "0.5.0-SNAPSHOT"
@ -72,6 +73,9 @@ project should never define a `:user` profile, nor should a user-wide
`:dev` profile be defined. Likewise, system profiles should use the `:dev` profile be defined. Likewise, system profiles should use the
`:system` profile, and define neither `:user` nor `:dev` profiles. `:system` profile, and define neither `:user` nor `:dev` profiles.
The `:system` profile is similar to `:user`, except it applies
system-wide instead of merely to a single user.
The `:base` profile provides dependencies necessary for basic repl The `:base` profile provides dependencies necessary for basic repl
functionality, adds `dev-resources` to the `:resources-path`, and sets functionality, adds `dev-resources` to the `:resources-path`, and sets
defaults for `:jvm-opts`, `:checkout-deps-share` and defaults for `:jvm-opts`, `:checkout-deps-share` and
@ -80,8 +84,7 @@ to change it.
The profiles listed above are active during development, but they are The profiles listed above are active during development, but they are
unmerged before the jar and pom files are created, making them unmerged before the jar and pom files are created, making them
invisible to code that depends upon your project. The next two invisible to code that depends upon your project.
profile is different.
The `:provided` profile is used to specify dependencies that should be The `:provided` profile is used to specify dependencies that should be
available during jar creation, but not propagated to other code that available during jar creation, but not propagated to other code that
@ -91,11 +94,9 @@ but are needed during the development of the project. This is often
used for frameworks like Hadoop that provide their own copies of used for frameworks like Hadoop that provide their own copies of
certain libraries. certain libraries.
## Default Profiles The `:default` profile specifies the profiles that are active by
The `:default-profile` specifies the profiles that are active by
default when running lein tasks. If not overridden, this is set to default when running lein tasks. If not overridden, this is set to
`:core-default`, which is a composite profile with `:leiningen/default`, which is a composite profile with
`[:base :system :user :provided :dev]`. `[:base :system :user :provided :dev]`.
## Task Specific Profiles ## Task Specific Profiles
@ -107,15 +108,17 @@ these are the `:test` profile, when running the `test` task, and the
## Profile Metadata ## Profile Metadata
If you mark your profile with `^:leaky` metadata, then the profile If you mark your profile with `^:leaky` metadata, then the profile
will affect the generated pom and jar when active. will not be stripped out when the pom and jar files are created.
If you mark a profile with `^{:pom-scope :test}` metadata, then the If you mark a profile with `^{:pom-scope :test}` metadata, then the
profile's `:dependencies` will be added with a `test` scope in the profile's `:dependencies` will be added with a `test` scope in the
generated pom and jar when active. generated pom and jar when active. The `:dev`, `:test`, and `:base`
profiles have this set automatically.
If you mark a profile with `^{:pom-scope :provided}` metadata, then the If you mark a profile with `^{:pom-scope :provided}` metadata, then
profile's `:dependencies` will be added with a `provided` scope in the the profile's `:dependencies` will be added with a `provided` scope in
generated pom and jar when active. the generated pom and jar when active. The `:provided` profile has
this set automatically.
## Merging ## Merging
@ -203,13 +206,7 @@ This can be used to avoid duplication:
:production [:shared {:servers ["prod1.mycorp.com", "prod1.mycorp.com"]}]} :production [:shared {:servers ["prod1.mycorp.com", "prod1.mycorp.com"]}]}
``` ```
Composite profiles are used by Leiningen internally for the `:default` ## Dynamic Eval
profile, which is the profile used if you don't change it using
`with-profile`. The `:default` profile is defined to be a composite of
`[:base :system :user :provided :dev]`, but you can change
this in your `project.clj` just like any other profile.
## Using Functions
Often you want to read an environment variable or execute a function to capture Often you want to read an environment variable or execute a function to capture
a value to use in your profiles. In order to do such a thing with the profiles.clj a value to use in your profiles. In order to do such a thing with the profiles.clj

View file

@ -469,8 +469,8 @@
(def default-profiles (def default-profiles
"Profiles get merged into the project map. The :dev, :provided, and :user "Profiles get merged into the project map. The :dev, :provided, and :user
profiles are active by default." profiles are active by default."
(atom {:default [:core-default] (atom {:default [:leiningen/default]
:core-default [:base :system :user :provided :dev] :leiningen/default [:base :system :user :provided :dev]
:base {:resource-paths ["dev-resources"] :base {:resource-paths ["dev-resources"]
:jvm-opts (with-meta tiered-jvm-opts :jvm-opts (with-meta tiered-jvm-opts
{:displace true}) {:displace true})

View file

@ -305,6 +305,7 @@ With an argument, the jar will be built with an alternate main."
(when (:auto-clean project true) (when (:auto-clean project true)
(clean/clean project)) (clean/clean project))
(eval/prep (eval/prep
;; TODO: don't hard-code :provided here, rely on ^:leaky
(process-project project main project/merge-profiles (process-project project main project/merge-profiles
(project/pom-scope-profiles project :provided))) (project/pom-scope-profiles project :provided)))
(let [jar-file (get-jar-filename* project nil)] (let [jar-file (get-jar-filename* project nil)]

View file

@ -5,7 +5,7 @@
(defproject nomnomnom "0.5.0-SNAPSHOT" (defproject nomnomnom "0.5.0-SNAPSHOT"
:dependencies [] :dependencies []
:profiles {:default [:core-default :my-leaky :my-provided :my-test] :profiles {:default [:leiningen/default :my-leaky :my-provided :my-test]
:my-leaky ^:leaky {:dependencies :my-leaky ^:leaky {:dependencies
[[org.clojure/tools.macro "0.1.2"]]} [[org.clojure/tools.macro "0.1.2"]]}
:my-test :my-test