├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── app ├── index.js └── templates │ ├── banner.txt │ ├── gradle-base │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ └── gradlew.bat │ ├── project-base │ ├── CHANGELOG.md │ ├── LICENSE │ ├── _appveyor.yml │ ├── _github │ │ ├── dependabot.yml │ │ └── workflows │ │ │ └── CI.yml │ ├── _gitignore │ └── gradle.properties │ ├── project-multi-modules │ └── module │ │ ├── README.md │ │ └── build.gradle │ ├── project-multi │ ├── README.md │ ├── build.gradle │ └── settings.gradle │ ├── project-single │ ├── README.md │ ├── build.gradle │ └── settings.gradle │ └── sources │ └── src │ ├── main │ ├── java │ │ └── package │ │ │ └── _gitkeep │ └── resources │ │ └── package │ │ └── _gitkeep │ └── test │ ├── groovy │ └── package │ │ ├── AbstractTest.groovy │ │ └── DummyTest.groovy │ ├── java │ └── package │ │ └── _gitkeep │ └── resources │ ├── logback.xml │ └── package │ └── _gitkeep ├── package-lock.json ├── package.json └── test ├── jshint.spec.js ├── sources └── sample │ └── Sample.java └── test-app.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp 3 | *.log 4 | .idea 5 | *.iml 6 | 7 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 2, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "undef": true, 15 | "unused": true, 16 | "strict": true 17 | } 18 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | temp 3 | *.log 4 | .idea 5 | *.iml 6 | test 7 | 8 | 9 | # don't ignore .npmignore files 10 | !.npmignore -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 14 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 3.1.0 (2022-12-27) 2 | * Update ru.vyarus.java-lib 2.2.2 -> 2.3.1 3 | * Update ru.vyarus.github-info 1.3.0 -> 1.4.0 4 | * Update ru.vyarus.quality 4.6.0 -> 4.8.0 5 | * Update com.github.ben-manes.versions 0.39.0 -> 0.44.0 6 | * Update et.researchgate.release 2.8.1 -> 3.0.2 7 | * Fix jitpack support 8 | * By default, release plugin assume main branch (setting for master commented) 9 | * Release process no longer perform full build (https://github.com/researchgate/gradle-release/issues/374) 10 | 11 | ### 3.0.3 (2021-10-27) 12 | * Update ru.vyarus.java-lib 2.2.1 -> 2.2.2 (disable publication option, support submodules without coverage) 13 | * Fix multi-module with bom maven central publication: 14 | - pom section from allprojects wasn't applied in subprojects because java plugin is activated only in subprojects 15 | - bom was not publishing 16 | * Add jdk 16 to CI builds 17 | 18 | ### 3.0.2 (2021-09-06) 19 | * Fix multi-module project release 20 | * Replace travis with github actions 21 | * Add dependabot config 22 | 23 | ### 3.0.1 (2021-07-13) 24 | * Update ru.vyarus.java-lib 2.2.0 -> 2.2.1 (fix multi-module projects configuration) 25 | 26 | ### 3.0.0 (2021-07-12) 27 | * Minimal required node 12.12.0 28 | * Update to gradle 6.9 29 | * Update ru.vyarus.quality 4.0.0 -> 4.6.0 30 | * Update com.github.ben-manes.versions 0.27.0 -> 0.39.0 31 | * Update ru.vyarus.github-info 1.2.0 -> 1.3.0 32 | * Update ru.vyarus.java-lib 2.1.0 -> 2.2.0 (much multi-module logic moved to plugin) 33 | * (breaking) Removed jcenter publishing, instead publish to maven central directly 34 | - Remove com.jfrog.bintray plugin 35 | - Add io.github.gradle-nexus.publish-plugin (1.1.0) 36 | - Add signing plugin (signing now manual; certificate configuration required) 37 | * Remove jcenter badge and repo usages 38 | * Disable gradle metadata publishing 39 | * Remove java version selection: java8 used by default for compilation 40 | - Remove animalsniffer usage 41 | * Enable mavenLocal as plugin repository by default (in settings.gradle) 42 | * Use spock 2.0 (groovy 3) 43 | * Remove spring dependency-management plugin in favour of gradle platform 44 | - In multi-module project bom module removed: instead platform 45 | is declared in the ROOT project, like maven (BOM published on release as before) 46 | Generated subproject poms does not depend on BOM anymore (direct dependencies put instead) 47 | * settings.gradle is modified now on project update 48 | Settings now contains plugin repos declaration and buildscan configuration 49 | 50 | ### 2.8.0 (2020-01-26) 51 | * Update ru.vyarus.java-lib 1.1.2 -> 2.1.0 52 | * Update gradle-github-info-plugin 1.1.0 -> 1.2.0 53 | * Update io.spring.dependency-management 1.0.8 -> 1.0.9 54 | * Update spock to 1.3 55 | * Remove deprecated compile configurations 56 | 57 | ### 2.7.0 (2019-11-24) 58 | * Fix node compatibility: minimal required node is 8.5.0 59 | * Update gradle 4.8.1 -> 5.6.4 60 | * Enable gradle build scan for failed builds 61 | * Update et.researchgate.release 2.7.0 -> 2.8.1 62 | * Update ru.vyarus.quality 3.1.1 -> 4.0.0 63 | * Update gradle-animalsniffer-plugin 1.4.3 -> 1.5.0 64 | * Update com.github.ben-manes.versions 0.20.0 -> 0.27.0 65 | * Update spock to 1.1 -> 1.2 66 | * Add io.spring.dependency-management plugin for BOM management (instead of gradle core support) 67 | * Add Automatic-Module-Name in manifest for java 11 68 | * Travis changes: add build matrix with jdk11, use openjdk8, lock to xenial disto 69 | * Add jdk11 to appveyor build 70 | * Use shields badge instead of bintray badge (badge issue was fixed on shields side) 71 | * Add multi-module project generation 72 | 73 | ### 2.6.0 (2018-07-22) 74 | * Update gradle 4.6 -> 4.8.1 75 | * Update et.researchgate.release 2.6.0 -> 2.7.0 76 | * Update com.jfrog.bintray 1.8.0 -> 1.8.4 77 | * Update com.github.ben-manes.versions 0.17.0 -> 0.20.0 78 | * Update ru.vyarus.java-lib 1.0.5 -> 1.1.2 79 | * Update ru.vyarus.quality 3.0.0 -> 3.1.1 80 | 81 | NOTE: gradle [STABLE_PUBLISHING](https://docs.gradle.org/4.8/userguide/publishing_maven.html#publishing_maven:deferred_configuration) option is enabled by default 82 | 83 | ### 2.5.0 (2018-04-02) 84 | * Update gradle 4.1 -> 4.6 85 | * Update gradle-quality-plugin 2.3.0 -> 3.0.0 86 | * Update gradle-animalsniffer-plugin 1.4.1 -> 1.4.3 87 | * Update gradle-bintray-plugin 1.7.3 -> 1.8.0 88 | * Update gradle-versions-plugin 0.15.0 -> 0.17.0 89 | * Use spotbugs-annotations dependency instead of jsr305 90 | * Add windows build via [appveyor](https://www.appveyor.com/) 91 | - New file .appveyor.yml 92 | - Coverage uploaded to codecov (with windows flag) 93 | * Update travis config: coverage sent to [codecov](https://codecov.io/) (with linux tag) 94 | * Remove coveralls plugin (switch from coveralls to codecov because it could merge coverages from different platforms) 95 | * Update README: 96 | - Add appveyor and codecov badges (instead of coveralls) 97 | - Replace jcenter badge from shields to bintray native badge (because shields bintray support not working) 98 | 99 | ### 2.4.0 (2017-08-19) 100 | * Update gradle 3.3 -> 4.1 101 | * Update gradle-release-plugin 2.5.0 -> 2.6.0 102 | * Update gradle-quality-plugin 2.1.0 -> 2.3.0 103 | * Update gradle-animalsniffer-plugin 1.2.0 -> 1.4.1 104 | * Update gradle-versions-plugin 0.13.0 -> 0.15.0 105 | * Update gradle-java-lib-plugin 1.0.4 -> 1.0.5 106 | * Update coveralls-gradle-plugin 2.7.1 -> 2.8.1 107 | * Update spock to 1.0 -> 1.1 108 | * Update travis config: 109 | - increase check task timeout to 20 min 110 | - disable gradle daemon ([recommended](https://docs.gradle.org/4.0.1/userguide/gradle_daemon.html#when_should_i_not_use_the_gradle_daemon)) 111 | - remove TERM=dump (set automatically by travis) 112 | - update cache management 113 | 114 | ### 2.3.0 (2017-01-24) 115 | * Yeoman generator 1.0 compatibility 116 | * Update gradle 3.0 -> 3.3 117 | * Update gradle-bintray-plugin 1.7.1 -> 1.7.3 118 | * Update gradle-release-plugin 2.4.1 -> 2.5.0 119 | * Update coveralls-gradle-plugin 2.6.3 -> 2.7.1 120 | * Update gradle-quality-plugin 2.0.0 -> 2.1.0 121 | * Fix report path in showDependenciesTree task and remove deprecated left shift syntax 122 | 123 | ### 2.2.0 (2016-09-09) 124 | * Update gradle 2.12 -> 3.0 125 | * Update gradle-java-lib-plugin 1.0.1 -> 1.0.4 126 | * Update gradle-animalsniffer-plugin 1.0.1 -> 1.2.0 127 | * Update gradle-quality-plugin 1.3.0 -> 2.0.0 128 | * Update gradle-bintray-plugin 1.6 -> 1.7.1 129 | * Update gradle-versions-plugin 0.12.0 -> 0.13.0 130 | * Update gradle-release-plugin 2.3.5 -> 2.4.1 131 | * Update mode: 132 | - now able to overwrite travis,yml, .gitignore and gradle script files 133 | - fix maven central sync logic 134 | 135 | ### 2.1.0 (2016-04-15) 136 | * Update gradle-versions-plugin 0.11.3 -> 0.12.0 137 | * Update coveralls-gradle-plugin 2.4.0x -> 2.6.3 138 | * Update gradle-bintray-plugin 1.5 -> 1.6 139 | * Update gradle-release-plugin 2.3.4 -> 2.3.5 140 | * Update gradle-quality-plugin 1.2.0 -> 1.3.0 141 | * Update gradle-animalsniffer-plugin 1.0.0 -> 1.0.1 142 | * Update gradle-github-info-plugin 1.0.0 -> 1.1.0 143 | - New plugin will [specify github repo and changelog file](https://github.com/xvik/gradle-github-info-plugin#comjfrogbintray) 144 | (if recognize) for bintray package (useful for package creation) 145 | * Improve travis cache configuration (according to [travis guide](https://docs.travis-ci.com/user/languages/java/#Caching)) 146 | * Update gradle 2.10 -> 2.12 147 | * Animalsniffer signatures: 148 | - Replace java16-sun to java16 149 | - Replace whildcard versions (`+`) to actual latest signature versions 150 | 151 | ### 2.0.0 (2016-01-07) 152 | * Build logic extracted to gradle plugins. As a result, only one small build file required now: 153 | - removed build-deps.gradle 154 | - removed all geadle files inside gradle/ folder 155 | * Quality tools configs (gradle/config) removed: they are maintained by gradle quality plugin 156 | * Update gradle 2.8 -> 2.10 157 | 158 | ### 1.1.4 (2015-10-27) 159 | * Change maven badge from maven-badges.herokuapp.com to shields.io (but link still leads to maven-badges.herokuapp.com) 160 | * Change bintray badge to shields.io badge (for custom label) 161 | * Update gradle 2.6 -> 2.8 162 | * Update checkstyle 6.9 -> 6.11.2 163 | - compatibility.jar is not required anymore and must be removed from gradle/config/checkstyle/compatibility.jar 164 | * Update pmd 5.3.3 -> 5.4.0 165 | * Update gradle-bintray-plugin 1.3.1 -> 1.4 166 | * Update gradle-release 2.2.0 -> 2.3.0 167 | 168 | ### 1.1.3 (2015-08-13) 169 | * Update gradle 2.5 -> 2.6 170 | * Update checkstyle 6.8.1 -> 6.9 171 | * Update gradle-bintray-plugin 1.2 -> 1.3.1 172 | * Update gradle-release plugin 2.1.2 -> 2.2.0 173 | * Update .travis.yml to use [container infrastructure](http://docs.travis-ci.com/user/migrating-from-legacy) and enable cache for gradle dependencies 174 | 175 | ### 1.1.2 (2015-07-29) 176 | * Fix java 7 build compatibility 177 | 178 | ### 1.1.1 (2015-07-29) 179 | * Update gradle 2.4 -> 2.5 180 | * Update checkstyle 6.7 -> 6.8.1 (with compatibility fix) 181 | * Update pmd 5.3.2 -> 5.3.3 182 | 183 | ### 1.1.0 (2015-06-27) 184 | * Update coveralls-gradle-plugin 2.3.1 -> 2.4.0 185 | * Update gradle-versions-plugin 0.9 -> 0.11.3 186 | * Update gradle-release 2.0.2 -> 2.1.2 187 | * Update checkstyle 6.5 -> 6.7 188 | * Update pmd 5.2.3 -> 5.3.2 189 | * Add strictQualityCheck option to build.gradle to be able to disable build fail on quality plugin warnings 190 | * Remove anonymous analytics 191 | * Add snapshots section to readme: describes how to use JitPack 192 | 193 | ### 1.0.4 (2015-05-07) 194 | * Update gradle 2.3 -> 2.4 195 | * Update gradle-bintray-plugin 1.1 -> 1.2 196 | * Update gradle-versions-plugin 0.8 -> 0.9 197 | * Remove explicit pmd dependencies because gradle now supports pmd 5.2 and above (not updated to 5.3.1 because of regression https://sourceforge.net/p/pmd/bugs/1331/) 198 | * Update checkstyle 6.4.1 -> 6.5 (not updated to 6.6 because it fails with NPE sometimes) 199 | * Switch gradle-release-plugin from com.github.townsfolk:gradle-release to net.researchgate:gradle-release (old plugin abandoned and this one is the new version) 200 | * Removed checkOutOfDate task: use dependencyUpdates task instead (provided by version plugin) 201 | * Apply correct groups for custom tasks 202 | 203 | ### 1.0.3 (2015-03-12) 204 | * Update spock 0.7 -> 1.0 205 | * Update findbugs 3.0.0 -> 3.0.1 206 | * Update checkstyle 6.3 - > 6.4.1 207 | 208 | ### 1.0.2 (2015-02-23) 209 | * Update gradle 2.2.1 -> 2.3 210 | * Update gradle-versions-plugin 0.7 -> 0.8 211 | 212 | ### 1.0.1 (2015-02-12) 213 | * Update gradle-bintray-plugin 1.0 -> 1.1 214 | * Update coveralls-gradle-plugin 2.1.0 -> 2.3.1 215 | * Update checkstyle 6.2 -> 6.3 216 | 217 | ### 1.0.0 (2015-01-21) 218 | * initial release (converted [slush generator](https://github.com/xvik/slush-lib-java)) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, Vyacheslav Rusakov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java library yeoman generator 2 | 3 | [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/xvik/generator-lib-java) 4 | [![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://www.opensource.org/licenses/MIT) 5 | [![NPM version](https://img.shields.io/npm/v/generator-lib-java.svg)](http://badge.fury.io/js/generator-lib-java) 6 | [![Build Status](https://travis-ci.com/xvik/generator-lib-java.svg?branch=master)](https://travis-ci.com/xvik/generator-lib-java) 7 | 8 | 9 | ### About 10 | 11 | Generates java library project (or multi-module library), hosted on github with maven central publication. 12 | Ideal for new OSS project quick start. 13 | 14 | Features: 15 | * Single and multi-module projects generation 16 | * [MIT](http://opensource.org/licenses/MIT) license (hardcoded) 17 | * [Gradle](http://www.gradle.org/) build (with support of optional and provided dependencies) 18 | * [Maven central](http://search.maven.org/) compatible artifacts (jar, sources, javadocs) 19 | * Ready for [spock](http://spockframework.org) tests ([documentation](http://docs.spockframework.org)) 20 | * CI: github actions (linux), [appveyor](https://www.appveyor.com/) (windows) 21 | * Coverage with jacoco, merged from both win and linux builds in [codecov.io](https://codecov.io/) 22 | * Target jdk compatibility check with [animal sniffer](http://mojo.codehaus.org/animal-sniffer/) (you may use newer jdk to build, and keep compatibility with older jdk) 23 | * Code quality checks ([checkstyle](http://checkstyle.sourceforge.net/), [pmd](http://pmd.sourceforge.net/), [findbugs](http://findbugs.sourceforge.net/)) 24 | * [Release process](https://github.com/researchgate/gradle-release#introduction) (like maven release) 25 | 26 | Requires jdk8 or above (due to checkstyle [requirement](http://checkstyle.sourceforge.net/releasenotes.html#Release_7.0)). But actual library could target any java level (jdk8 is only required for build). 27 | 28 | ### Known issue 29 | 30 | Gradle 2.13+ has a [bug with console input](https://issues.gradle.org/browse/GRADLE-3446). As a result, 31 | during release version confirm questions are [not visible](https://github.com/researchgate/gradle-release/issues/185). 32 | 33 | Issue is not blocking and only affects release process: simply hit enter for questions (and be sure version in properties file is correct). 34 | 35 | ### Thanks to 36 | 37 | * [Vladislav Bauer](https://github.com/vbauer) ([android-arsenal](http://android-arsenal.com/) author) for checkstyle config and [gitignore.io](https://gitignore.io) hint 38 | * [Juan Roperto](https://github.com/jroperto) for pmd config 39 | 40 | ### Example projects 41 | 42 | #### Single module 43 | 44 | * [dropwizard-guicey](https://github.com/xvik/dropwizard-guicey) 45 | * [guice-validator](https://github.com/xvik/guice-validator) 46 | * [guice-persist-orient](https://github.com/xvik/guice-persist-orient) 47 | * [dropwizard-orient-server](https://github.com/xvik/dropwizard-orient-server) 48 | * [generics-resolver](https://github.com/xvik/generics-resolver) 49 | 50 | #### Multi-module 51 | 52 | * [guice-ext-annotations](https://github.com/xvik/guice-ext-annotations) - with published BOM 53 | * [yaml-config-updater](https://github.com/xvik/yaml-updater) - without BOM 54 | 55 | ### Setup 56 | 57 | Install [yeoman](http://yeoman.io/): 58 | 59 | ```bash 60 | $ npm install -g yo 61 | ``` 62 | 63 | Install generator: 64 | 65 | ```bash 66 | $ npm install -g generator-lib-java 67 | ``` 68 | 69 | ### Github setup 70 | 71 | You will need [github](https://github.com) user. Create it if you don't have already. 72 | 73 | ### Maven central setup 74 | 75 | For maven central publication you must first register in sonatype and approve your group. 76 | Read this a bit [outdated article](https://medium.com/@vyarus/the-hard-way-to-maven-central-c9e16d163acc) 77 | for getting started. 78 | 79 | For certificate generation see [java-lib plugin docs](https://github.com/xvik/gradle-java-lib-plugin#signing) 80 | Note that signing configuration required only for release (otherwise its ignored) 81 | 82 | After all you'll need to put the following properties into `~/.gradle/gradle.properties` 83 | 84 | ``` 85 | sonatypeUser = 86 | sonatypePassword = 87 | 88 | signing.keyId = 78065050 89 | signing.password = 90 | signing.secretKeyRingFile = /path/to/certs.gpg 91 | ``` 92 | 93 | Generator will check and warn you if something is not configured. 94 | 95 | ### Publishing library to local repository only 96 | 97 | If library is assumed to be used as internal library with local (corporate) maven repo, 98 | manual modifications required. 99 | 100 | Remove `io.github.gradle-nexus.publish-plugin`. 101 | 102 | Remove `ru.vyarus.github-info` (I assume your source would not be in github). And remove related 103 | `github` configuration block. 104 | 105 | Remove `signing` plugin if you don't need to sign artifacts for your repository. 106 | 107 | Configure repository: 108 | 109 | ```groovy 110 | publishing { 111 | repositories { 112 | maven { 113 | url project.version.contains("SNAPSHOT") 114 | ? "https://my-private-nexus.com/nexus/content/repositories/my-snapshots" 115 | : "https://my-private-nexus.com/nexus/content/repositories/my-releases" 116 | credentials { 117 | username = project.findProperty('myRepoUser') 118 | password = project.findProperty('myRepoPass') 119 | } 120 | } 121 | } 122 | } 123 | ``` 124 | 125 | Change releasing task: 126 | 127 | ```groovy 128 | afterReleaseBuild { 129 | dependsOn = [publish] 130 | ``` 131 | 132 | Now simple `publish` task deploys snapshot version and `release` task would perform complete release 133 | (with version change and tagging git). 134 | 135 | To use published library declare custom repository in target project: 136 | 137 | ```groovy 138 | repositories { 139 | // usually root repo combining releases and snapshots 140 | maven { url 'https://my-private-nexus.com/nexus/content/groups/my/' } 141 | } 142 | ``` 143 | 144 | ### Usage 145 | 146 | > General convention: project name == github project name == bintray package page 147 | 148 | Run generator: 149 | 150 | ```bash 151 | $ yo lib-java 152 | ``` 153 | 154 | Generator creates project in current folder if project name (question) is the same as current directory, 155 | and will create subdirectory otherwise. 156 | 157 | Generator calls github to validate user correctness and suggest your name and email. If there is a problem with it use offline mode: 158 | 159 | ```bash 160 | $ yo lib-java --offline 161 | ``` 162 | 163 | Project setup ready, start coding! 164 | 165 | #### Build upgrade 166 | 167 | If generator started in folder with already generated project - it will work in update mode. 168 | This will allow you to easily update existing build with new generator version. 169 | 170 | Update mode skips some files to reduce update to only meaningful files (e.g. no need to update CHANGELOG.md, gradle.properties etc). 171 | Update will use previous answers by default. 172 | 173 | Start update without local changes and after generation look git changes and correct 174 | (usually only main build.gradle requires modifications after update). 175 | 176 | #### Global storage 177 | 178 | Most likely, some answers will be the same for all your libraries, that's why they are stored in global config and 179 | you will see more precise defaults on next generation. 180 | 181 | Global config stored in `~/.config/configstore/generator-lib-java.json` 182 | 183 | ### External services 184 | 185 | Create [github](https://github.com) repo matching your library name and push project there (github will guide you). 186 | 187 | In github project settings go to `Webhooks & services` and add `travis-ci` service. 188 | 189 | Enable repository on [appveyor](https://www.appveyor.com/) 190 | 191 | And after next commit windows and linux builds will be performed automatically and combined coverage report 192 | will be available on [codecov](https://codecov.io/) (badges for all services are already generated in readme). 193 | 194 | Maven central badge is generated in readme. 195 | 196 | ### Snapshots 197 | 198 | [JitPack](https://jitpack.io) is ideal for snapshots: it builds github project and serves dependency for you. 199 | Special section in project readme is generated to show how to use it for snapshots. 200 | JitPack doesn't require any configuration to support your library. 201 | 202 | ### Gitter 203 | 204 | [Gitter](https://gitter.im) is a chat room for your repository. Most likely, with it you 205 | will get much more feedback (something people will never post as issue or write by email). 206 | 207 | Gitter badge is not generated automatically, because it's not required as other services and it's too easy to add at any time. 208 | Look it and decide if you need it. 209 | 210 | ### Documentation 211 | 212 | You can use [gradle-mkdocs-plugin](https://github.com/xvik/gradle-mkdocs-plugin) for writing versioned project documentation 213 | (published on github pages). 214 | 215 | ### Project usage 216 | 217 | ```bash 218 | $ gradlew check 219 | ``` 220 | 221 | Runs code quality plugins and tests. If quality checks were activated (asked during generation) do check before pushing to avoid 222 | build failures on travis. Moreover, it's easy to always keep everything clean instead of doing it before release. 223 | 224 | ```bash 225 | $ gradlew dependencyUpdates 226 | ``` 227 | 228 | Checks if your project dependencies are actual and prints versions analysis report to console. 229 | 230 | ```bash 231 | $ gradlew dependencies 232 | ``` 233 | 234 | Prints dependencies tree into console 235 | 236 | ```bash 237 | $ gradlew openDependencyReport 238 | ``` 239 | 240 | Generates dependencies html report and launch it in default browser. 241 | To analyze conflicts, click on dependency name to activate 242 | [dependencyInsight](http://www.gradle.org/docs/current/groovydoc/org/gradle/api/tasks/diagnostics/DependencyInsightReportTask.html) popup. 243 | 244 | ```bash 245 | $ gradlew install 246 | ``` 247 | 248 | Installs library to local maven repository. Useful for referencing by other projects (for testing without releasing library). 249 | 250 | ```bash 251 | $ gradlew release 252 | ``` 253 | 254 | Releases library. Read release process section below before performing first release. 255 | 256 | ### Project details 257 | 258 | Used gradle plugins: 259 | * [java](http://www.gradle.org/docs/current/userguide/java_plugin.html) 260 | * [groovy](http://www.gradle.org/docs/current/userguide/groovy_plugin.html) to support spock tests 261 | * [maven-publish](http://www.gradle.org/docs/current/userguide/publishing_maven.html) to generate pom and publish to maven repository 262 | * [project-report](http://www.gradle.org/docs/current/userguide/project_reports_plugin.html) to generate dependency tree html report 263 | * [jacoco](http://www.gradle.org/docs/current/userguide/jacoco_plugin.html) to build coverage report for coveralls 264 | * [pmd](http://www.gradle.org/docs/current/userguide/pmd_plugin.html) to check code quality with [PMD](http://pmd.sourceforge.net/) tool 265 | * [checkstyle](http://www.gradle.org/docs/current/userguide/checkstyle_plugin.html) to check code style rules with [checkstyle](http://checkstyle.sourceforge.net/index.html) 266 | * [spotbugs](https://github.com/spotbugs/spotbugs-gradle-plugin) to find potential bugs with [spotbugs](https://spotbugs.github.io/) 267 | * [o.github.gradle-nexus.publish-plugin](https://github.com/gradle-nexus/publish-plugin) to simplify maven central publication 268 | * [com.github.ben-manes.versions](https://github.com/ben-manes/gradle-versions-plugin) to check dependencies versions updates 269 | * [net.researchgate.release](https://github.com/researchgate/gradle-release) for release (see [article](http://www.sosaywecode.com/gradle-release-plugin/) for additional plugin details) 270 | * [ru.vyarus.pom](https://github.com/xvik/gradle-pom-plugin) for simpler pom generation 271 | * [ru.vyarus.java-lib](https://github.com/xvik/gradle-java-lib-plugin) to prepare java artifacts setup 272 | * [ru.vyarus.github-info](https://github.com/xvik/gradle-github-info-plugin) to fill in github specific data 273 | * [ru.vyarus.quality](https://github.com/xvik/gradle-quality-plugin) to configure quality plugins and provide advanced reporting 274 | 275 | #### Optional dependencies 276 | 277 | Optional and provided dependencies support provided by [ru.vyarus.pom plugin](https://github.com/xvik/gradle-pom-plugin). 278 | 279 | Example usage: 280 | 281 | ```groovy 282 | provided 'com.github.spotbugs:spotbugs-annotations:3.1.2' 283 | ``` 284 | 285 | or 286 | 287 | ```groovy 288 | optional 'com.github.spotbugs:spotbugs-annotations:3.1.2' 289 | ``` 290 | 291 | In the generated pom these dependencies will be defined as provided or optional, but for gradle build it's 292 | the same as declaring them in `implementation` scope. 293 | 294 | jsr305 provided dependency is defined by default in generated project (useful to guide firebug). 295 | 296 | Scala note: The Scala compiler, unlike the Java compiler, [requires that annotations used by a library be available when 297 | compiling against that library](https://issues.scala-lang.org/browse/SI-5420). 298 | If your library users will compile with Scala, they must declare a dependency on JSR-305 jar. 299 | 300 | ### Quality tools 301 | 302 | Quality tools are configured by [ru.vyarus.quality plugin](https://github.com/xvik/gradle-quality-plugin). 303 | 304 | Read more about quality tools specifics and how to suppress warnings: 305 | * [checkstyle](http://xvik.github.io/gradle-quality-plugin/3.0.0/tool/checkstyle/) 306 | * [pmd](http://xvik.github.io/gradle-quality-plugin/3.0.0/tool/pmd/) 307 | * [spotbugs](http://xvik.github.io/gradle-quality-plugin/3.0.0/tool/spotbugs/) 308 | 309 | By default, quality checks fail build if any violation found. In order to simply report violations do: 310 | 311 | ```groovy 312 | quality { 313 | strict = false 314 | } 315 | ``` 316 | 317 | ### Release process 318 | 319 | #### Before first release 320 | 321 | When releasing first time it's better to do 322 | 323 | ```bash 324 | $ gradlew install 325 | ``` 326 | 327 | And validate generated pom file and jars (in local maven repository ~/.m2/repository/..). 328 | 329 | #### General release process 330 | 331 | Update `CHANGELOG.md`. 332 | 333 | Push all changes before release and wait for `travis` to check build (wait for green badge). 334 | 335 | Perform release: 336 | 337 | ```bash 338 | $ gradlew release 339 | ``` 340 | 341 | Release will check that current copy is actual: no uncommitted/unversioned/unpushed changes, nothing newer is in remote repository. 342 | You can start releasing either from snapshot version (1.0.0-SNAPSHOT) or from normal one (1.0.0). 343 | 344 | During release, plugin will create tag (new github release appear) and update version in `gradle.properties`. 345 | 346 | You may want to create github release: release will only create tag. To create release go to github releases, click on tag and press 'edit'. 347 | I usually use text from changelog as release message, but you may expand it with other release specific notes. 348 | 349 | ### Support 350 | 351 | [Gitter chat room](https://gitter.im/xvik/generator-lib-java) 352 | 353 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const chalk = require('chalk'), 4 | JavaGenerator = require('yo-java-helper'); 5 | 6 | /** 7 | * Generator variables, available for templates: 8 | */ 9 | const questions = [ 10 | 'multiModule', // multi module project 11 | 'modulePrefix', // multi-module project's modules prefix 12 | 'moduleName', // multi-module project's module name 13 | 'githubUser', // github user name 14 | 'authorName', // author full name 15 | 'authorEmail', // author email 16 | 'libName', // library name 17 | 'libGroup', // maven artifact group 18 | 'libPackage', // base package 19 | 'libVersion', // library version 20 | 'libDesc', // library description 21 | 'enableQualityChecks' // true if quality checks enabled 22 | ]; 23 | 24 | /* extra variables: 25 | * - year // 2015 26 | * - date // 02.12.2015 27 | * - reverseDate // 2015-12-02 28 | */ 29 | 30 | /* 31 | Templates syntax: 32 | - <%= %> html escaped value 33 | - <%- %> not escaped (raw) value 34 | - <% %> any logic (script block) 35 | */ 36 | 37 | const globals = [ 38 | 'githubUser', 39 | 'authorName', 40 | 'authorEmail', 41 | 'libGroup' 42 | ]; 43 | 44 | module.exports = class extends JavaGenerator { 45 | 46 | constructor(args, opts) { 47 | super(args, opts, require('../package.json')); 48 | 49 | this.option('offline', { 50 | desc: 'Disables github user lookup', 51 | type: Boolean, 52 | defaults: false 53 | }); 54 | this.option('ask', { 55 | desc: 'Force questions even all answers available (during project update)', 56 | type: Boolean, 57 | defaults: false 58 | }); 59 | } 60 | 61 | initializing() { 62 | 63 | // init 64 | this.$initConfig(questions); 65 | this.$initDateVars(); 66 | 67 | 68 | // read gradle config 69 | const done = this.async(); 70 | this.context.gradleConfPath = this.$resolveFileFromUserHome('.gradle/gradle.properties'); 71 | this.$readProperties(this.context.gradleConfPath, res => { 72 | this.context.gradleConf = res; 73 | done(); 74 | }); 75 | } 76 | 77 | 78 | prompting() { 79 | // greeting 80 | this.log(chalk.yellow(this.$readBanner('banner.txt'))); 81 | this.log(` v.${chalk.green(this.context.pkg.version)}`); 82 | this.log(); 83 | if (this.context.updateMode) { 84 | this.log(`Updating library ${chalk.red(this.appname)}, generated with v.${chalk.green(this.context.usedGeneratorVersion)}`); 85 | if (this.context.allAnswered && !this.options.ask) { 86 | this.log(); 87 | this.log('Using stored answers from .yo-rc.json. \n' + 88 | 'If you need to re-run questions use --ask generator option.'); 89 | } 90 | this.log(); 91 | 92 | // MIGRATION from 2.8.0 or before 93 | 94 | // clear removed properties 95 | ['targetJava', 96 | 'libTags', 97 | 'mirrorToJcenter', 98 | 'bintrayUser', 99 | 'bintrayRepo', 100 | 'bintraySignFiles', 101 | 'mavenCentralSync'].forEach(value => this.config.delete(value)); 102 | } 103 | 104 | // ask for github 105 | const options = this.options; 106 | if (!options.ask && this.context.allAnswered) { 107 | return; 108 | } 109 | 110 | let githubData = {}, 111 | gen = this, 112 | prompts = [ 113 | { 114 | type: 'confirm', 115 | name: 'multiModule', 116 | message: 'Create multi-module project?', 117 | default: this.$defaultValue('multiModule', false) 118 | }, 119 | { 120 | type: 'input', 121 | name: 'modulePrefix', 122 | message: 'Modules prefix ({prefix}-name)', 123 | default: this.$defaultValue('modulePrefix', 'project'), 124 | when: props => props.multiModule, 125 | validate: input => !input ? 'Prefix required' : true 126 | }, 127 | { 128 | type: 'input', 129 | name: 'moduleName', 130 | message: 'Module name (prefix-{name})', 131 | default: this.$defaultValue('moduleName', 'module'), 132 | when: props => props.multiModule, 133 | validate: input => !input ? 'Module name required' : true 134 | }, 135 | { 136 | type: 'input', 137 | name: 'githubUser', 138 | message: 'GitHub user name', 139 | default: this.$defaultValue('githubUser'), 140 | validate: function (input) { 141 | return new Promise((resolve) => { 142 | if (options.offline) { 143 | if (input) { 144 | resolve(true); 145 | } else { 146 | resolve('Github user required'); 147 | } 148 | return; 149 | } 150 | gen.$getGithubData(input, (err, res) => { 151 | if (err) { 152 | resolve(err); 153 | } else { 154 | githubData = res; 155 | resolve(true); 156 | } 157 | }); 158 | }); 159 | } 160 | }, 161 | { 162 | type: 'input', 163 | name: 'authorName', 164 | message: 'Author name', 165 | default: () => githubData.name || this.$defaultValue('authorName'), 166 | validate: input => !input ? 'Author name required' : true 167 | }, 168 | { 169 | type: 'input', 170 | name: 'authorEmail', 171 | message: 'Author email', 172 | default: () => githubData.email || this.$defaultValue('authorEmail'), 173 | validate: input => !input ? 'Author email required' : true 174 | } 175 | ]; 176 | 177 | let other = () => { 178 | if (this.context.allAnswered && !this.options.ask) { 179 | return null; 180 | } 181 | 182 | const disableOnUpdate = () => !this.context.updateMode; 183 | 184 | prompts = [ 185 | { 186 | type: 'input', 187 | name: 'libGroup', 188 | message: 'Maven artifact group', 189 | validate: this.$validatePackage, 190 | default: this.$defaultValue('libGroup', 'com.mycompany') 191 | }, 192 | { 193 | type: 'input', 194 | name: 'libPackage', 195 | message: 'Base package', 196 | validate: this.$validatePackage, 197 | when: disableOnUpdate, 198 | default: props => this.libPackage || props.libGroup + '.' + this.libName.replace(/(\s+|-|_)/g, '.') 199 | }, 200 | {type: 'input', name: 'libDesc', message: 'Description', default: this.libDesc}, 201 | { 202 | type: 'input', 203 | name: 'libVersion', 204 | message: 'Version', 205 | default: '0.1.0', 206 | when: disableOnUpdate 207 | }, 208 | { 209 | type: 'confirm', 210 | name: 'enableQualityChecks', 211 | message: 'Enable code quality checks (checkstyle, pmd, findbugs)?', 212 | default: this.enableQualityChecks || true 213 | } 214 | ]; 215 | 216 | return this.$prompt(prompts, questions); 217 | }; 218 | 219 | let askLibName = () => { 220 | if (this.context.updateMode) { 221 | // update must be started from project folder - no need to ask for name 222 | return null; 223 | } 224 | 225 | this.log(`Accept default library name ${chalk.red(this.appname)} to generate in current folder, otherwise new folder will be created`); 226 | 227 | prompts = [{ 228 | name: 'libName', message: 'Library name', default: this.libName || this.appname, 229 | filter: this.$folderName 230 | }]; 231 | 232 | return this.$prompt(prompts, ['libName']).then(props => { 233 | this.appname = props.libName; 234 | return other(); 235 | }); 236 | }; 237 | 238 | return this.$prompt(prompts, questions).then(askLibName); 239 | } 240 | 241 | configuring() { 242 | // fill not used properties for single-module projects (to avoid questions on update) 243 | if (!this.multiModule) { 244 | this.modulePrefix = '-'; 245 | this.moduleName = '-'; 246 | } 247 | 248 | // configure 249 | this.$selectTargetFolder(); 250 | this.$saveConfiguration(questions, globals); 251 | } 252 | 253 | writing() { 254 | // base 255 | const writeOnceFiles = [ 256 | 'CHANGELOG.md', 257 | 'README.md', 258 | 'gradle.properties', 259 | 'LICENSE' 260 | ]; 261 | this.gradlewExists = this.$exists('gradlew'); 262 | 263 | this.$copy('gradle-base', {writeOnceFiles: writeOnceFiles}); 264 | 265 | this.$copyTpl('project-base', {writeOnceFiles: writeOnceFiles}); 266 | 267 | if (this.multiModule) { 268 | 269 | // MULTI MODULE PROJECT 270 | this.$copyTpl('project-multi', {writeOnceFiles: writeOnceFiles}); 271 | // generate modules only once because module would be obviously renamed after initial generation 272 | if (!this.context.updateMode) { 273 | const moduleDir = this.modulePrefix + '-' + this.moduleName; 274 | this.$copyTpl('project-multi-modules/module', { 275 | writeOnceFiles: writeOnceFiles, 276 | targetFolder: moduleDir 277 | }); 278 | const packageFolder = this.libPackage.replace(/\./g, '/'); 279 | this.$copyTpl('sources', { 280 | pathReplace: [ 281 | {regex: /(^|\/)package(\/|$)/, replace: '$1' + packageFolder + '$2'} 282 | ], 283 | targetFolder: moduleDir 284 | }); 285 | } else { 286 | this.log(chalk.yellow(' skip ') + 'sources generation'); 287 | } 288 | } else { 289 | 290 | // SINGLE PROJECT 291 | this.$copyTpl('project-single', {writeOnceFiles: writeOnceFiles}); 292 | // sources 293 | if (!this.$exists('src/main')) { 294 | this.$copySources(this.libPackage, 'sources'); 295 | } else { 296 | this.log(chalk.yellow(' skip ') + 'sources generation'); 297 | } 298 | } 299 | } 300 | 301 | end() { 302 | // chmod 303 | // setting executable flag manually 304 | if (!this.gradlewExists) { 305 | this.$setExecutableFlag('gradlew'); 306 | } 307 | 308 | // check gradle config 309 | let conf = this.context.gradleConf || {}, 310 | warnSign = !conf['signing.keyId'] || !conf['signing.secretKeyRingFile'], 311 | warnCentral = !conf.sonatypeUser || !conf.sonatypePassword; 312 | 313 | if (!warnSign && !warnCentral) { 314 | return; 315 | } 316 | 317 | this.log(); 318 | this.log(chalk.red('IMPORTANT') + ' you need to add the following configurations to global gradle file (required for release): ' + 319 | '\n ' + chalk.green(this.context.gradleConfPath)); 320 | if (warnSign) { 321 | this.log(); 322 | this.log('For release artifacts signing:'); 323 | this.log(chalk.yellow('signing.keyId') + '='); 324 | this.log(chalk.yellow('signing.password') + '='); 325 | this.log(chalk.yellow('signing.secretKeyRingFile') + '='); 326 | } 327 | if (warnCentral) { 328 | this.log(); 329 | this.log('For maven central publication:'); 330 | this.log(chalk.yellow('sonatypeUser') + '='); 331 | this.log(chalk.yellow('sonatypePassword') + '='); 332 | } 333 | } 334 | }; 335 | -------------------------------------------------------------------------------- /app/templates/banner.txt: -------------------------------------------------------------------------------- 1 | .__ ._____. __ 2 | | | |__\_ |__ |__|____ ___ _______ 3 | | | | || __ \ | \__ \\ \/ /\__ \ 4 | | |_| || \_\ \ | |/ __ \\ / / __ \_ 5 | |____/__||___ / /\__| (____ /\_/ (____ / 6 | \/ \______| \/ \/ -------------------------------------------------------------------------------- /app/templates/gradle-base/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xvik/generator-lib-java/172d452c4d9d24b8bd7e07dec4f415b71d7f41cc/app/templates/gradle-base/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/templates/gradle-base/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /app/templates/gradle-base/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /app/templates/gradle-base/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /app/templates/project-base/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### <%= libVersion %> (<%= reverseDate %>) 2 | * Initial release -------------------------------------------------------------------------------- /app/templates/project-base/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) <%= year %>, <%= authorName %> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /app/templates/project-base/_appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | 3 | environment: 4 | matrix: 5 | - job_name: Java 8 6 | JAVA_HOME: C:\Program Files\Java\jdk1.8.0 7 | PYTHON: "C:\\Python36-x64" 8 | - job_name: Java 11 9 | JAVA_HOME: C:\Program Files\Java\jdk11 10 | PYTHON: "C:\\Python36-x64" 11 | - job_name: Java 16 12 | appveyor_build_worker_image: Visual Studio 2019 13 | JAVA_HOME: C:\Program Files\Java\jdk16 14 | PYTHON: "C:\\Python36-x64" 15 | 16 | install: 17 | - set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH% 18 | - pip install codecov --user 19 | 20 | build_script: 21 | - ./gradlew assemble --no-daemon 22 | test_script: 23 | - ./gradlew check --no-daemon 24 | 25 | on_success: 26 | - ./gradlew jacocoTestReport --no-daemon 27 | - python -m codecov -f build\reports\jacoco\test\jacocoTestReport.xml -F windows 28 | 29 | cache: 30 | - C:\Users\appveyor\.gradle\caches 31 | - C:\Users\appveyor\.gradle\wrapper -------------------------------------------------------------------------------- /app/templates/project-base/_github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gradle 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "23:00" 8 | open-pull-requests-limit: 10 -------------------------------------------------------------------------------- /app/templates/project-base/_github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | name: Java ${{ matrix.java }} 11 | strategy: 12 | matrix: 13 | java: [8, 11, 16] 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - name: Set up JDK ${{ matrix.java }} 19 | uses: actions/setup-java@v1 20 | with: 21 | java-version: ${{ matrix.java }} 22 | 23 | - name: Build 24 | run: | 25 | chmod +x gradlew 26 | ./gradlew assemble --no-daemon 27 | 28 | - name: Test 29 | env: 30 | GH_ACTIONS: true 31 | run: ./gradlew check --no-daemon 32 | 33 | - name: Build coverage report 34 | run: ./gradlew jacocoTestReport --no-daemon 35 | 36 | - uses: codecov/codecov-action@v2 37 | with: 38 | files: build/reports/jacoco/test/jacocoTestReport.xml 39 | flags: LINUX 40 | fail_ci_if_error: true -------------------------------------------------------------------------------- /app/templates/project-base/_gitignore: -------------------------------------------------------------------------------- 1 | # Created with https://www.gitignore.io 2 | 3 | ### Gradle ### 4 | .gradle/ 5 | build/ 6 | 7 | # Ignore Gradle GUI config 8 | gradle-app.setting 9 | 10 | ### JetBrains ### 11 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 12 | 13 | /*.iml 14 | 15 | ## Directory-based project format: 16 | .idea/ 17 | 18 | ## File-based project format: 19 | *.ipr 20 | *.iws 21 | 22 | ## Plugin-specific files: 23 | 24 | # IntelliJ 25 | out/ 26 | 27 | # mpeltonen/sbt-idea plugin 28 | .idea_modules/ 29 | 30 | # JIRA plugin 31 | atlassian-ide-plugin.xml 32 | 33 | # Crashlytics plugin (for Android Studio and IntelliJ) 34 | com_crashlytics_export_strings.xml 35 | 36 | 37 | ### Eclipse ### 38 | *.pydevproject 39 | .metadata 40 | bin/ 41 | tmp/ 42 | *.tmp 43 | *.bak 44 | *.swp 45 | *~.nib 46 | local.properties 47 | .settings/ 48 | .loadpath 49 | 50 | # External tool builders 51 | .externalToolBuilders/ 52 | 53 | # Locally stored "Eclipse launch configurations" 54 | *.launch 55 | 56 | # CDT-specific 57 | .cproject 58 | 59 | # PDT-specific 60 | .buildpath 61 | 62 | # sbteclipse plugin 63 | .target 64 | 65 | # TeXlipse plugin 66 | .texlipse 67 | 68 | ### Java ### 69 | *.class 70 | 71 | # Mobile Tools for Java (J2ME) 72 | .mtj.tmp/ 73 | 74 | # Package Files # 75 | *.war 76 | *.ear 77 | 78 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 79 | hs_err_pid* 80 | 81 | 82 | ### NetBeans ### 83 | nbproject/private/ 84 | nbbuild/ 85 | dist/ 86 | nbdist/ 87 | nbactions.xml 88 | nb-configuration.xml 89 | 90 | 91 | ### OSX ### 92 | .DS_Store 93 | .AppleDouble 94 | .LSOverride 95 | 96 | # Icon must end with two \r 97 | Icon 98 | 99 | 100 | # Thumbnails 101 | ._* 102 | 103 | # Files that might appear on external disk 104 | .Spotlight-V100 105 | .Trashes 106 | 107 | # Directories potentially created on remote AFP share 108 | .AppleDB 109 | .AppleDesktop 110 | Network Trash Folder 111 | Temporary Items 112 | .apdisk 113 | 114 | 115 | ### Windows ### 116 | # Windows image file caches 117 | Thumbs.db 118 | ehthumbs.db 119 | 120 | # Folder config file 121 | Desktop.ini 122 | 123 | # Recycle Bin used on file shares 124 | $RECYCLE.BIN/ 125 | 126 | # Windows Installer files 127 | *.cab 128 | *.msi 129 | *.msm 130 | *.msp 131 | 132 | # Windows shortcuts 133 | *.lnk 134 | 135 | 136 | ### Linux ### 137 | *~ 138 | 139 | # KDE directory preferences 140 | .directory 141 | 142 | ### JEnv ### 143 | # JEnv local Java version configuration file 144 | .java-version 145 | 146 | # Used by previous versions of JEnv 147 | .jenv-version 148 | -------------------------------------------------------------------------------- /app/templates/project-base/gradle.properties: -------------------------------------------------------------------------------- 1 | version=<%= libVersion %>-SNAPSHOT -------------------------------------------------------------------------------- /app/templates/project-multi-modules/module/README.md: -------------------------------------------------------------------------------- 1 | # <%= libName %> <%= moduleName %> module 2 | 3 | Description. 4 | 5 | Features: 6 | * Feature 1 7 | * Feature 2 8 | 9 | ### Setup 10 | 11 | [![Maven Central](https://img.shields.io/maven-central/v/<%= libGroup %>/<%= modulePrefix %>-<%= moduleName %>.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/<%= libGroup %>/<%= modulePrefix %>-<%= moduleName %>) 12 | 13 | Avoid version in dependency declaration below if you use [BOM](../). 14 | 15 | Maven: 16 | 17 | ```xml 18 | 19 | <%= libGroup %> 20 | <%= modulePrefix %>-<%= moduleName %> 21 | <%= libVersion %> 22 | 23 | ``` 24 | 25 | Gradle: 26 | 27 | ```groovy 28 | implementation '<%= libGroup %>:<%= modulePrefix %>-<%= moduleName %>:<%= libVersion %>' 29 | ``` 30 | 31 | See the most recent version in the badge above. 32 | 33 | 34 | ### Usage 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/templates/project-multi-modules/module/build.gradle: -------------------------------------------------------------------------------- 1 | description = "Module description" 2 | 3 | dependencies { 4 | // module specific dependencies (version always declared in root module) 5 | // implementation 'com.foo:lib1' 6 | } -------------------------------------------------------------------------------- /app/templates/project-multi/README.md: -------------------------------------------------------------------------------- 1 | # <%= libName %> 2 | [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://www.opensource.org/licenses/MIT) 3 | [![CI](https://github.com/<%= githubUser %>/<%= libName %>/actions/workflows/CI.yml/badge.svg)](https://github.com/<%= githubUser %>/<%= libName %>/actions/workflows/CI.yml) 4 | [![Appveyor build status](https://ci.appveyor.com/api/projects/status/github/<%= githubUser %>/<%= libName %>?svg=true)](https://ci.appveyor.com/project/<%= githubUser %>/<%= libName %>) 5 | [![codecov](https://codecov.io/gh/<%= githubUser %>/<%= libName %>/branch/master/graph/badge.svg)](https://codecov.io/gh/<%= githubUser %>/<%= libName %>) 6 | 7 | ### About 8 | 9 | <%= libDesc %> 10 | 11 | ### Setup 12 | 13 | [![Maven Central](https://img.shields.io/maven-central/v/<%= libGroup %>/<%= libName %>.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/<%= libGroup %>/<%= libName %>) 14 | 15 | You can either use [modules](#modules) directly (in this case see module page for setup) or use provided BOM 16 | to unify versions management (recommended). 17 | 18 | ### BOM 19 | 20 | Maven: 21 | 22 | ```xml 23 | 24 | 25 | 26 | <%= libGroup %> 27 | <%= modulePrefix %>-bom 28 | <%= libVersion %> 29 | pom 30 | import 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <%= libGroup %> 39 | <%= modulePrefix %>-<%= moduleName %> 40 | 41 | 42 | ``` 43 | 44 | Gradle: 45 | 46 | ```groovy 47 | dependencies { 48 | // BOM 49 | implementation platform('<%= libGroup %>:<%= modulePrefix %>-bom:<%= libVersion %>') 50 | 51 | // declare modules without versions 52 | implementation '<%= libGroup %>:<%= modulePrefix %>-<%= moduleName %>' 53 | } 54 | 55 | ``` 56 | 57 | ### Modules 58 | 59 | #### [<%= moduleName %>](<%= modulePrefix %>-<%= moduleName %>) 60 | 61 | Module description. 62 | 63 | --- 64 | [![java lib generator](http://img.shields.io/badge/Powered%20by-%20Java%20lib%20generator-green.svg?style=flat-square)](https://github.com/xvik/generator-lib-java) -------------------------------------------------------------------------------- /app/templates/project-multi/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'ru.vyarus.github-info' version '1.4.0' apply false<% if (enableQualityChecks) { %> 3 | id 'ru.vyarus.quality' version '4.8.0' apply false<% } %> 4 | 5 | id 'jacoco' 6 | id 'java-platform' 7 | id 'ru.vyarus.java-lib' version '2.3.1' 8 | id 'net.researchgate.release' version '3.0.2' 9 | id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' 10 | id 'com.github.ben-manes.versions' version '0.44.0' 11 | } 12 | 13 | wrapper { 14 | gradleVersion = '6.9' 15 | } 16 | 17 | description = '<%= libDesc %>' 18 | 19 | ext { 20 | slf4j = '1.7.30' 21 | } 22 | 23 | // root project is a BOM (like maven) 24 | dependencies { 25 | // inherited BOMs declaration 26 | //api platform('group:artifact:version') 27 | constraints { 28 | api 'org.spockframework:spock-core:2.0-groovy-3.0' 29 | api "org.slf4j:slf4j-api:$slf4j" 30 | // add subprojects to BOM 31 | project.subprojects.each { api it } 32 | } 33 | } 34 | 35 | javaLib { 36 | // aggregated test and coverage reports 37 | aggregateReports() 38 | // publish root BOM as custom artifact 39 | bom { 40 | artifactId = '<%= modulePrefix %>-bom' 41 | description = '<%= libDesc %> BOM' 42 | } 43 | // bom publication could be disabled (to use it only for dependency management in submodules) 44 | // in this case bom section above could be removed; afterReleaseBuild must also be updated 45 | //withoutPublication() 46 | } 47 | 48 | // maven publication related configuration applied to all projects 49 | allprojects { 50 | apply plugin: 'project-report' 51 | apply plugin: 'ru.vyarus.github-info' 52 | apply plugin: 'ru.vyarus.java-lib' 53 | apply plugin: 'signing' 54 | 55 | repositories { mavenLocal(); mavenCentral() } 56 | 57 | group = '<%= libGroup %>' 58 | 59 | github { 60 | user = '<%= githubUser %>' 61 | license = 'MIT' 62 | } 63 | 64 | // delay required because java plugin is activated only in subprojects and without it 65 | // pom closure would reference root project only 66 | afterEvaluate { 67 | pom { 68 | developers { 69 | developer { 70 | id '<%= githubUser %>' 71 | name '<%= authorName %>' 72 | email '<%= authorEmail %>' 73 | } 74 | } 75 | } 76 | } 77 | 78 | // don't publish gradle metadata artifact 79 | javaLib.withoutGradleMetadata() 80 | 81 | // skip signing for jitpack (snapshots) 82 | tasks.withType(Sign) {onlyIf { !System.getenv('JITPACK') }} 83 | } 84 | 85 | // all sub-modules are normal java modules, using root BOM (like maven) 86 | subprojects { 87 | apply plugin: 'groovy' 88 | apply plugin: 'jacoco' 89 | apply plugin: 'ru.vyarus.quality' 90 | apply plugin: 'com.github.ben-manes.versions' 91 | 92 | sourceCompatibility = 1.8 93 | 94 | // common dependencies for all modules 95 | dependencies { 96 | implementation platform(project(':')) 97 | 98 | compileOnly 'com.github.spotbugs:spotbugs-annotations:4.4.2' 99 | 100 | implementation 'org.slf4j:slf4j-api' 101 | 102 | testImplementation 'ch.qos.logback:logback-classic:1.2.3' 103 | testImplementation "org.slf4j:jul-to-slf4j:${rootProject.slf4j}" 104 | testImplementation 'org.spockframework:spock-core' 105 | } 106 | 107 | javaLib { 108 | // java 9 auto module name 109 | autoModuleName = "$rootProject.group.${project.name.replace('<%= modulePrefix %>-', rootProject.name)}" 110 | // use only direct dependencies in the generated pom, removing BOM mentions 111 | pom.removeDependencyManagement() 112 | } 113 | 114 | test { 115 | useJUnitPlatform() 116 | testLogging { 117 | events 'skipped', 'failed' 118 | exceptionFormat 'full' 119 | } 120 | maxHeapSize = '512m' 121 | } 122 | 123 | dependencyUpdates.revision = 'release' 124 | } 125 | 126 | // dependency on all subprojects required for release validation 127 | check.dependsOn subprojects.check 128 | 129 | nexusPublishing { 130 | repositories { 131 | sonatype { 132 | username = findProperty('sonatypeUser') 133 | password = findProperty('sonatypePassword') 134 | } 135 | } 136 | } 137 | 138 | // Required signing properties for release: signing.keyId, signing.password and signing.secretKeyRingFile 139 | // (https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials) 140 | 141 | //release.git.requireBranch.set('master') // default is main branch 142 | 143 | // release manages only root project (subprojects will be checked and released implicitly) 144 | afterReleaseBuild { 145 | dependsOn 'publishToSonatype' 146 | dependsOn subprojects.collect {":$it.name:publishToSonatype" } 147 | dependsOn 'closeAndReleaseSonatypeStagingRepository' 148 | doLast { 149 | logger.warn "RELEASED $project.group:$project.name:$project.version" 150 | } 151 | } 152 | 153 | -------------------------------------------------------------------------------- /app/templates/project-multi/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenLocal() 4 | gradlePluginPortal() 5 | } 6 | } 7 | plugins { 8 | id "com.gradle.enterprise" version "3.12.1" 9 | } 10 | 11 | gradleEnterprise { 12 | buildScan { 13 | termsOfServiceUrl = 'https://gradle.com/terms-of-service' 14 | termsOfServiceAgree = 'yes' 15 | //publishOnFailure() 16 | } 17 | } 18 | 19 | rootProject.name = '<%= libName %>' 20 | 21 | include '<%= modulePrefix %>-<%= moduleName %>' 22 | -------------------------------------------------------------------------------- /app/templates/project-single/README.md: -------------------------------------------------------------------------------- 1 | # <%= libName %> 2 | [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://www.opensource.org/licenses/MIT) 3 | [![CI](https://github.com/<%= githubUser %>/<%= libName %>/actions/workflows/CI.yml/badge.svg)](https://github.com/<%= githubUser %>/<%= libName %>/actions/workflows/CI.yml) 4 | [![Appveyor build status](https://ci.appveyor.com/api/projects/status/github/<%= githubUser %>/<%= libName %>?svg=true)](https://ci.appveyor.com/project/<%= githubUser %>/<%= libName %>) 5 | [![codecov](https://codecov.io/gh/<%= githubUser %>/<%= libName %>/branch/master/graph/badge.svg)](https://codecov.io/gh/<%= githubUser %>/<%= libName %>) 6 | 7 | 8 | ### About 9 | 10 | <%= libDesc %> 11 | 12 | Features: 13 | * Feature 1 14 | * Feature 2 15 | 16 | ### Setup 17 | 18 | [![Maven Central](https://img.shields.io/maven-central/v/<%= libGroup %>/<%= libName %>.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/<%= libGroup %>/<%= libName %>) 19 | 20 | Maven: 21 | 22 | ```xml 23 | 24 | <%= libGroup %> 25 | <%= libName %> 26 | <%= libVersion %> 27 | 28 | ``` 29 | 30 | Gradle: 31 | 32 | ```groovy 33 | implementation '<%= libGroup %>:<%= libName %>:<%= libVersion %>' 34 | ``` 35 | 36 | ##### Snapshots 37 | 38 | You can use snapshot versions through [JitPack](https://jitpack.io): 39 | 40 | * Go to [JitPack project page](https://jitpack.io/#<%= githubUser %>/<%= libName %>) 41 | * Select `Commits` section and click `Get it` on commit you want to use (top one - the most recent) 42 | * Follow displayed instruction: add repository and change dependency (NOTE: due to JitPack convention artifact group will be different) 43 | 44 | ### Usage 45 | 46 | --- 47 | [![java lib generator](http://img.shields.io/badge/Powered%20by-%20Java%20lib%20generator-green.svg?style=flat-square)](https://github.com/xvik/generator-lib-java) -------------------------------------------------------------------------------- /app/templates/project-single/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'groovy' 3 | id 'jacoco' 4 | id 'project-report' 5 | id 'signing' 6 | id 'ru.vyarus.java-lib' version '2.3.1' 7 | id 'ru.vyarus.github-info' version '1.4.0'<% if (enableQualityChecks) { %> 8 | id 'ru.vyarus.quality' version '4.8.0'<% } %> 9 | id 'net.researchgate.release' version '3.0.2' 10 | id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' 11 | id 'com.github.ben-manes.versions' version '0.44.0' 12 | } 13 | 14 | sourceCompatibility = 1.8 15 | 16 | wrapper { 17 | gradleVersion = '6.9' 18 | } 19 | 20 | ext { 21 | groovy = '2.5.14' 22 | slf4j = '1.7.30' 23 | } 24 | 25 | repositories { mavenLocal(); mavenCentral() } 26 | dependencies { 27 | // BOMs usage 28 | // implementation platform('dependency:address') 29 | 30 | compileOnly 'com.github.spotbugs:spotbugs-annotations:4.2.3' 31 | 32 | implementation "org.slf4j:slf4j-api:$slf4j" 33 | 34 | testImplementation 'ch.qos.logback:logback-classic:1.2.3' 35 | testImplementation "org.slf4j:jul-to-slf4j:$slf4j" 36 | testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0' 37 | } 38 | 39 | group = '<%= libGroup %>' 40 | description = '<%= libDesc %>' 41 | 42 | github { 43 | user = '<%= githubUser %>' 44 | license = 'MIT' 45 | } 46 | 47 | pom { 48 | developers { 49 | developer { 50 | id '<%= githubUser %>' 51 | name '<%= authorName %>' 52 | email '<%= authorEmail %>' 53 | } 54 | } 55 | } 56 | 57 | javaLib { 58 | // java 9 auto module name 59 | autoModuleName = "$project.group.$project.name" 60 | // don't publish gradle metadata artifact 61 | withoutGradleMetadata() 62 | // use only direct dependencies in the generated pom, removing BOM mentions 63 | pom.removeDependencyManagement() 64 | // put resolved dependencies versions 65 | //pom.forceVersions() 66 | } 67 | 68 | nexusPublishing { 69 | repositories { 70 | sonatype { 71 | username = findProperty('sonatypeUser') 72 | password = findProperty('sonatypePassword') 73 | } 74 | } 75 | } 76 | 77 | // skip signing for jitpack (snapshots) 78 | tasks.withType(Sign) {onlyIf { !System.getenv('JITPACK') }} 79 | 80 | // Required signing properties for release: signing.keyId, signing.password and signing.secretKeyRingFile 81 | // (https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials) 82 | 83 | //release.git.requireBranch.set('master') //default is main branch 84 | 85 | afterReleaseBuild { 86 | dependsOn = ['publishToSonatype', 87 | 'closeAndReleaseSonatypeStagingRepository'] 88 | doLast { 89 | logger.warn "RELEASED $project.group:$project.name:$project.version" 90 | } 91 | } 92 | 93 | test { 94 | useJUnitPlatform() 95 | testLogging { 96 | events 'skipped', 'failed' 97 | exceptionFormat 'full' 98 | } 99 | maxHeapSize = '512m' 100 | } 101 | 102 | dependencyUpdates.revision = 'release' 103 | -------------------------------------------------------------------------------- /app/templates/project-single/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenLocal() 4 | gradlePluginPortal() 5 | } 6 | } 7 | plugins { 8 | id "com.gradle.enterprise" version "3.12.1" 9 | } 10 | 11 | gradleEnterprise { 12 | buildScan { 13 | termsOfServiceUrl = 'https://gradle.com/terms-of-service' 14 | termsOfServiceAgree = 'yes' 15 | //publishOnFailure() 16 | } 17 | } 18 | 19 | rootProject.name = '<%= libName %>' 20 | -------------------------------------------------------------------------------- /app/templates/sources/src/main/java/package/_gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xvik/generator-lib-java/172d452c4d9d24b8bd7e07dec4f415b71d7f41cc/app/templates/sources/src/main/java/package/_gitkeep -------------------------------------------------------------------------------- /app/templates/sources/src/main/resources/package/_gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xvik/generator-lib-java/172d452c4d9d24b8bd7e07dec4f415b71d7f41cc/app/templates/sources/src/main/resources/package/_gitkeep -------------------------------------------------------------------------------- /app/templates/sources/src/test/groovy/package/AbstractTest.groovy: -------------------------------------------------------------------------------- 1 | package <%= libPackage %>; 2 | 3 | import spock.lang.Specification 4 | 5 | /** 6 | * Base class for tests. 7 | * 8 | * @author <%= authorName %> 9 | * @since <%= date %> 10 | */ 11 | abstract class AbstractTest extends Specification { 12 | 13 | void setup() { 14 | // todo: do test setup here 15 | } 16 | 17 | void cleanup() { 18 | // todo: do test cleanup here 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/templates/sources/src/test/groovy/package/DummyTest.groovy: -------------------------------------------------------------------------------- 1 | package <%= libPackage %>; 2 | 3 | /** 4 | * Dummy test. 5 | * 6 | * @author <%= authorName %> 7 | * @since <%= date %> 8 | */ 9 | class DummyTest extends AbstractTest { 10 | 11 | def "Check something important"() { 12 | 13 | when: "do something" 14 | Integer checkAssignment = 1 15 | then: "check result" 16 | checkAssignment == 1 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/templates/sources/src/test/java/package/_gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xvik/generator-lib-java/172d452c4d9d24b8bd7e07dec4f415b71d7f41cc/app/templates/sources/src/test/java/package/_gitkeep -------------------------------------------------------------------------------- /app/templates/sources/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 6 | 7 | UTF-8 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/templates/sources/src/test/resources/package/_gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xvik/generator-lib-java/172d452c4d9d24b8bd7e07dec4f415b71d7f41cc/app/templates/sources/src/test/resources/package/_gitkeep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-lib-java", 3 | "version": "3.1.0", 4 | "type": "commonjs", 5 | "description": "Java library project generator, hosted on github, build with gradle and published to maven central", 6 | "license": "MIT", 7 | "main": "app/index.js", 8 | "homepage": "https://github.com/xvik/generator-lib-java", 9 | "bugs": "https://github.com/xvik/generator-lib-java/issues", 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/xvik/generator-lib-java.git" 13 | }, 14 | "author": { 15 | "name": "Vyacheslav Rusakov", 16 | "email": "vyarus@gmail.com", 17 | "url": "https://github.com/xvik" 18 | }, 19 | "engines": { 20 | "node": ">=12.12.0", 21 | "npm": ">=6.14.4" 22 | }, 23 | "scripts": { 24 | "test": "mocha" 25 | }, 26 | "files": [ 27 | "app" 28 | ], 29 | "keywords": [ 30 | "yeoman-generator", 31 | "java", 32 | "lib", 33 | "gradle", 34 | "github", 35 | "maven central" 36 | ], 37 | "dependencies": { 38 | "chalk": "4.1.1", 39 | "yeoman-environment": "3.19.3", 40 | "yo-java-helper": "2.2.0" 41 | }, 42 | "devDependencies": { 43 | "fs-extra": "10.0.0", 44 | "fs-readdir-recursive": "1.1.0", 45 | "mocha": "*", 46 | "mocha-jshint": "2.3.1", 47 | "yeoman-assert": "3.1.1", 48 | "yeoman-test": "6.0.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/jshint.spec.js: -------------------------------------------------------------------------------- 1 | require('mocha-jshint')({paths:['app/']}); -------------------------------------------------------------------------------- /test/sources/sample/Sample.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Sample source. 5 | */ 6 | public class Sample { 7 | 8 | private final Integer x; 9 | 10 | public Sample() { 11 | x = 12 + 3; 12 | } 13 | 14 | public int getX() { 15 | return x; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/test-app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let path = require('path'), 4 | helpers = require('yeoman-test'), 5 | read = require('fs-readdir-recursive'), 6 | util = require('util'), 7 | execFile = util.promisify(require('child_process').execFile), 8 | fs = require('fs-extra'), 9 | 10 | appPath = path.join(__dirname, '../app'), 11 | targetPath = path.join(__dirname, 'temp'); 12 | 13 | function remapFiles(dir, target = 'testlib/') { 14 | // append generated project sub-dir 15 | return read(dir).map(val => target + val) 16 | } 17 | 18 | function dotfile(file) { 19 | return file.replace(/^_|\/_|\\_/, '/.').replace(/^\//, '') 20 | } 21 | 22 | function repackage(file) { 23 | return file.replace(/(^|\/|\\)package(\/|\\|$)/, '$1com/johnd/testlib$2') 24 | } 25 | 26 | function subdir(dir) { 27 | return function (file) { 28 | return dir + "/" + file; 29 | } 30 | } 31 | 32 | async function runGradle(targetDir, done) { 33 | const isWin = /^win/.test(process.platform), 34 | targetFile = (isWin ? '': (targetDir + '/')) + 'gradlew' + (isWin ? '.bat' : ''); 35 | const { stdout, stderr } = await execFile(targetFile, ['check'], {cwd: targetDir}); 36 | console.log(stdout); 37 | console.log(stderr); 38 | if (done) { 39 | done(); 40 | } 41 | } 42 | 43 | describe('check simple app generation', () => { 44 | let result 45 | 46 | before(async () => { 47 | result = await helpers.run(appPath) 48 | .inDir(targetPath) 49 | .withOptions({offline: true}) 50 | .withPrompts({ 51 | multiModule: false, 52 | githubUser: 'johnd', 53 | authorName: 'John Doe', 54 | authorEmail: 'johnd@somemail.com', 55 | libName: 'testlib', 56 | libGroup: 'com.johnd', 57 | libPackage: 'com.johnd.testlib', 58 | libVersion: '0.1.0', 59 | libDesc: 'Test library', 60 | enableQualityChecks: true 61 | }); 62 | }); 63 | 64 | it('creates files on initial generation', () => { 65 | result.assertFile(remapFiles(appPath + '/templates/gradle-base')); 66 | result.assertFile(remapFiles(appPath + '/templates/project-base').map(dotfile)); 67 | result.assertFile(remapFiles(appPath + '/templates/project-single')); 68 | result.assertFile(remapFiles(appPath + '/templates/sources').map(dotfile).map(repackage)); 69 | }); 70 | 71 | it('creates valid project', async () => { 72 | fs.copySync(path.join(__dirname, 'sources'), targetPath + '/testlib/src/main/java'); 73 | await runGradle(targetPath + '/testlib'); 74 | }).timeout(300000); //5 min should be enough to download everything 75 | }); 76 | 77 | describe('check multi-module app generation', () => { 78 | let result 79 | 80 | before(async () => { 81 | result = await helpers.run(appPath) 82 | .inDir(targetPath) 83 | .withOptions({offline: true}) 84 | .withPrompts({ 85 | multiModule: true, 86 | modulePrefix: 'foo', 87 | moduleName: 'sample', 88 | githubUser: 'johnd', 89 | authorName: 'John Doe', 90 | authorEmail: 'johnd@somemail.com', 91 | libName: 'testlib', 92 | libGroup: 'com.johnd', 93 | libPackage: 'com.johnd.testlib', 94 | libVersion: '0.1.0', 95 | libDesc: 'Test library', 96 | enableQualityChecks: true 97 | }); 98 | }); 99 | 100 | it('creates files on initial generation', () => { 101 | result.assertFile(remapFiles(appPath + '/templates/gradle-base')); 102 | result.assertFile(remapFiles(appPath + '/templates/project-base').map(dotfile)); 103 | result.assertFile(remapFiles(appPath + '/templates/project-multi').map(dotfile)); 104 | result.assertFile(read(appPath + '/templates/project-multi-modules/module').map(subdir('testlib/foo-sample'))); 105 | result.assertFile(read(appPath + '/templates/sources').map(dotfile).map(repackage).map(subdir('testlib/foo-sample'))); 106 | }); 107 | 108 | it('creates valid project', async () => { 109 | fs.copySync(path.join(__dirname, 'sources'), targetPath + '/testlib/foo-sample/src/main/java'); 110 | await runGradle(targetPath + '/testlib'); 111 | }).timeout(300000); //5 min should be enough to download everything 112 | }); 113 | --------------------------------------------------------------------------------