├── .github
└── workflows
│ └── release.yml
├── .gitignore
├── .idea
└── clojure-deps.xml
├── CHANGELOG.adoc
├── LICENSE
├── README.adoc
├── bb.edn
├── deps.edn
├── pom.xml
├── project-config.edn
├── project-version
├── resources
└── clj
│ └── new
│ └── rssyslib
│ ├── .clj-kondo
│ └── config.edn
│ ├── .cljstyle
│ ├── .editorconfig
│ ├── .gitignore
│ ├── CHANGELOG.adoc
│ ├── LICENSE
│ ├── README.adoc
│ ├── bb.edn
│ ├── deps.edn
│ ├── dev
│ └── src
│ │ └── user.clj
│ ├── pom.xml
│ ├── project-config.edn
│ ├── project-secrets.edn
│ ├── project-version
│ ├── resources
│ └── readme.txt
│ ├── scripts
│ └── bump-semver.clj
│ ├── src
│ └── core.clj
│ ├── test
│ └── core_test.clj
│ └── tests.edn
├── scripts
└── bump-semver.clj
└── src
└── clj
└── new
└── org
└── rssys
└── libtemplate.clj
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Publish new release to Clojars
2 | on:
3 |
4 | # react on every push with tags
5 | push:
6 | tags:
7 | - '*'
8 |
9 | # Allows you to run this workflow manually from the Actions tab
10 | workflow_dispatch:
11 |
12 | jobs:
13 |
14 | publish:
15 | name: Create release-artifacts
16 | runs-on: ubuntu-latest
17 |
18 | permissions:
19 | contents: read
20 | packages: write
21 | steps:
22 | # setup JDK
23 | - name: Set up JDK 16
24 | uses: actions/setup-java@v2
25 | with:
26 | java-version: '16'
27 | distribution: 'adopt'
28 |
29 | # Setup babashka
30 | - name: Set up babashka
31 | uses: turtlequeue/setup-babashka@v1.3.0
32 | with:
33 | babashka-version: 0.4.4
34 |
35 | # install clojure tools deps, lein and boot
36 | - name: Install clojure tools
37 | uses: DeLaGuardo/setup-clojure@3.5
38 | with:
39 | # Install just one or all simultaneously
40 | cli: 1.10.3.875 # Clojure CLI based on tools.deps
41 | lein: 2.9.6 # or use 'latest' to always provision latest version of leiningen
42 | boot: 2.8.3 # or use 'latest' to always provision latest version of boot
43 |
44 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
45 | - uses: actions/checkout@v2
46 |
47 | # Run tests
48 | # - name: Run tests
49 | # run: bb test
50 |
51 | # Build distr
52 | - name: Build distr
53 | run: bb build
54 |
55 | # Publish binary Github releases
56 | # - name: Upload binaries to release
57 | # uses: svenstaro/upload-release-action@v2
58 | # with:
59 | # repo_token: ${{ secrets.GHR_TOKEN }} # PAT token with rights: repo, user, admin:repo_hook
60 | # file: target/mylib*.jar
61 | # tag: ${{ github.ref }}
62 | # overwrite: true
63 | # file_glob: true
64 |
65 | # Publish package as jar file to Clojars
66 | - name: Publish new version to Clojars
67 | # run: mvn --batch-mode deploy
68 | run: bb deploy
69 | env:
70 | CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
71 | CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
72 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # exclude whole folders with logs
2 | log
3 | logs
4 |
5 | # exclude clj-kondo files except config
6 | .clj-kondo/*
7 | !*.clj-kondo/config.edn
8 |
9 | # exclude all .idea except some subfolders
10 | .idea/*
11 | !.idea/clojure-deps.xml
12 | !.idea/codeStyles/
13 | !.idea/copyright/
14 |
15 | # standard (default) exclusions
16 | /target
17 | /classes
18 | /checkouts
19 | *.jar
20 | *.class
21 | *.xml.asc
22 | /.cpcache
23 | /.lein-*
24 | /.nrepl-history
25 | /.nrepl-port
26 | .hgignore
27 | .hg/
28 |
29 |
30 | # exclude common files
31 | *.iml
32 | trace.edn
33 | .eastwood
34 | .nrepl-port
35 |
36 | # exclude private configs with sensitive data
37 | project-secrets.edn
38 |
39 | # allow public env vars for project
40 | !project-config.edn
41 |
--------------------------------------------------------------------------------
/.idea/clojure-deps.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/CHANGELOG.adoc:
--------------------------------------------------------------------------------
1 | == Changelog
2 |
3 | === [2.0.5] - 13-06-2021
4 |
5 | .Added
6 | * Github Actions CI. Publish new version to Clojars.
7 |
8 | .Changed
9 | * program `env` replaced with `{:extra-env env-vars}` map to pass new environment variables to the shell command.
10 | * updated dependencies.
11 |
12 | === [2.0.4] - 02-05-2021
13 |
14 | ==== Changed
15 |
16 | * update `bb.edn` syntax up to `babashka` v0.3.7 which is significantly reduced script size.
17 |
18 |
19 | === [2.0.3] - 25-04-2021
20 |
21 | ==== Fixed
22 |
23 | * -shell function now exits if Exception occurred to avoid strange behaviour.
24 |
25 |
26 | === [2.0.2] - 24-04-2021
27 |
28 | ==== Changed
29 |
30 | * minor changes
31 |
32 |
33 | === [2.0.1] - 24-04-2021
34 |
35 | ==== Changed
36 |
37 | * .clj-kondo/config.edn is updated cause `:exclude-files` has wrong value
38 |
39 |
40 | === [2.0.0] - 24-04-2021
41 |
42 | ==== Breaking changes
43 |
44 | * now all functionality of `just`, `direnv` utilities performed by `babashka` v0.3.5+ only
45 | ** removed utilities from project requirements: `just`, `direnv`
46 | ** removed config files: `Justfile`, `.env.public`, `.env.private`, `.envrc`
47 | * artifact name has changed to `org.rssys.libtemplate/clj-template` due to new Clojars policy
48 | * file `version_id` is renamed to `project-version`
49 |
50 |
51 | ==== Added
52 |
53 | * `project-config.edn` for public project configuration
54 | * `project-secrets.edn` for sensitive data, passwords, private project configuration
55 | * `bb.edn` for tasks (replacement of `Makefile` or `Justfile`)
56 |
57 | ==== Changed
58 |
59 | * updated all deps
60 |
61 | === [1.0.0] - 03-03-2021
62 |
63 | ==== Added
64 |
65 | * now it is possible to set the particular value to `major`, `minor`, `patch` sections when doing version bumping.
66 | It may be useful when we want to set `patch` version to the number of commits from the beginning
67 | (e.g. ```just bump patch `git rev-list HEAD --count````).
68 |
69 | === [0.1.2] - 02-03-2021
70 |
71 | ==== Breaking changes
72 |
73 | * removed `jenv` from project requirements
74 |
75 | === [0.1.1] - 26-02-2021
76 |
77 | Minor changes.
78 |
79 | ==== Fixed
80 |
81 | * pom.xml rendering
82 | * comments in scripts and docs.
83 |
84 | === [0.1.0-SNAPSHOT] - 23-02-2021
85 |
86 | Initial release.
87 |
88 | ==== Added
89 |
90 | * scripts for operations: clean, build, install, deploy, outdated, lint, format, test
91 | * project control via `Justfile`;
92 | * `cljstyle` formatter support;
93 | * dotenv files support using `direnv` utility:
94 | ** `.env.public` - for public environment variables;
95 | ** `.env.private` - for passwords and other secrets;
96 | * linter `clj-kondo` support with initial config;
97 | * project requirements script for MacOS
98 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 2.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
5 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6 |
7 | 1. DEFINITIONS
8 |
9 | "Contribution" means:
10 |
11 | a) in the case of the initial Contributor, the initial content
12 | Distributed under this Agreement, and
13 |
14 | b) in the case of each subsequent Contributor:
15 | i) changes to the Program, and
16 | ii) additions to the Program;
17 | where such changes and/or additions to the Program originate from
18 | and are Distributed by that particular Contributor. A Contribution
19 | "originates" from a Contributor if it was added to the Program by
20 | such Contributor itself or anyone acting on such Contributor's behalf.
21 | Contributions do not include changes or additions to the Program that
22 | are not Modified Works.
23 |
24 | "Contributor" means any person or entity that Distributes the Program.
25 |
26 | "Licensed Patents" mean patent claims licensable by a Contributor which
27 | are necessarily infringed by the use or sale of its Contribution alone
28 | or when combined with the Program.
29 |
30 | "Program" means the Contributions Distributed in accordance with this
31 | Agreement.
32 |
33 | "Recipient" means anyone who receives the Program under this Agreement
34 | or any Secondary License (as applicable), including Contributors.
35 |
36 | "Derivative Works" shall mean any work, whether in Source Code or other
37 | form, that is based on (or derived from) the Program and for which the
38 | editorial revisions, annotations, elaborations, or other modifications
39 | represent, as a whole, an original work of authorship.
40 |
41 | "Modified Works" shall mean any work in Source Code or other form that
42 | results from an addition to, deletion from, or modification of the
43 | contents of the Program, including, for purposes of clarity any new file
44 | in Source Code form that contains any contents of the Program. Modified
45 | Works shall not include works that contain only declarations,
46 | interfaces, types, classes, structures, or files of the Program solely
47 | in each case in order to link to, bind by name, or subclass the Program
48 | or Modified Works thereof.
49 |
50 | "Distribute" means the acts of a) distributing or b) making available
51 | in any manner that enables the transfer of a copy.
52 |
53 | "Source Code" means the form of a Program preferred for making
54 | modifications, including but not limited to software source code,
55 | documentation source, and configuration files.
56 |
57 | "Secondary License" means either the GNU General Public License,
58 | Version 2.0, or any later versions of that license, including any
59 | exceptions or additional permissions as identified by the initial
60 | Contributor.
61 |
62 | 2. GRANT OF RIGHTS
63 |
64 | a) Subject to the terms of this Agreement, each Contributor hereby
65 | grants Recipient a non-exclusive, worldwide, royalty-free copyright
66 | license to reproduce, prepare Derivative Works of, publicly display,
67 | publicly perform, Distribute and sublicense the Contribution of such
68 | Contributor, if any, and such Derivative Works.
69 |
70 | b) Subject to the terms of this Agreement, each Contributor hereby
71 | grants Recipient a non-exclusive, worldwide, royalty-free patent
72 | license under Licensed Patents to make, use, sell, offer to sell,
73 | import and otherwise transfer the Contribution of such Contributor,
74 | if any, in Source Code or other form. This patent license shall
75 | apply to the combination of the Contribution and the Program if, at
76 | the time the Contribution is added by the Contributor, such addition
77 | of the Contribution causes such combination to be covered by the
78 | Licensed Patents. The patent license shall not apply to any other
79 | combinations which include the Contribution. No hardware per se is
80 | licensed hereunder.
81 |
82 | c) Recipient understands that although each Contributor grants the
83 | licenses to its Contributions set forth herein, no assurances are
84 | provided by any Contributor that the Program does not infringe the
85 | patent or other intellectual property rights of any other entity.
86 | Each Contributor disclaims any liability to Recipient for claims
87 | brought by any other entity based on infringement of intellectual
88 | property rights or otherwise. As a condition to exercising the
89 | rights and licenses granted hereunder, each Recipient hereby
90 | assumes sole responsibility to secure any other intellectual
91 | property rights needed, if any. For example, if a third party
92 | patent license is required to allow Recipient to Distribute the
93 | Program, it is Recipient's responsibility to acquire that license
94 | before distributing the Program.
95 |
96 | d) Each Contributor represents that to its knowledge it has
97 | sufficient copyright rights in its Contribution, if any, to grant
98 | the copyright license set forth in this Agreement.
99 |
100 | e) Notwithstanding the terms of any Secondary License, no
101 | Contributor makes additional grants to any Recipient (other than
102 | those set forth in this Agreement) as a result of such Recipient's
103 | receipt of the Program under the terms of a Secondary License
104 | (if permitted under the terms of Section 3).
105 |
106 | 3. REQUIREMENTS
107 |
108 | 3.1 If a Contributor Distributes the Program in any form, then:
109 |
110 | a) the Program must also be made available as Source Code, in
111 | accordance with section 3.2, and the Contributor must accompany
112 | the Program with a statement that the Source Code for the Program
113 | is available under this Agreement, and informs Recipients how to
114 | obtain it in a reasonable manner on or through a medium customarily
115 | used for software exchange; and
116 |
117 | b) the Contributor may Distribute the Program under a license
118 | different than this Agreement, provided that such license:
119 | i) effectively disclaims on behalf of all other Contributors all
120 | warranties and conditions, express and implied, including
121 | warranties or conditions of title and non-infringement, and
122 | implied warranties or conditions of merchantability and fitness
123 | for a particular purpose;
124 |
125 | ii) effectively excludes on behalf of all other Contributors all
126 | liability for damages, including direct, indirect, special,
127 | incidental and consequential damages, such as lost profits;
128 |
129 | iii) does not attempt to limit or alter the recipients' rights
130 | in the Source Code under section 3.2; and
131 |
132 | iv) requires any subsequent distribution of the Program by any
133 | party to be under a license that satisfies the requirements
134 | of this section 3.
135 |
136 | 3.2 When the Program is Distributed as Source Code:
137 |
138 | a) it must be made available under this Agreement, or if the
139 | Program (i) is combined with other material in a separate file or
140 | files made available under a Secondary License, and (ii) the initial
141 | Contributor attached to the Source Code the notice described in
142 | Exhibit A of this Agreement, then the Program may be made available
143 | under the terms of such Secondary Licenses, and
144 |
145 | b) a copy of this Agreement must be included with each copy of
146 | the Program.
147 |
148 | 3.3 Contributors may not remove or alter any copyright, patent,
149 | trademark, attribution notices, disclaimers of warranty, or limitations
150 | of liability ("notices") contained within the Program from any copy of
151 | the Program which they Distribute, provided that Contributors may add
152 | their own appropriate notices.
153 |
154 | 4. COMMERCIAL DISTRIBUTION
155 |
156 | Commercial distributors of software may accept certain responsibilities
157 | with respect to end users, business partners and the like. While this
158 | license is intended to facilitate the commercial use of the Program,
159 | the Contributor who includes the Program in a commercial product
160 | offering should do so in a manner which does not create potential
161 | liability for other Contributors. Therefore, if a Contributor includes
162 | the Program in a commercial product offering, such Contributor
163 | ("Commercial Contributor") hereby agrees to defend and indemnify every
164 | other Contributor ("Indemnified Contributor") against any losses,
165 | damages and costs (collectively "Losses") arising from claims, lawsuits
166 | and other legal actions brought by a third party against the Indemnified
167 | Contributor to the extent caused by the acts or omissions of such
168 | Commercial Contributor in connection with its distribution of the Program
169 | in a commercial product offering. The obligations in this section do not
170 | apply to any claims or Losses relating to any actual or alleged
171 | intellectual property infringement. In order to qualify, an Indemnified
172 | Contributor must: a) promptly notify the Commercial Contributor in
173 | writing of such claim, and b) allow the Commercial Contributor to control,
174 | and cooperate with the Commercial Contributor in, the defense and any
175 | related settlement negotiations. The Indemnified Contributor may
176 | participate in any such claim at its own expense.
177 |
178 | For example, a Contributor might include the Program in a commercial
179 | product offering, Product X. That Contributor is then a Commercial
180 | Contributor. If that Commercial Contributor then makes performance
181 | claims, or offers warranties related to Product X, those performance
182 | claims and warranties are such Commercial Contributor's responsibility
183 | alone. Under this section, the Commercial Contributor would have to
184 | defend claims against the other Contributors related to those performance
185 | claims and warranties, and if a court requires any other Contributor to
186 | pay any damages as a result, the Commercial Contributor must pay
187 | those damages.
188 |
189 | 5. NO WARRANTY
190 |
191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
192 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
193 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
194 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
195 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
196 | PURPOSE. Each Recipient is solely responsible for determining the
197 | appropriateness of using and distributing the Program and assumes all
198 | risks associated with its exercise of rights under this Agreement,
199 | including but not limited to the risks and costs of program errors,
200 | compliance with applicable laws, damage to or loss of data, programs
201 | or equipment, and unavailability or interruption of operations.
202 |
203 | 6. DISCLAIMER OF LIABILITY
204 |
205 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
206 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
207 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
208 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
209 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
210 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
211 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
212 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
213 | POSSIBILITY OF SUCH DAMAGES.
214 |
215 | 7. GENERAL
216 |
217 | If any provision of this Agreement is invalid or unenforceable under
218 | applicable law, it shall not affect the validity or enforceability of
219 | the remainder of the terms of this Agreement, and without further
220 | action by the parties hereto, such provision shall be reformed to the
221 | minimum extent necessary to make such provision valid and enforceable.
222 |
223 | If Recipient institutes patent litigation against any entity
224 | (including a cross-claim or counterclaim in a lawsuit) alleging that the
225 | Program itself (excluding combinations of the Program with other software
226 | or hardware) infringes such Recipient's patent(s), then such Recipient's
227 | rights granted under Section 2(b) shall terminate as of the date such
228 | litigation is filed.
229 |
230 | All Recipient's rights under this Agreement shall terminate if it
231 | fails to comply with any of the material terms or conditions of this
232 | Agreement and does not cure such failure in a reasonable period of
233 | time after becoming aware of such noncompliance. If all Recipient's
234 | rights under this Agreement terminate, Recipient agrees to cease use
235 | and distribution of the Program as soon as reasonably practicable.
236 | However, Recipient's obligations under this Agreement and any licenses
237 | granted by Recipient relating to the Program shall continue and survive.
238 |
239 | Everyone is permitted to copy and distribute copies of this Agreement,
240 | but in order to avoid inconsistency the Agreement is copyrighted and
241 | may only be modified in the following manner. The Agreement Steward
242 | reserves the right to publish new versions (including revisions) of
243 | this Agreement from time to time. No one other than the Agreement
244 | Steward has the right to modify this Agreement. The Eclipse Foundation
245 | is the initial Agreement Steward. The Eclipse Foundation may assign the
246 | responsibility to serve as the Agreement Steward to a suitable separate
247 | entity. Each new version of the Agreement will be given a distinguishing
248 | version number. The Program (including Contributions) may always be
249 | Distributed subject to the version of the Agreement under which it was
250 | received. In addition, after a new version of the Agreement is published,
251 | Contributor may elect to Distribute the Program (including its
252 | Contributions) under the new version.
253 |
254 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
255 | receives no rights or licenses to the intellectual property of any
256 | Contributor under this Agreement, whether expressly, by implication,
257 | estoppel or otherwise. All rights in the Program not expressly granted
258 | under this Agreement are reserved. Nothing in this Agreement is intended
259 | to be enforceable by any entity that is not a Contributor or Recipient.
260 | No third-party beneficiary rights are created under this Agreement.
261 |
262 | Exhibit A - Form of Secondary Licenses Notice
263 |
264 | "This Source Code may also be made available under the following
265 | Secondary Licenses when the conditions for such availability set forth
266 | in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
267 | version(s), and exceptions or additional permissions here}."
268 |
269 | Simply including a copy of this Agreement, including this Exhibit A
270 | is not sufficient to license the Source Code under Secondary Licenses.
271 |
272 | If it is not possible or desirable to put the notice in a particular
273 | file, then You may include the notice in a location (such as a LICENSE
274 | file in a relevant directory) where a recipient would be likely to
275 | look for such a notice.
276 |
277 | You may add additional accurate notices of copyright ownership.
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | image:https://img.shields.io/github/license/redstarssystems/rssyslib[license,link=LICENSE]
2 | image:https://img.shields.io/clojars/v/org.rssys.libtemplate/clj-template.svg[clojars,link=https://clojars.org/org.rssys.libtemplate/clj-template]
3 |
4 | == Library template
5 |
6 | :Author: Mike Ananev
7 | :Date: 17/04/2021
8 | :git: https://git-scm.com[git]
9 | :clojure-deps-cli: https://clojure.org/guides/getting_started[clojure deps cli]
10 | :clj-new: https://github.com/seancorfield/clj-new[clj-new]
11 | :babashka: https://github.com/babashka/babashka[babashka]
12 | :toc:
13 |
14 | WARNING: This project is deprecated. Use newer version from here https://github.com/redstarssystems/libtemplate
15 |
16 |
17 | === Intro
18 |
19 | This `Library template` helps you to quick start new library project using {clojure-deps-cli} and {clj-new}.
20 |
21 | This `Library template` provides:
22 |
23 | - project control using {babashka} tasks (v0.3.7+);
24 | - environment variables control and project configuration using `project-config.edn` file;
25 | - secrets & passwords control using `project-secrets.edn` file;
26 | - editor configuration via `.editorconfig` file;
27 | - configured `clj-kondo` linter;
28 | - configured `cljstyle` formatter;
29 | - run tests using https://github.com/lambdaisland/kaocha[kaocha].
30 |
31 | This template will give you the following basic project workflow:
32 | [source, bash]
33 | ----
34 | mike@mbp02 ✗ bb tasks
35 | build Build deployable jar file for this project
36 | bump Bump version artifact in `project-version` file, level may be one of: major, minor, patch, alpha, beta, rc, release.
37 | clean Clean target folder
38 | deploy Deploy this library to Clojars
39 | format Format source code
40 | install Install deployable jar locally (requires the pom.xml file)
41 | lint Lint source code
42 | outdated Check for outdated dependencies
43 | repl Run Clojure repl
44 | requirements Install project requirements
45 | test Run tests
46 | ----
47 |
48 |
49 | See also:
50 |
51 | * https://github.com/redstarssystems/rssysapp[Application template]
52 |
53 | === Using Library template
54 |
55 | ==== New library project
56 |
57 | Before creating a project from this template, please install prerequisites (see below).
58 | To create a project from this template just run:
59 |
60 | [source, bash]
61 | ----
62 | clojure -X:new :template org.rssys.libtemplate :name com.example/lib01
63 | cd lib01
64 | ----
65 | where `:new` is alias in `~/.clojure/deps.edn` file (see prerequisites below).
66 |
67 | NOTE: Please, see `README.adoc` in a root folder of created project to install other tools once.
68 |
69 |
70 | === Install prerequisites
71 |
72 | All these tools you need to install only once.
73 |
74 | . Install {clojure-deps-cli} tools
75 | .. MacOS
76 | +
77 | [source,bash]
78 | ----
79 | brew install clojure/tools/clojure
80 | ----
81 | .. Linux
82 | +
83 | Ensure that the following dependencies are installed in OS: `bash`, `curl`, `rlwrap`, and `Java`.
84 | +
85 | [source, bash]
86 | ----
87 | curl -O https://download.clojure.org/install/linux-install-1.10.3.822.sh
88 | chmod +x linux-install-1.10.3.822.sh
89 | sudo ./linux-install-1.10.3.822.sh
90 | ----
91 |
92 | . Install latest {clj-new} library to a file `~/.clojure/deps.edn`
93 | +
94 | [source, clojure]
95 | ----
96 | {
97 | :aliases {
98 | :new {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.297"}}
99 | :exec-fn clj-new/create}
100 | }
101 |
102 | }
103 | ----
104 |
105 | . Install {babashka} v0.3.7+
106 | .. MacOS
107 | +
108 | [source, bash]
109 | ----
110 | brew install borkdude/brew/babashka
111 | ----
112 | +
113 | .. Linux
114 | +
115 | [source, bash]
116 | ----
117 | sudo bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)
118 | ----
119 |
120 | === License
121 |
122 | Copyright © 2021 {Author} +
123 | Distributed under the Eclipse Public License 2.0 or (at your option) any later version.
124 |
125 |
126 |
--------------------------------------------------------------------------------
/bb.edn:
--------------------------------------------------------------------------------
1 | {:deps {cprop/cprop {:mvn/version "0.1.18"}}
2 | :tasks {:requires ([babashka.fs :as fs]
3 | [cprop.core :refer [load-config]]
4 | [cprop.source :refer [from-env]])
5 | ;; helpers and constants
6 | :init (do
7 | (def ansi-green "\u001B[32m") (def ansi-reset "\u001B[0m") (def ansi-yellow "\u001B[33m")
8 | (def target-folder "target")
9 | (defn current-date
10 | []
11 | (let [date (java.time.LocalDateTime/now)
12 | formatter (java.time.format.DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss")]
13 | (.format date formatter)))
14 | (def config (load-config :file "project-config.edn"))
15 | ;; uncomment this if you need local secrets. Now we use Github Actions.
16 | ;;(def secrets (load-config :file "project-secrets.edn"))
17 | (def env (from-env))
18 | (def version-file "project-version")
19 | (def version-id (clojure.string/trim (slurp version-file)))
20 | (def group-id (:group-id config))
21 | (def artifact-id (:artifact-id config))
22 | (def project-name (:project-name config))
23 | (def jar-filename (format "%s/%s-%s.jar" target-folder artifact-id version-id)))
24 | :enter (let [{:keys [name]} (current-task)] (println (clojure.core/format "%s[ ] %s %s%s" ansi-yellow name (current-date) ansi-reset)))
25 | :leave (let [{:keys [name]} (current-task)] (println (clojure.core/format "%s[✔]︎ %s %s%s" ansi-green name (current-date) ansi-reset)))
26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 | ;; commands
28 | clean {:doc "Clean target folder"
29 | :task (do (fs/delete-tree target-folder)
30 | (fs/create-dir target-folder))}
31 |
32 | build {:doc "Build deployable jar file for this project"
33 | :task (let [params (format "-X:jar :jar %s :group-id %s :artifact-id %s :version '\"%s\"'"
34 | jar-filename
35 | group-id
36 | artifact-id
37 | version-id)]
38 | (fs/create-dirs target-folder)
39 | (clojure params))}
40 |
41 | install {:doc "Install deployable jar locally (requires the pom.xml file)"
42 | :task (let [params (format "-X:install :installer :local :artifact '\"%s\"'" jar-filename)]
43 | (clojure params))}
44 |
45 | deploy {:doc "Deploy this library to Clojars"
46 | :task (let [cmd (format "clojure -X:install :installer :remote :artifact '\"%s\"'" jar-filename)
47 | ;; credentials for Clojars are set in Github Actions
48 | ;;env-vars {:CLOJARS_USERNAME (:clojars-username env)
49 | ;; :CLOJARS_PASSWORD (:clojars-password env)}
50 | ]
51 | (shell #_{:extra-env env-vars} cmd))}
52 |
53 | repl {:doc "Run Clojure repl"
54 | :task (clojure "-M:repl")}
55 |
56 | ;;use `bb outdated --upgrade` or `bb outdated --upgrade --force`
57 | outdated {:doc "Check for outdated dependencies"
58 | :task (clojure (str "-M:outdated " (apply str (interpose " " *command-line-args*))))}
59 |
60 | bump {:doc "Bump version artifact in `project-version` file, level may be one of: major, minor, patch, alpha, beta, rc, release."
61 | :task (let [param (first *command-line-args*)
62 | level (or (#{"major" "minor" "patch" "alpha" "beta" "rc" "release"} param) "patch")]
63 | (shell {:out version-file} (format "bb -f scripts/bump-semver.clj %s %s" version-id level))
64 | (println version-id "->" (clojure.string/trim (slurp version-file))))}
65 |
66 | requirements {:doc "Install project requirements"
67 | :task (let [os-name (clojure.string/lower-case (System/getProperty "os.name"))]
68 | (case os-name
69 | "mac os x" (do
70 | (shell "brew install git")
71 | (shell "brew install coreutils")
72 | (shell "brew install --cask cljstyle")
73 | (shell "brew install borkdude/brew/clj-kondo"))
74 | (println "Please, install manually the following tools: git, cljstyle, clj-kondo")))}}}
--------------------------------------------------------------------------------
/deps.edn:
--------------------------------------------------------------------------------
1 | {:paths ["src" "resources"]
2 |
3 | :deps {org.clojure/clojure {:mvn/version "1.10.3"}
4 | seancorfield/clj-new {:mvn/version "1.1.309"}}
5 |
6 | :aliases {
7 | :new {:exec-fn clj-new/create
8 | :exec-args {:template "rssyslib"}}
9 |
10 | :test {:extra-paths ["test"]
11 | :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}}}
12 |
13 | :repl {:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}
14 | healthsamurai/matcho {:mvn/version "0.3.7"}
15 | criterium/criterium {:mvn/version "0.4.6"}
16 | hashp/hashp {:mvn/version "0.2.1"}}
17 | :extra-paths ["dev/src" "resources" "test"]
18 | :jvm-opts []
19 | :main-opts ["--main" "nrepl.cmdline"]}
20 |
21 | :jar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.0.216"}}
22 | :exec-fn hf.depstar/jar
23 | :exec-args {:jar "rssyslib.jar" :sync-pom true}}
24 |
25 | :install {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}}
26 | :exec-fn deps-deploy.deps-deploy/deploy}
27 |
28 | :deploy {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}}
29 | :exec-fn deps-deploy.deps-deploy/deploy}
30 |
31 | :outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "0.15.2"}}
32 | :main-opts ["-m" "antq.core"]}}}
33 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | org.rssys.libtemplate
5 | clj-template
6 | 2.0.5
7 | rssyslib
8 | Red Stars Systems library template.
9 | https://github.com/redstarssystems/rssyslib
10 |
11 |
12 | Eclipse Public License
13 | http://www.eclipse.org/legal/epl-v20.html
14 |
15 |
16 |
17 |
18 | Mike Ananev
19 |
20 |
21 |
22 | https://github.com/redstarssystems/rssyslib
23 | scm:git:git://github.com/redstarssystems/rssyslib.git
24 | scm:git:ssh://git@github.com/redstarssystems/rssyslib.git
25 | HEAD
26 |
27 |
28 |
29 | org.clojure
30 | clojure
31 | 1.10.3
32 |
33 |
34 | seancorfield
35 | clj-new
36 | 1.1.309
37 |
38 |
39 |
40 | src
41 |
42 |
43 |
44 | clojars
45 | https://repo.clojars.org/
46 |
47 |
48 |
49 |
50 | clojars
51 | Clojars repository
52 | https://clojars.org/repo
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/project-config.edn:
--------------------------------------------------------------------------------
1 | ;; Project configuration
2 | ;; Put here your environment variables and public configuration parameters for this project
3 | {
4 | :project-name "libtemplate"
5 | :group-id "org.rssys.libtemplate"
6 | :artifact-id "clj-template"
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/project-version:
--------------------------------------------------------------------------------
1 | 2.0.5
2 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/.clj-kondo/config.edn:
--------------------------------------------------------------------------------
1 | {:output {:exclude-files ["target/*"]}
2 |
3 | :linters {:consistent-alias
4 | {:aliases {clojure.string string}}
5 |
6 | :unresolved-namespace
7 | {:exclude [user criterium.core]}
8 |
9 | :unresolved-symbol
10 | {:exclude [(cljs.test/are [thrown? thrown-with-msg?])
11 | (cljs.test/is [thrown? thrown-with-msg?])
12 | (clojure.test/are [thrown? thrown-with-msg?])
13 | (clojure.test/is [thrown? thrown-with-msg?])]}
14 |
15 | :unsorted-required-namespaces
16 | {:level :warning}
17 |
18 | :unused-referred-var
19 | {:exclude {clojure.test [is deftest testing use-fixtures]}}}
20 |
21 | :skip-comments true}
22 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/.cljstyle:
--------------------------------------------------------------------------------
1 | {:rules {:indentation {:indents {#".*" [[:inner 0]]}},
2 | :blank-lines {:trim-consecutive? false :max-consecutive 3}
3 | :types {:enabled? false}
4 | :namespaces {:import-break-width 120}}
5 |
6 | :align-associative? true
7 |
8 | :files {:ignore #{".clj-kondo" ".idea" ".cpcache" "target" ".git"}}
9 |
10 | :test-code (concat
11 | [2]
12 | (map
13 | (fn* [p1__5#] (inc (* p1__5# 2)))
14 | (filter (fn* [p1__6#] (aget sieved p1__6#)) (range 1 hn)))
15 | (->> [1 2 3] (filter odd?) (vec)))}
16 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/.editorconfig:
--------------------------------------------------------------------------------
1 |
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_style = space
8 | indent_size = 2
9 | insert_final_newline = true
10 | max_line_length = 120
11 | trim_trailing_whitespace = true
12 |
13 |
14 | [{*.md, *.adoc}]
15 | trim_trailing_whitespace = false
16 |
17 |
18 | [*.xml]
19 | indent_size = 4
20 |
21 |
22 | [{*.yml, *.yaml}]
23 | max_line_length = 200
24 |
25 |
26 | [Makefile]
27 | indent_size = 4
28 | indent_style = tab
29 |
30 | [Justfile]
31 | indent_size = 4
32 | indent_style = tab
33 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/.gitignore:
--------------------------------------------------------------------------------
1 | # exclude whole folders with logs
2 | log
3 | logs
4 |
5 | # exclude clj-kondo files except config
6 | .clj-kondo/*
7 | !*.clj-kondo/config.edn
8 |
9 | # exclude all .idea except some subfolders
10 | .idea/*
11 | !.idea/clojure-deps.xml
12 | !.idea/codeStyles/
13 | !.idea/copyright/
14 |
15 | # standard (default) exclusions
16 | /target
17 | /classes
18 | /checkouts
19 | *.jar
20 | *.class
21 | *.xml.asc
22 | /.cpcache
23 | /.lein-*
24 | /.nrepl-history
25 | /.nrepl-port
26 | .hgignore
27 | .hg/
28 |
29 |
30 | # exclude common files
31 | *.iml
32 | trace.edn
33 | .eastwood
34 | .nrepl-port
35 |
36 | # exclude private configs with sensitive data
37 | project-secrets.edn
38 |
39 | # allow public env vars for project
40 | !project-config.edn
41 |
42 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/CHANGELOG.adoc:
--------------------------------------------------------------------------------
1 | == Changelog
2 |
3 | === [0.1.0-SNAPSHOT] - {{date}}
4 |
5 | Initial release.
6 |
7 | ==== Added
8 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/LICENSE:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 2.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
5 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6 |
7 | 1. DEFINITIONS
8 |
9 | "Contribution" means:
10 |
11 | a) in the case of the initial Contributor, the initial content
12 | Distributed under this Agreement, and
13 |
14 | b) in the case of each subsequent Contributor:
15 | i) changes to the Program, and
16 | ii) additions to the Program;
17 | where such changes and/or additions to the Program originate from
18 | and are Distributed by that particular Contributor. A Contribution
19 | "originates" from a Contributor if it was added to the Program by
20 | such Contributor itself or anyone acting on such Contributor's behalf.
21 | Contributions do not include changes or additions to the Program that
22 | are not Modified Works.
23 |
24 | "Contributor" means any person or entity that Distributes the Program.
25 |
26 | "Licensed Patents" mean patent claims licensable by a Contributor which
27 | are necessarily infringed by the use or sale of its Contribution alone
28 | or when combined with the Program.
29 |
30 | "Program" means the Contributions Distributed in accordance with this
31 | Agreement.
32 |
33 | "Recipient" means anyone who receives the Program under this Agreement
34 | or any Secondary License (as applicable), including Contributors.
35 |
36 | "Derivative Works" shall mean any work, whether in Source Code or other
37 | form, that is based on (or derived from) the Program and for which the
38 | editorial revisions, annotations, elaborations, or other modifications
39 | represent, as a whole, an original work of authorship.
40 |
41 | "Modified Works" shall mean any work in Source Code or other form that
42 | results from an addition to, deletion from, or modification of the
43 | contents of the Program, including, for purposes of clarity any new file
44 | in Source Code form that contains any contents of the Program. Modified
45 | Works shall not include works that contain only declarations,
46 | interfaces, types, classes, structures, or files of the Program solely
47 | in each case in order to link to, bind by name, or subclass the Program
48 | or Modified Works thereof.
49 |
50 | "Distribute" means the acts of a) distributing or b) making available
51 | in any manner that enables the transfer of a copy.
52 |
53 | "Source Code" means the form of a Program preferred for making
54 | modifications, including but not limited to software source code,
55 | documentation source, and configuration files.
56 |
57 | "Secondary License" means either the GNU General Public License,
58 | Version 2.0, or any later versions of that license, including any
59 | exceptions or additional permissions as identified by the initial
60 | Contributor.
61 |
62 | 2. GRANT OF RIGHTS
63 |
64 | a) Subject to the terms of this Agreement, each Contributor hereby
65 | grants Recipient a non-exclusive, worldwide, royalty-free copyright
66 | license to reproduce, prepare Derivative Works of, publicly display,
67 | publicly perform, Distribute and sublicense the Contribution of such
68 | Contributor, if any, and such Derivative Works.
69 |
70 | b) Subject to the terms of this Agreement, each Contributor hereby
71 | grants Recipient a non-exclusive, worldwide, royalty-free patent
72 | license under Licensed Patents to make, use, sell, offer to sell,
73 | import and otherwise transfer the Contribution of such Contributor,
74 | if any, in Source Code or other form. This patent license shall
75 | apply to the combination of the Contribution and the Program if, at
76 | the time the Contribution is added by the Contributor, such addition
77 | of the Contribution causes such combination to be covered by the
78 | Licensed Patents. The patent license shall not apply to any other
79 | combinations which include the Contribution. No hardware per se is
80 | licensed hereunder.
81 |
82 | c) Recipient understands that although each Contributor grants the
83 | licenses to its Contributions set forth herein, no assurances are
84 | provided by any Contributor that the Program does not infringe the
85 | patent or other intellectual property rights of any other entity.
86 | Each Contributor disclaims any liability to Recipient for claims
87 | brought by any other entity based on infringement of intellectual
88 | property rights or otherwise. As a condition to exercising the
89 | rights and licenses granted hereunder, each Recipient hereby
90 | assumes sole responsibility to secure any other intellectual
91 | property rights needed, if any. For example, if a third party
92 | patent license is required to allow Recipient to Distribute the
93 | Program, it is Recipient's responsibility to acquire that license
94 | before distributing the Program.
95 |
96 | d) Each Contributor represents that to its knowledge it has
97 | sufficient copyright rights in its Contribution, if any, to grant
98 | the copyright license set forth in this Agreement.
99 |
100 | e) Notwithstanding the terms of any Secondary License, no
101 | Contributor makes additional grants to any Recipient (other than
102 | those set forth in this Agreement) as a result of such Recipient's
103 | receipt of the Program under the terms of a Secondary License
104 | (if permitted under the terms of Section 3).
105 |
106 | 3. REQUIREMENTS
107 |
108 | 3.1 If a Contributor Distributes the Program in any form, then:
109 |
110 | a) the Program must also be made available as Source Code, in
111 | accordance with section 3.2, and the Contributor must accompany
112 | the Program with a statement that the Source Code for the Program
113 | is available under this Agreement, and informs Recipients how to
114 | obtain it in a reasonable manner on or through a medium customarily
115 | used for software exchange; and
116 |
117 | b) the Contributor may Distribute the Program under a license
118 | different than this Agreement, provided that such license:
119 | i) effectively disclaims on behalf of all other Contributors all
120 | warranties and conditions, express and implied, including
121 | warranties or conditions of title and non-infringement, and
122 | implied warranties or conditions of merchantability and fitness
123 | for a particular purpose;
124 |
125 | ii) effectively excludes on behalf of all other Contributors all
126 | liability for damages, including direct, indirect, special,
127 | incidental and consequential damages, such as lost profits;
128 |
129 | iii) does not attempt to limit or alter the recipients' rights
130 | in the Source Code under section 3.2; and
131 |
132 | iv) requires any subsequent distribution of the Program by any
133 | party to be under a license that satisfies the requirements
134 | of this section 3.
135 |
136 | 3.2 When the Program is Distributed as Source Code:
137 |
138 | a) it must be made available under this Agreement, or if the
139 | Program (i) is combined with other material in a separate file or
140 | files made available under a Secondary License, and (ii) the initial
141 | Contributor attached to the Source Code the notice described in
142 | Exhibit A of this Agreement, then the Program may be made available
143 | under the terms of such Secondary Licenses, and
144 |
145 | b) a copy of this Agreement must be included with each copy of
146 | the Program.
147 |
148 | 3.3 Contributors may not remove or alter any copyright, patent,
149 | trademark, attribution notices, disclaimers of warranty, or limitations
150 | of liability ("notices") contained within the Program from any copy of
151 | the Program which they Distribute, provided that Contributors may add
152 | their own appropriate notices.
153 |
154 | 4. COMMERCIAL DISTRIBUTION
155 |
156 | Commercial distributors of software may accept certain responsibilities
157 | with respect to end users, business partners and the like. While this
158 | license is intended to facilitate the commercial use of the Program,
159 | the Contributor who includes the Program in a commercial product
160 | offering should do so in a manner which does not create potential
161 | liability for other Contributors. Therefore, if a Contributor includes
162 | the Program in a commercial product offering, such Contributor
163 | ("Commercial Contributor") hereby agrees to defend and indemnify every
164 | other Contributor ("Indemnified Contributor") against any losses,
165 | damages and costs (collectively "Losses") arising from claims, lawsuits
166 | and other legal actions brought by a third party against the Indemnified
167 | Contributor to the extent caused by the acts or omissions of such
168 | Commercial Contributor in connection with its distribution of the Program
169 | in a commercial product offering. The obligations in this section do not
170 | apply to any claims or Losses relating to any actual or alleged
171 | intellectual property infringement. In order to qualify, an Indemnified
172 | Contributor must: a) promptly notify the Commercial Contributor in
173 | writing of such claim, and b) allow the Commercial Contributor to control,
174 | and cooperate with the Commercial Contributor in, the defense and any
175 | related settlement negotiations. The Indemnified Contributor may
176 | participate in any such claim at its own expense.
177 |
178 | For example, a Contributor might include the Program in a commercial
179 | product offering, Product X. That Contributor is then a Commercial
180 | Contributor. If that Commercial Contributor then makes performance
181 | claims, or offers warranties related to Product X, those performance
182 | claims and warranties are such Commercial Contributor's responsibility
183 | alone. Under this section, the Commercial Contributor would have to
184 | defend claims against the other Contributors related to those performance
185 | claims and warranties, and if a court requires any other Contributor to
186 | pay any damages as a result, the Commercial Contributor must pay
187 | those damages.
188 |
189 | 5. NO WARRANTY
190 |
191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
192 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
193 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
194 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
195 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
196 | PURPOSE. Each Recipient is solely responsible for determining the
197 | appropriateness of using and distributing the Program and assumes all
198 | risks associated with its exercise of rights under this Agreement,
199 | including but not limited to the risks and costs of program errors,
200 | compliance with applicable laws, damage to or loss of data, programs
201 | or equipment, and unavailability or interruption of operations.
202 |
203 | 6. DISCLAIMER OF LIABILITY
204 |
205 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
206 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
207 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
208 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
209 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
210 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
211 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
212 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
213 | POSSIBILITY OF SUCH DAMAGES.
214 |
215 | 7. GENERAL
216 |
217 | If any provision of this Agreement is invalid or unenforceable under
218 | applicable law, it shall not affect the validity or enforceability of
219 | the remainder of the terms of this Agreement, and without further
220 | action by the parties hereto, such provision shall be reformed to the
221 | minimum extent necessary to make such provision valid and enforceable.
222 |
223 | If Recipient institutes patent litigation against any entity
224 | (including a cross-claim or counterclaim in a lawsuit) alleging that the
225 | Program itself (excluding combinations of the Program with other software
226 | or hardware) infringes such Recipient's patent(s), then such Recipient's
227 | rights granted under Section 2(b) shall terminate as of the date such
228 | litigation is filed.
229 |
230 | All Recipient's rights under this Agreement shall terminate if it
231 | fails to comply with any of the material terms or conditions of this
232 | Agreement and does not cure such failure in a reasonable period of
233 | time after becoming aware of such noncompliance. If all Recipient's
234 | rights under this Agreement terminate, Recipient agrees to cease use
235 | and distribution of the Program as soon as reasonably practicable.
236 | However, Recipient's obligations under this Agreement and any licenses
237 | granted by Recipient relating to the Program shall continue and survive.
238 |
239 | Everyone is permitted to copy and distribute copies of this Agreement,
240 | but in order to avoid inconsistency the Agreement is copyrighted and
241 | may only be modified in the following manner. The Agreement Steward
242 | reserves the right to publish new versions (including revisions) of
243 | this Agreement from time to time. No one other than the Agreement
244 | Steward has the right to modify this Agreement. The Eclipse Foundation
245 | is the initial Agreement Steward. The Eclipse Foundation may assign the
246 | responsibility to serve as the Agreement Steward to a suitable separate
247 | entity. Each new version of the Agreement will be given a distinguishing
248 | version number. The Program (including Contributions) may always be
249 | Distributed subject to the version of the Agreement under which it was
250 | received. In addition, after a new version of the Agreement is published,
251 | Contributor may elect to Distribute the Program (including its
252 | Contributions) under the new version.
253 |
254 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
255 | receives no rights or licenses to the intellectual property of any
256 | Contributor under this Agreement, whether expressly, by implication,
257 | estoppel or otherwise. All rights in the Program not expressly granted
258 | under this Agreement are reserved. Nothing in this Agreement is intended
259 | to be enforceable by any entity that is not a Contributor or Recipient.
260 | No third-party beneficiary rights are created under this Agreement.
261 |
262 | Exhibit A - Form of Secondary Licenses Notice
263 |
264 | "This Source Code may also be made available under the following
265 | Secondary Licenses when the conditions for such availability set forth
266 | in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
267 | version(s), and exceptions or additional permissions here}."
268 |
269 | Simply including a copy of this Agreement, including this Exhibit A
270 | is not sufficient to license the Source Code under Secondary Licenses.
271 |
272 | If it is not possible or desirable to put the notice in a particular
273 | file, then You may include the notice in a location (such as a LICENSE
274 | file in a relevant directory) where a recipient would be likely to
275 | look for such a notice.
276 |
277 | You may add additional accurate notices of copyright ownership.
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/README.adoc:
--------------------------------------------------------------------------------
1 | == {{name}}
2 | :git: https://git-scm.com[git]
3 | :clojure-deps-cli: https://clojure.org/guides/getting_started[clojure deps cli]
4 | :clj-new: https://github.com/seancorfield/clj-new[clj-new]
5 | :babashka: https://github.com/babashka/babashka[babashka]
6 | :toc:
7 |
8 | Project {{name}} generated from library template https://github.com/redstarssystems/rssyslib.
9 |
10 |
11 | === Install project prerequisites
12 |
13 | All these tools you need to install only once.
14 |
15 | . Install {clojure-deps-cli} tools
16 | .. MacOS
17 | +
18 | [source,bash]
19 | ----
20 | brew install clojure/tools/clojure
21 | ----
22 | .. Linux
23 | +
24 | Ensure that the following dependencies are installed in OS: `bash`, `curl`, `rlwrap`, and `Java`.
25 | +
26 | [source, bash]
27 | ----
28 | curl -O https://download.clojure.org/install/linux-install-1.10.3.822.sh
29 | chmod +x linux-install-1.10.3.822.sh
30 | sudo ./linux-install-1.10.3.822.sh
31 | ----
32 |
33 | . Install latest {clj-new} library to a file `~/.clojure/deps.edn`
34 | +
35 | [source, clojure]
36 | ----
37 | {
38 | :aliases {
39 | :new {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.297"}}
40 | :exec-fn clj-new/create}
41 | }
42 | }
43 | ----
44 |
45 | . Install {babashka} v0.3.7+
46 | .. MacOS
47 | +
48 | [source, bash]
49 | ----
50 | brew install borkdude/brew/babashka
51 | ----
52 | +
53 | .. Linux
54 | +
55 | [source, bash]
56 | ----
57 | sudo bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)
58 | ----
59 |
60 | . Run once:
61 | +
62 | [source,bash]
63 | ----
64 | bb requirements
65 | ----
66 | to install other necessary tools (MacOS only, for Linux manual instruction).
67 |
68 | === Project workflow
69 |
70 | To configure project workflow scripts use `bb.edn`.
71 |
72 | To configure project version use file `project-version`
73 |
74 | To configure `group-id` and `artifact-id` for jar file use file `project-config`
75 |
76 | Run `bb tasks` to show help for project workflow.
77 |
78 | List of available tasks:
79 | [source, bash]
80 | ----
81 | build Build deployable jar file for this project
82 | bump Bump version artifact in `project-version` file, level may be one of: major, minor, patch, alpha, beta, rc, release.
83 | clean Clean target folder
84 | deploy Deploy this library to Clojars
85 | format Format source code
86 | install Install deployable jar locally (requires the pom.xml file)
87 | lint Lint source code
88 | outdated Check for outdated dependencies
89 | repl Run Clojure repl
90 | requirements Install project requirements
91 | test Run tests
92 | ----
93 |
94 | === License
95 |
96 | Copyright © 2021 {{user}} +
97 | Distributed under the Eclipse Public License 2.0 or (at your option) any later version.
98 |
99 |
100 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/bb.edn:
--------------------------------------------------------------------------------
1 | {:deps {cprop/cprop {:mvn/version "0.1.18"}}
2 | :tasks {:requires ([babashka.fs :as fs]
3 | [cprop.core :refer [load-config]]
4 | [cprop.source :refer [from-env]])
5 | ;; helpers and constants
6 | :init (do
7 | (def ansi-green "\u001B[32m") (def ansi-reset "\u001B[0m") (def ansi-yellow "\u001B[33m")
8 | (def target-folder "target")
9 | (defn current-date
10 | []
11 | (let [date (java.time.LocalDateTime/now)
12 | formatter (java.time.format.DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss")]
13 | (.format date formatter)))
14 | (def config (load-config :file "project-config.edn"))
15 | (def secrets (load-config :file "project-secrets.edn"))
16 | (def env (from-env))
17 | (def version-file "project-version")
18 | (def version-id (clojure.string/trim (slurp version-file)))
19 | (def group-id (:group-id config))
20 | (def artifact-id (:artifact-id config))
21 | (def project-name (:project-name config))
22 | (def jar-filename (format "%s/%s-%s.jar" target-folder artifact-id version-id)))
23 | :enter (let [{:keys [name]} (current-task)] (println (clojure.core/format "%s[ ] %s %s%s" ansi-yellow name (current-date) ansi-reset)))
24 | :leave (let [{:keys [name]} (current-task)] (println (clojure.core/format "%s[✔]︎ %s %s%s" ansi-green name (current-date) ansi-reset)))
25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 | ;; commands
27 | clean {:doc "Clean target folder"
28 | :task (do (fs/delete-tree target-folder)
29 | (fs/create-dir target-folder))}
30 |
31 | build {:doc "Build deployable jar file for this project"
32 | :task (let [params (format "-X:jar :jar %s :group-id %s :artifact-id %s :version '\"%s\"'"
33 | jar-filename
34 | group-id
35 | artifact-id
36 | version-id)]
37 | (fs/create-dirs target-folder)
38 | (clojure params))}
39 |
40 | install {:doc "Install deployable jar locally (requires the pom.xml file)"
41 | :task (let [params (format "-X:install :installer :local :artifact '\"%s\"'" jar-filename)]
42 | (clojure params))}
43 |
44 | deploy {:doc "Deploy this library to Clojars"
45 | :task (let [cmd (format "clojure -X:install :installer :remote :artifact '\"%s\"'" jar-filename)
46 | env-vars {:CLOJARS_USERNAME (:clojars/username secrets)
47 | :CLOJARS_PASSWORD (:clojars/password secrets)}]
48 | (shell {:extra-env env-vars} cmd))}
49 |
50 | repl {:doc "Run Clojure repl"
51 | :task (clojure "-M:repl")}
52 |
53 | ;;use `bb outdated --upgrade` or `bb outdated --upgrade --force`
54 | outdated {:doc "Check for outdated dependencies"
55 | :task (clojure (str "-M:outdated " (apply str (interpose " " *command-line-args*))))}
56 |
57 | bump {:doc "Bump version artifact in `project-version` file, level may be one of: major, minor, patch, alpha, beta, rc, release."
58 | :task (let [param (first *command-line-args*)
59 | level (or (#{"major" "minor" "patch" "alpha" "beta" "rc" "release"} param) "patch")]
60 | (shell {:out version-file} (format "bb -f scripts/bump-semver.clj %s %s" version-id level))
61 | (println version-id "->" (clojure.string/trim (slurp version-file))))}
62 |
63 | test {:doc "Run tests"
64 | :task (clojure (str "-M:test " (apply str (interpose " " *command-line-args*))))}
65 |
66 | format {:doc "Format source code"
67 | :task (do (shell "cljstyle fix"))}
68 |
69 | lint {:doc "Lint source code"
70 | :task (do (shell "clj-kondo --parallel --lint src:test:dev/src")
71 | (shell "cljstyle check"))}
72 |
73 | requirements {:doc "Install project requirements"
74 | :task (let [os-name (clojure.string/lower-case (System/getProperty "os.name"))]
75 | (case os-name
76 | "mac os x" (do
77 | (shell "brew install git")
78 | (shell "brew install coreutils")
79 | (shell "brew install --cask cljstyle")
80 | (shell "brew install borkdude/brew/clj-kondo"))
81 | (println "Please, install manually the following tools: git, cljstyle, clj-kondo")))}}}
82 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/deps.edn:
--------------------------------------------------------------------------------
1 | {
2 | :mvn/repos {"clojars" {:url "https://repo.clojars.org/"}
3 | "central" {:url "https://repo1.maven.org/maven2/"}}
4 |
5 | :paths ["src" "resources"]
6 |
7 | :deps {org.clojure/clojure {:mvn/version "1.10.3"}}
8 |
9 | :aliases {
10 | :repl {:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}
11 | healthsamurai/matcho {:mvn/version "0.3.7"}
12 | criterium/criterium {:mvn/version "0.4.6"}
13 | hashp/hashp {:mvn/version "0.2.1"}}
14 | :extra-paths ["dev/src" "resources" "test"]
15 | :jvm-opts []
16 | :main-opts ["--main" "nrepl.cmdline"]}
17 |
18 | :test {:extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
19 | healthsamurai/matcho {:mvn/version "0.3.7"}
20 | lambdaisland/kaocha {:mvn/version "1.0.861"}
21 | lambdaisland/kaocha-cloverage {:mvn/version "1.0.75"}}
22 | :extra-paths ["resources" "test" "test/resources"]
23 | :jvm-opts []
24 | :main-opts ["--main" "kaocha.runner"]}
25 |
26 | :jar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.0.216"}}
27 | :exec-fn hf.depstar/jar
28 | :exec-args {:jar "{{name}}.jar" :sync-pom true}}
29 |
30 | :install {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}}
31 | :exec-fn deps-deploy.deps-deploy/deploy
32 | :exec-args {:installer :local :artifact "{{name}}.jar"}}
33 |
34 | :deploy {:replace-deps {slipset/deps-deploy {:mvn/version "0.1.5"}}
35 | :exec-fn deps-deploy.deps-deploy/deploy
36 | :exec-args {:installer :remote :artifact "{{name}}.jar"}}
37 |
38 | :outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "0.15.2"}}
39 | :main-opts ["-m" "antq.core"]}
40 | }}
41 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/dev/src/user.clj:
--------------------------------------------------------------------------------
1 | (ns user
2 | (:require
3 | [hashp.core]))
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | {{namespace}}
5 | {{name}}
6 | 0.1.0-SNAPSHOT
7 | {{name}}
8 | FIXME project name.
9 | https://github.com/FIXME
10 |
11 |
12 | Eclipse Public License
13 | http://www.eclipse.org/legal/epl-v20.html
14 |
15 |
16 |
17 |
18 | {{user}}
19 |
20 |
21 |
22 | https://github.com/FIXME
23 | scm:git:git://github.com/FIXME.git
24 | scm:git:ssh://git@github.com/FIXME.git
25 | HEAD
26 |
27 |
28 |
29 | org.clojure
30 | clojure
31 | 1.10.3
32 |
33 |
34 |
35 | src
36 |
37 |
38 |
39 | clojars
40 | https://repo.clojars.org/
41 |
42 |
43 |
44 |
45 | clojars
46 | Clojars repository
47 | https://clojars.org/repo
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/project-config.edn:
--------------------------------------------------------------------------------
1 | ;; Project configuration
2 | ;; Put here your environment variables and public configuration parameters for this project
3 | {
4 | :project-name {{namespace}}
5 | :group-id {{group}}
6 | :artifact-id {{name}}
7 | :git/url ""
8 | }
9 |
10 |
11 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/project-secrets.edn:
--------------------------------------------------------------------------------
1 | ;; Project private configuration
2 | ;; Put project passwords and other secrets here
3 |
4 | {:clojars/username ""
5 | :clojars/password ""}
6 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/project-version:
--------------------------------------------------------------------------------
1 | 0.1.0-SNAPSHOT
2 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/resources/readme.txt:
--------------------------------------------------------------------------------
1 | Put resources in this folder.
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/scripts/bump-semver.clj:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; the code below is taken from Leiningen
3 | ;; https://github.com/technomancy/leiningen/blob/master/src/leiningen/release.clj
4 |
5 | (def ^:dynamic *level* nil)
6 |
7 |
8 | (defn string->semantic-version
9 | [version-string]
10 | "Create map representing the given version string. Returns nil if the
11 | string does not follow guidelines setforth by Semantic Versioning 2.0.0,
12 | http://semver.org/"
13 | ;; ..[-][-SNAPSHOT]
14 | (if-let [[_ major minor patch qualifier snapshot]
15 | (re-matches
16 | #"(\d+)\.(\d+)\.(\d+)(?:-(?!SNAPSHOT)([^\-]+))?(?:-(SNAPSHOT))?"
17 | version-string)]
18 | (->> [major minor patch]
19 | (map #(Integer/parseInt %))
20 | (zipmap [:major :minor :patch])
21 | (merge {:qualifier qualifier
22 | :snapshot snapshot}))))
23 |
24 |
25 | (defn parse-semantic-version
26 | [version-string]
27 | "Create map representing the given version string. Aborts with exit code 1
28 | if the string does not follow guidelines setforth by Semantic Versioning 2.0.0,
29 | http://semver.org/"
30 | (or (string->semantic-version version-string)
31 | (throw (ex-info "Unrecognized version string:" {:version version-string}))))
32 |
33 |
34 | (defn version-map->string
35 | "Given a version-map, return a string representing the version."
36 | [version-map]
37 | (let [{:keys [major minor patch qualifier snapshot]} version-map]
38 | (cond-> (str major "." minor "." patch)
39 | qualifier (str "-" qualifier)
40 | snapshot (str "-" snapshot))))
41 |
42 |
43 | (defn next-qualifier
44 | "Increments and returns the qualifier. If an explicit `sublevel`
45 | is provided, then, if the original qualifier was using that sublevel,
46 | increments it, else returns that sublevel with \"1\" appended.
47 | Supports empty strings for sublevel, in which case the return value
48 | is effectively a BuildNumber."
49 | ([qualifier]
50 | (if-let [[_ sublevel] (re-matches #"([^\d]+)?(?:\d+)?"
51 | (or qualifier ""))]
52 | (next-qualifier sublevel qualifier)
53 | "1"))
54 | ([sublevel qualifier]
55 | (let [pattern (re-pattern (str sublevel "([0-9]+)"))
56 | [_ n] (and qualifier (re-find pattern qualifier))]
57 | (str sublevel (inc (Integer. (or n 0)))))))
58 |
59 |
60 | (defn bump-version-map
61 | "Given version as a map of the sort returned by parse-semantic-version, return
62 | a map of the version incremented in the level argument. Always returns a
63 | SNAPSHOT version, unless the level is :release. For :release, removes SNAPSHOT
64 | if the input is a SNAPSHOT, removes qualifier if the input is not a SNAPSHOT."
65 | [{:keys [major minor patch qualifier snapshot]} level value]
66 | (let [level (or level
67 | (if qualifier :qualifier)
68 | :patch)]
69 | (case (keyword (name level))
70 | :major {:major (if value value (inc major)) :minor 0 :patch 0 :qualifier nil :snapshot "SNAPSHOT"}
71 | :minor {:major major :minor (if value value (inc minor)) :patch 0 :qualifier nil :snapshot "SNAPSHOT"}
72 | :patch {:major major :minor minor :patch (if value value (inc patch)) :qualifier nil :snapshot "SNAPSHOT"}
73 | :alpha {:major major :minor minor :patch patch
74 | :qualifier (next-qualifier "alpha" qualifier)
75 | :snapshot "SNAPSHOT"}
76 | :beta {:major major :minor minor :patch patch
77 | :qualifier (next-qualifier "beta" qualifier)
78 | :snapshot "SNAPSHOT"}
79 | :rc {:major major :minor minor :patch patch
80 | :qualifier (next-qualifier "RC" qualifier)
81 | :snapshot "SNAPSHOT"}
82 | :qualifier {:major major :minor minor :patch patch
83 | :qualifier (next-qualifier qualifier)
84 | :snapshot "SNAPSHOT"}
85 | :release (merge {:major major :minor minor :patch patch}
86 | (if snapshot
87 | {:qualifier qualifier :snapshot nil}
88 | {:qualifier nil :snapshot nil})))))
89 |
90 |
91 | (defn bump-version
92 | "Given a version string, return the bumped version string -
93 | incremented at the indicated level. Add qualifier unless releasing
94 | non-snapshot. Level defaults to *level*."
95 | [version-str & [level value]]
96 | (-> version-str
97 | (parse-semantic-version)
98 | (bump-version-map (or level *level*) value)
99 | (version-map->string)))
100 |
101 | ;; end of Leiningen code
102 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 |
104 |
105 | (let [version (first *command-line-args*)
106 | level (second *command-line-args*)
107 | value (first (drop 2 *command-line-args*))]
108 | (try
109 | (println (bump-version version level value))
110 | (catch Exception e
111 | (binding [*out* *err*]
112 | (println "Error processing version value: " version " " (.getMessage e)))
113 | (println version))))
114 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/src/core.clj:
--------------------------------------------------------------------------------
1 | (ns {{namespace}}.core)
2 |
3 | (defn foo
4 | "simple fn"
5 | []
6 | (println "foo function."))
7 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/test/core_test.clj:
--------------------------------------------------------------------------------
1 | (ns {{namespace}}.core-test
2 | (:require [clojure.test :refer [deftest testing is]]
3 | [matcho.core :refer [match]]))
4 |
5 |
6 | (deftest ^:unit a-test
7 | (testing "simple test."
8 | (is (= 1 1))
9 | (match {:a 1} {:a int?})))
10 |
--------------------------------------------------------------------------------
/resources/clj/new/rssyslib/tests.edn:
--------------------------------------------------------------------------------
1 | #kaocha/v1
2 | {:kaocha/fail-fast? false
3 | :kaocha/color? true
4 | :kaocha/reporter [kaocha.report/documentation]
5 |
6 | :kaocha.plugin.randomize/randomize? true
7 | :kaocha.plugin.profiling/count 3
8 | :kaocha.plugin.profiling/profiling? true
9 |
10 | :capture-output? true
11 |
12 | :plugins [:kaocha.plugin/randomize
13 | :kaocha.plugin/filter
14 | :kaocha.plugin/capture-output
15 | :kaocha.plugin/profiling
16 | :kaocha.plugin/cloverage
17 | :kaocha.plugin/print-invocations
18 | :kaocha.plugin/hooks
19 | :kaocha.plugin/notifier
20 | :kaocha.plugin.alpha/info]
21 |
22 | :tests [{:id :unit
23 | :source-paths ["src"]
24 | ;; :test-paths ["test/src"]
25 | :focus-meta [:unit]}
26 |
27 | ;;{:id :integration
28 | ;; :source-paths ["src"]
29 | ;; :test-paths ["test/src"]
30 | ;; :focus-meta [:integration]}
31 | ]
32 |
33 |
34 | :cloverage/opts {:output "target/coverage"
35 | :ns-regex []
36 | :ns-exclude-regex []
37 | :fail-threshold 0
38 | :low-watermark 50
39 | :high-watermark 80
40 | :summary? true
41 | :text? false
42 | :emma-xml? false
43 | :html? true
44 | :nop? false
45 | :lcov? false
46 | :coveralls? false
47 | :codecov? true}}
48 |
--------------------------------------------------------------------------------
/scripts/bump-semver.clj:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;; the code below is taken from Leiningen
3 | ;; https://github.com/technomancy/leiningen/blob/master/src/leiningen/release.clj
4 |
5 | (def ^:dynamic *level* nil)
6 |
7 |
8 | (defn string->semantic-version
9 | [version-string]
10 | "Create map representing the given version string. Returns nil if the
11 | string does not follow guidelines setforth by Semantic Versioning 2.0.0,
12 | http://semver.org/"
13 | ;; ..[-][-SNAPSHOT]
14 | (if-let [[_ major minor patch qualifier snapshot]
15 | (re-matches
16 | #"(\d+)\.(\d+)\.(\d+)(?:-(?!SNAPSHOT)([^\-]+))?(?:-(SNAPSHOT))?"
17 | version-string)]
18 | (->> [major minor patch]
19 | (map #(Integer/parseInt %))
20 | (zipmap [:major :minor :patch])
21 | (merge {:qualifier qualifier
22 | :snapshot snapshot}))))
23 |
24 |
25 | (defn parse-semantic-version
26 | [version-string]
27 | "Create map representing the given version string. Aborts with exit code 1
28 | if the string does not follow guidelines setforth by Semantic Versioning 2.0.0,
29 | http://semver.org/"
30 | (or (string->semantic-version version-string)
31 | (throw (ex-info "Unrecognized version string:" {:version version-string}))))
32 |
33 |
34 | (defn version-map->string
35 | "Given a version-map, return a string representing the version."
36 | [version-map]
37 | (let [{:keys [major minor patch qualifier snapshot]} version-map]
38 | (cond-> (str major "." minor "." patch)
39 | qualifier (str "-" qualifier)
40 | snapshot (str "-" snapshot))))
41 |
42 |
43 | (defn next-qualifier
44 | "Increments and returns the qualifier. If an explicit `sublevel`
45 | is provided, then, if the original qualifier was using that sublevel,
46 | increments it, else returns that sublevel with \"1\" appended.
47 | Supports empty strings for sublevel, in which case the return value
48 | is effectively a BuildNumber."
49 | ([qualifier]
50 | (if-let [[_ sublevel] (re-matches #"([^\d]+)?(?:\d+)?"
51 | (or qualifier ""))]
52 | (next-qualifier sublevel qualifier)
53 | "1"))
54 | ([sublevel qualifier]
55 | (let [pattern (re-pattern (str sublevel "([0-9]+)"))
56 | [_ n] (and qualifier (re-find pattern qualifier))]
57 | (str sublevel (inc (Integer. (or n 0)))))))
58 |
59 |
60 | (defn bump-version-map
61 | "Given version as a map of the sort returned by parse-semantic-version, return
62 | a map of the version incremented in the level argument. Always returns a
63 | SNAPSHOT version, unless the level is :release. For :release, removes SNAPSHOT
64 | if the input is a SNAPSHOT, removes qualifier if the input is not a SNAPSHOT."
65 | [{:keys [major minor patch qualifier snapshot]} level value]
66 | (let [level (or level
67 | (if qualifier :qualifier)
68 | :patch)]
69 | (case (keyword (name level))
70 | :major {:major (if value value (inc major)) :minor 0 :patch 0 :qualifier nil :snapshot "SNAPSHOT"}
71 | :minor {:major major :minor (if value value (inc minor)) :patch 0 :qualifier nil :snapshot "SNAPSHOT"}
72 | :patch {:major major :minor minor :patch (if value value (inc patch)) :qualifier nil :snapshot "SNAPSHOT"}
73 | :alpha {:major major :minor minor :patch patch
74 | :qualifier (next-qualifier "alpha" qualifier)
75 | :snapshot "SNAPSHOT"}
76 | :beta {:major major :minor minor :patch patch
77 | :qualifier (next-qualifier "beta" qualifier)
78 | :snapshot "SNAPSHOT"}
79 | :rc {:major major :minor minor :patch patch
80 | :qualifier (next-qualifier "RC" qualifier)
81 | :snapshot "SNAPSHOT"}
82 | :qualifier {:major major :minor minor :patch patch
83 | :qualifier (next-qualifier qualifier)
84 | :snapshot "SNAPSHOT"}
85 | :release (merge {:major major :minor minor :patch patch}
86 | (if snapshot
87 | {:qualifier qualifier :snapshot nil}
88 | {:qualifier nil :snapshot nil})))))
89 |
90 |
91 | (defn bump-version
92 | "Given a version string, return the bumped version string -
93 | incremented at the indicated level. Add qualifier unless releasing
94 | non-snapshot. Level defaults to *level*."
95 | [version-str & [level value]]
96 | (-> version-str
97 | (parse-semantic-version)
98 | (bump-version-map (or level *level*) value)
99 | (version-map->string)))
100 |
101 | ;; end of Leiningen code
102 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 |
104 |
105 | (let [version (first *command-line-args*)
106 | level (second *command-line-args*)
107 | value (first (drop 2 *command-line-args*))]
108 | (try
109 | (println (bump-version version level value))
110 | (catch Exception e
111 | (binding [*out* *err*]
112 | (println "Error processing version value: " version " " (.getMessage e)))
113 | (println version))))
114 |
--------------------------------------------------------------------------------
/src/clj/new/org/rssys/libtemplate.clj:
--------------------------------------------------------------------------------
1 | (ns clj.new.org.rssys.libtemplate
2 | (:require
3 | [clj.new.templates :refer [renderer project-data ->files]]))
4 |
5 |
6 | (defn libtemplate
7 | "entry point to run template."
8 | [name]
9 | (let [render (renderer "rssyslib")
10 | data (project-data name)]
11 | (println "Generating project from library template https://github.com/redstarssystems/rssyslib.git")
12 | (println "See README.adoc in project root to install once project prerequisites.")
13 | (->files data
14 | [".clj-kondo/config.edn" (render ".clj-kondo/config.edn" data)]
15 | ["dev/src/user.clj" (render "dev/src/user.clj" data)]
16 | ["deps.edn" (render "deps.edn" data)]
17 | [".gitignore" (render ".gitignore" data)]
18 | ["resources/readme.txt" (render "resources/readme.txt" data)]
19 | ["src/{{nested-dirs}}/core.clj" (render "src/core.clj" data)]
20 | ["test/{{nested-dirs}}/core_test.clj" (render "test/core_test.clj" data)]
21 | [".editorconfig" (render ".editorconfig" data)]
22 | ["project-config.edn" (render "project-config.edn" data)]
23 | ["project-secrets.edn" (render "project-secrets.edn" data)]
24 | [".cljstyle" (render ".cljstyle" data)]
25 | ["CHANGELOG.adoc" (render "CHANGELOG.adoc" data)]
26 | ["LICENSE" (render "LICENSE" data)]
27 | ["bb.edn" (render "bb.edn" data)]
28 | ["tests.edn" (render "tests.edn" data)]
29 | ["project-version" (render "project-version" data)]
30 | ["README.adoc" (render "README.adoc" data)]
31 | ["scripts/bump-semver.clj" (render "scripts/bump-semver.clj" data)]
32 | ["pom.xml" (render "pom.xml" data)])))
33 |
--------------------------------------------------------------------------------