diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..32b57c0f5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text eol=lf +*.jar -text +*.bat -text +*.pcap binary +*.blocks binary +*.dylib binary +*.so binary diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 000000000..18e06775e --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,35 @@ + + + + + + + + +### Description +As an [Actor], I want [feature] so that [why]. + +### Acceptance Criteria +* [Criteria 1] + +### Steps to Reproduce (Bug) +1. [Step 1] +2. [Step 2] +3. [Step ...] + +**Expected behavior:** [What you expect to happen] + +**Actual behavior:** [What actually happens] + +**Frequency:** [What percentage of the time does it occur?] + +### Versions (Add all that apply) +* Software version: +* Java version: [`java -version`] +* OS Name & Version: [`cat /etc/*release`] +* Kernel Version: [`uname -a`] +* Virtual Machine software & version: [`vmware -v`] +* Docker Version: [`docker version`] +* Cloud VM, type, size: [Amazon Web Services I3-large] + +### Additional Information diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..b74f4182e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,8 @@ + + + +## PR Description + +## Fixed Issue(s) + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..7d83dd578 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +*.bak +*.swp +*.tmp +*~.nib +*.iml +*.launch +*.swp +*.log +*.db +.classpath +.DS_Store +.gradletasknamecache +.externalToolBuilders/ +.gradle/ +.idea/ +.loadpath +.metadata +.prefs +.project +.recommenders/ +.settings +.springBeans +.vertx +bin/ +local.properties +target/ +tmp/ +build/ +out/ +*.vscode/ +*.rlib +*.d +*.a +*.class + + diff --git a/CLA.md b/CLA.md new file mode 100644 index 000000000..f3e2c46d1 --- /dev/null +++ b/CLA.md @@ -0,0 +1,19 @@ +Sign the CLA +============= + +This page is the step-by-step guide to signing the Consensys AG +Individual Contributor License Agreement. + +1. First and foremost, read [the current version of the CLA]. + It is written to be as close to plain English as possible. + +2. Make an account on [GitHub] if you don't already have one. + +3. After creating your first pull request, you will see a merge + pre-requisite requiring to you read and sign the CLA. + +If you have any questions, you can reach us on [Gitter]. + +[Gitter]: https://gitter.im/PegaSysEng/artemis +[GitHub]: https://github.com/ +[the current version of the CLA]: https://gist.github.com/rojotek/978b48a5e8b68836856a8961d6887992 diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md new file mode 100644 index 000000000..dfd1c60cc --- /dev/null +++ b/CODE-OF-CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [private@pegasys.tech]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[Contributor Covenant]: https://www.contributor-covenant.org +[private@pegasys.tech]: mailto:private@pegasys.tech \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..25a3baf0c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,205 @@ +# Contributing +:+1::tada: First off, thanks for taking the time to contribute! :tada::+1: + +Welcome to the discv5 repository! The following is a set of guidelines for contributing to this repo and its packages. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + +#### Table Of Contents +[Code of Conduct](#code-of-conduct) + +[I just have a quick question](#i-just-have-a-quick-question) + +[How To Contribute](#how-to-contribute) + * [Reporting Bugs](#reporting-bugs) + * [Suggesting Enhancements](#suggesting-enhancements) + * [Your First Code Contribution](#your-first-code-contribution) + * [Pull Requests](#pull-requests) + * [Code Reviews] + +[Style Guides](#style-guides) + * [Java Style Guide](#java-code-style-guide) + * [Coding Conventions](#coding-conventions) + * [Git Commit Messages & Pull Request Messages](#git-commit-messages--pull-request-messages) + +[Issue and Pull Request Labels](#issue-and-pull-request-labels) + +## Code of Conduct + +This project and everyone participating in it is governed by the [Code of Conduct](CODE-OF-CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [private@pegasys.tech]. + + +## I just have a quick question + +> **Note:** Please don't file an issue to ask a question. You'll get faster results by using the resources below. + +* [Gitter] +* [Wiki] + +## How To Contribute +### Reporting Bugs + +This section guides you through submitting a bug report. Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports. + +Before creating bug reports, please check the [before-submitting-a-bug-report](#before-submitting-a-bug-report) checklist as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill in the [issue_template.md](.github/issue_template.md), the information it asks for helps us resolve issues faster. + +> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. + +#### Before Submitting A Bug Report +* **Confirm the problem** is reproducible in the latest version of the software +* **Check the [Debugging Wiki]**. You might be able to find the cause of the problem and fix things yourself. +* **Perform a [cursory search of project issues](https://github.com/search?q=+is%3Aissue+repo%3APegasysEng/discv5)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one. + +#### How Do I Submit A (Good) Bug Report? +Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). Issues should provide the following information by filling in the [issue_template.md](.github/issue_template.md). + +Explain the problem and include additional details to help maintainers reproduce the problem: + +* **Use a clear and descriptive title** for the issue to identify the problem. +* **Describe the exact steps which reproduce the problem** in as many details as possible. +* **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). +* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior. +* **Explain which behavior you expected to see instead and why.** +* **Include screenshots** which show you following the described steps and clearly demonstrate the problem. + +Provide more context by answering these questions: + +* **Did the problem start happening recently** (e.g. after updating to a new version of the software) or was this always a problem? +* If the problem started happening recently, **can you reproduce the problem in an older version of the software?** What's the most recent version in which the problem doesn't happen? +* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens. + +Include details about your configuration and environment: + +* **Which version of the software are you using?** +* **What OS & Version are you running?** + * **For Linux - What kernel are you running?** You can get the exact version by running `uname -a` in your terminal. +* **Are you running in a virtual machine?** If so, which VM software are you using and which operating systems and versions are used for the host and the guest? +* **Are you running in a docker container?** If so, what version of docker? +* **Are you running in a a Cloud?** If so, which one, and what type/size of VM is it? +* **What version of Java are you running?** + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related suggestions. + +Before creating enhancement suggestions, please check the [before-submitting-an-enhancement-suggestion](#before-submitting-an-enhancement-suggestion) list as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in the [issue_template.md](.github/issue_template.md), including the steps that you imagine you would take if the feature you're requesting existed. + +#### Before Submitting An Enhancement Suggestion + +* **Check the [Debugging Wiki].** You might be able to find the cause of the problem and fix things yourself. +* **Perform a [cursory search of project issues](https://github.com/search?q=+is%3Aissue+repo%3APegasysEng/discv5)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one. + +#### How Do I Submit A (Good) Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). Issues should and provide the following information by filling in the [issue_template.md](.github/issue_template.md) and providing the following information: + +* **Use a clear and descriptive title** for the issue to identify the suggestion. +* **Provide a step-by-step description of the suggested enhancement** in as many details as possible. +* **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). +* **Describe the current behavior** and **explain which behavior you expected to see instead** and why. +* **Include screenshots** which help you demonstrate the steps. +* **Explain why this enhancement would be useful** to most users. +* **Does this enhancement exist in other clients?** +* **Specify which version of the software you're using.** +* **Specify the name and version of the OS you're using.** + +## Your First Code Contribution +Start by looking through the 'good first issue' and 'help wanted' issues: +* [Good First Issue][search-label-good-first-issue] - issues which should only require a few lines of code, and a test or two. +* [Help wanted issues][search-label-help-wanted] - issues which are a bit more involved than `good first issue` issues. + +### Local Development +The codebase is maintained using the "*contributor workflow*" where everyone without exception contributes patch proposals using "*pull-requests*". This facilitates social contribution, easy testing and peer review. + +To contribute a patch, the workflow is as follows: + +* Fork repository +* Create topic branch +* Commit patch +* Create pull-request, adhering to the coding conventions herein set forth + +In general a commit serves a single purpose and diffs should be easily comprehensible. For this reason do not mix any formatting fixes or code moves with actual code changes. + +### Architectural Best Practices + +Questions on architectural best practices will be guided by the principles set forth in [Effective Java](http://index-of.es/Java/Effective%20Java.pdf) by Joshua Bloch + +### Automated Test coverage +All code submissions must be accompanied by appropriate automated tests. The goal is to provide confidence in the code’s robustness, while avoiding redundant tests. + +### Pull Requests + +The process described here has several goals: + +- Maintain Product quality +- Fix problems that are important to users +- Engage the community in working toward the best possible product +- Enable a sustainable system for maintainers to review contributions +- Further explanation on PR & commit messages can be found in this post: [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/). + +Please follow these steps to have your contribution considered by the approvers: + +1. Complete the CLA, as described in [CLA.md] +2. Follow all instructions in [PULL-REQUEST-TEMPLATE.md](.github/pull_request_template.md) +3. Include appropriate test coverage. Testing is 100% automated. There is no such thing as a manual test. +4. Follow the [Style Guides](#style-guides) +5. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing
What if the status checks are failing?If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.
+ +While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted. Please refer to [Code Reviews]. + +# Style Guides + +## Java Code Style Guide + +We use Google's Java coding conventions for the project. To reformat code, run: + +``` +./gradlew spotlessApply +``` + +Code style will be checked automatically during a build. + +## Coding Conventions +We have a set of [coding conventions](https://github.com/hyperledger/besu/blob/master/CODING-CONVENTIONS.md) to which we try to adhere. These are not strictly enforced during the build, but should be adhered to and called out in code reviews. + +## Git Commit Messages & Pull Request Messages +* Use the present tense ("Add feature" not "Added feature") +* Use the imperative mood ("Move cursor to..." not "Moves cursor to...") +* Provide a summary on the first line with more details on additional lines as needed +* Reference issues and pull requests liberally + +# Issue and Pull Request Labels +#### Type of Issue and Issue State + +| Label name | Search Link :mag_right: | Description | +| --- | --- | --- | +| `enhancement` | [search][search-label-enhancement] | Feature requests. | +| `bug` | [search][search-label-bug] | Confirmed bugs or reports that are very likely to be bugs. | +| `help wanted` | [search][search-label-help-wanted] | The core team would appreciate help from the community in resolving these issues. | +| `good first issue` | [search][search-label-good-first-issue] | Less complex issues which would be good first issues to work on for users who want to contribute. | +| `info needed` | [search][search-label-info-needed] | More information needs to be collected about these problems or feature requests (e.g. steps to reproduce). | +| `needs reproduction` | [search][search-label-needs-reproduction] | Likely bugs, but haven't been reliably reproduced. | +| `blocked` | [search][search-label-blocked] | Issues blocked on other issues. | +| `duplicate` | [search][search-label-duplicate] | Issues which are duplicates of other issues, i.e. they have been reported before. | +| `wontfix` | [search][search-label-wontfix] | The core team has decided not to fix these issues for now, either because they're working as intended or for some other reason. | +| `invalid` | [search][search-label-invalid] | Issues which aren't valid (e.g. user errors). | +| `do we want this?` | [search][search-label-do-we-want-this] | Seeking stakeholder consensus on proposed feature. | + +[search-label-enhancement]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Aenhancement +[search-label-bug]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Abug +[search-label-help-wanted]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Ahelp%20wanted +[search-label-good-first-issue]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Agood%20first%20issue +[search-label-info-needed]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Ainfo%20needed +[search-label-needs-reproduction]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Aneeds%20reproduction +[search-label-blocked]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Ablocked +[search-label-duplicate]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Aduplicate +[search-label-wontfix]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Awontfix +[search-label-invalid]: https://github.com/search?q=is%3Aopen+is%3Aissue+repo%3APegasysEng%2Fdiscv5+label%3Ainvalid +[search-label-work-in-progress]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3APegasysEng%2Fdiscv5+label%3Awork%20in%20progress +[search-label-requires-changes]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3APegasysEng%2Fdiscv5+label%3Arequires%20changes +[search-label-do-we-want-this]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3APegasysEng%2Fdiscv5+label%3Ado%20we%20want%20this + +[private@pegasys.tech]: mailto:private@pegasys.tech +[Gitter]: https://gitter.im/PegaSysEng/discv5 +[Wiki]: https://github.com/PegaSysEng/discv5/wiki +[Debugging Wiki]: https://github.com/PegaSysEng/discv5/wiki/Debugging +[CLA.md]: /CLA.md +[Code Reviews]: /docs/community/code-reviews.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/build.gradle b/build.gradle new file mode 100644 index 000000000..890e15a6a --- /dev/null +++ b/build.gradle @@ -0,0 +1,159 @@ +import net.ltgt.gradle.errorprone.CheckSeverity + +plugins { + id 'java-library' + id 'com.diffplug.gradle.spotless' version '3.26.0' + id 'com.jfrog.bintray' version '1.8.4' + id 'com.github.ben-manes.versions' version '0.27.0' + id 'com.github.hierynomus.license' version '0.15.0' + id 'io.spring.dependency-management' version '1.0.8.RELEASE' + id 'net.ltgt.errorprone' version '1.1.1' +} + +apply from: "${rootDir}/gradle/versions.gradle" +apply from: "${rootDir}/gradle/check-licenses.gradle" +defaultTasks 'build', 'checkLicenses' + +sourceCompatibility = '11' +targetCompatibility = '11' + +repositories { + jcenter() + mavenCentral() +} + +dependencies { + errorprone("com.google.errorprone:error_prone_core") + testImplementation 'org.junit.jupiter:junit-jupiter-api' + + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' +} + +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**.gradle/**' + } + + importOrder 'tech.pegasys', 'net.consensys', 'java', '' + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.7') + } +} + +license { + header rootProject.file("gradle/java.license") + skipExistingHeaders true + mapping('java', 'SLASHSTAR_STYLE') + ext.year = Calendar.getInstance().get(Calendar.YEAR) +} + +task checkSpdxHeader(type: CheckSpdxHeader) { + apply plugin: 'groovy' + + rootPath = "${projectDir}" + spdxHeader = "* SPDX-License-Identifier: Apache-2.0" + filesRegex = "(.*.java)|(.*.groovy)" +} + +tasks.withType(JavaCompile) { + options.fork = true + options.incremental = true + options.compilerArgs += [ + '-Xlint:unchecked', + '-Xlint:cast', + '-Xlint:rawtypes', + '-Xlint:overloads', + '-Xlint:divzero', + '-Xlint:finally', + '-Xlint:static', + '-Werror', + ] + + options.errorprone { + disableWarningsInGeneratedCode + // Our equals need to be symmetric, this checker doesn't respect that. + check('EqualsGetClass', CheckSeverity.OFF) + // We like to use futures with no return values. + check('FutureReturnValueIgnored', CheckSeverity.OFF) + // We use the JSR-305 annotations instead of the Google annotations. + check('ImmutableEnumChecker', CheckSeverity.OFF) + + check('FieldCanBeFinal', CheckSeverity.OFF) + check('InsecureCryptoUsage', CheckSeverity.WARN) + check('WildcardImport', CheckSeverity.WARN) + + // This check is broken in Java 12. See https://github.com/google/error-prone/issues/1257 + if (JavaVersion.current() == JavaVersion.VERSION_12) { + check('Finally', CheckSeverity.OFF) + } + // This check is broken after Java 12. See https://github.com/google/error-prone/issues/1352 + if (JavaVersion.current() > JavaVersion.VERSION_12) { + check('TypeParameterUnusedInFormals', CheckSeverity.OFF) + } + } + options.encoding = 'UTF-8' + + jar { + baseName project.name + manifest { + attributes( + 'Specification-Title': project.name, + 'Specification-Version': project.version, + 'Implementation-Title': project.name, + 'Implementation-Version': calculateVersion() + ) + } + } +} + +test { + jvmArgs = [ + '-Xmx4g', + '-XX:-UseGCOverheadLimit', + ] + useJUnitPlatform() + reports { + junitXml.enabled = true + } +} + +javadoc { + options.addStringOption('Xdoclint:all', '-quiet') + options.addStringOption('Xwerror', '-html5') + options.encoding = 'UTF-8' +} + +// Takes the version, and if -SNAPSHOT is part of it replaces SNAPSHOT +// with the git commit version. +def calculateVersion() { + String version = rootProject.version + if (version.endsWith("-SNAPSHOT")) { + version = version.replace("-SNAPSHOT", "-dev-" + getCheckedOutGitCommitHash()) + } + return version +} + +def getCheckedOutGitCommitHash() { + def gitFolder = "$projectDir/.git/" + if (!file(gitFolder).isDirectory()) { + // We are in a submodule. The file's contents are `gitdir: \n`. + // Read the file, cut off the front, and trim the whitespace. + gitFolder = file(gitFolder).text.substring(8).trim() + "/" + } + def takeFromHash = 8 + /* + * '.git/HEAD' contains either + * in case of detached head: the currently checked out commit hash + * otherwise: a reference to a file containing the current commit hash + */ + def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD + def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd + + if (isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb + + def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master + refHead.text.trim().take takeFromHash +} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/CheckSpdxHeader.groovy b/buildSrc/src/main/groovy/CheckSpdxHeader.groovy new file mode 100644 index 000000000..27bcbe239 --- /dev/null +++ b/buildSrc/src/main/groovy/CheckSpdxHeader.groovy @@ -0,0 +1,84 @@ +/* + * Copyright 2019 ConsenSys AG. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + + +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import org.gradle.tooling.BuildException + +class CheckSpdxHeader extends DefaultTask { + private String rootPath + private String spdxHeader + private String filesRegex + private String excludeRegex + + @Input + String getRootPath() { + return rootPath + } + + void setRootPath(final String rootPath) { + this.rootPath = rootPath + } + + @Input + String getSpdxHeader() { + return spdxHeader + } + + void setSpdxHeader(final String spdxHeader) { + this.spdxHeader = spdxHeader + } + + @Input + String getFilesRegex() { + return filesRegex + } + + void setFilesRegex(final String filesRegex) { + this.filesRegex = filesRegex + } + + @Input + String getExcludeRegex() { + return excludeRegex + } + + void setExcludeRegex(final String excludeRegex) { + this.excludeRegex = excludeRegex + } + + @TaskAction + void checkHeaders() { + def filesWithoutHeader = [] + new File(rootPath).traverse( + type: groovy.io.FileType.FILES, + nameFilter: ~/${filesRegex}/, + excludeFilter: ~/${excludeRegex}/ + ) { + f -> + if (!f.getText().contains(spdxHeader)) { + filesWithoutHeader.add(f) + } + } + + if (!filesWithoutHeader.isEmpty()) { + throw new BuildException("Files without headers: " + filesWithoutHeader.join('\n'), null) + } + } + +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..17048556a --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +version=0.1.0-SNAPSHOT diff --git a/gradle/check-licenses.gradle b/gradle/check-licenses.gradle new file mode 100644 index 000000000..53365b6ab --- /dev/null +++ b/gradle/check-licenses.gradle @@ -0,0 +1,185 @@ +/** + * Check that the licenses of our 3rd parties are in our acceptedLicenses list. + * + * run it with "gradle checkLicenses" + * + * To add new accepted licenses you need to update this script. + * Some products may be available with multiple licenses. In this case you must update + * this script to add it in the downloadLicenses#licenses. + */ + +// Some parts of this code comes from Zipkin/https://github.com/openzipkin/zipkin/pull/852 +// Zipkin itself is under Apache License. + +/** + * The lists of the license we accept. + */ +ext.acceptedLicenses = [ + 'BSD License', + 'BSD 2-Clause', + 'BSD 3-Clause', + 'Eclipse Distribution License - v 1.0', + 'Eclipse Public License - v 1.0', + 'Eclipse Public License - Version 1.0', + 'Eclipse Public License 1.0', + 'Eclipse Public License - v 2.0', + 'MIT License', + 'Apache License, Version 2.0', + 'Bouncy Castle Licence', + 'Public Domain', + 'Mozilla Public License 1.0', + 'Mozilla Public License Version 1.1', + 'Mozilla Public License Version 2.0', + 'CC0', + 'CC0 1.0 Universal License', + 'Common Development and Distribution License 1.0', + 'Unicode/ICU License', +]*.toLowerCase() + +/** + * This is the configuration we need for our licenses plugin: 'com.github.hierynomus.license' + * This plugin generates a list of dependencies. + */ +downloadLicenses { + includeProjectDependencies = true + reportByDependency = false + reportByLicenseType = true + dependencyConfiguration = 'testCompile' + + ext.apache = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0') + ext.mit = license('MIT License', 'http://www.opensource.org/licenses/mit-license.php') + ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php') + ext.bsd3Clause = license('BSD 3-Clause', 'http://opensource.org/licenses/BSD-3-Clause') + ext.bsd2Clause = license('BSD 2-Clause', 'http://opensource.org/licenses/BSD-2-Clause') + ext.mpl = license('Mozilla Public License', 'http://www.mozilla.org/MPL') + ext.mpl1_1 = license('Mozilla Public License Version 1.1', 'http://www.mozilla.org/MPL/1.1/') + ext.mpl2_0 = license('Mozilla Public License, Version 2.0', 'http://www.mozilla.org/MPL/2.0/') + ext.cddl = license('Common Development and Distribution License 1.0', 'http://opensource.org/licenses/CDDL-1.0') + ext.cddl1_1 = license('Common Development and Distribution License 1.0', 'http://oss.oracle.com/licenses/CDDL-1.1') + ext.epl2_0 = license('Eclipse Public License - v 2.0', 'https://www.eclipse.org/legal/epl-2.0/') + aliases = [ + (apache) : [ + 'Apache Software License - Version 2.0', + 'The Apache Software License, Version 2.0', + 'The Apache Software License, version 2.0', + 'Apache License Version 2.0', + 'Apache License, Version 2.0', + 'The Apache License, Version 2.0', + 'Apache 2', + 'Apache 2.0', + 'Apache License 2.0', + 'Apache-2.0', + license('Apache License', 'http://www.apache.org/licenses/LICENSE-2.0'), + license('Apache Software Licenses', 'http://www.apache.org/licenses/LICENSE-2.0.txt'), + license('Apache', 'http://www.opensource.org/licenses/Apache-2.0') + ], + (mit) : ['The MIT License'], + (bsd) : [ + 'BSD', + 'BSD licence', + 'The BSD License', + 'Berkeley Software Distribution (BSD) License', + license('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php') + ], + (bsd3Clause): [ + '3-Clause BSD License', + 'BSD 3-Clause', + 'BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)', + license('BSD 3-clause', 'http://opensource.org/licenses/BSD-3-Clause'), + license('BSD 3-Clause', 'http://www.scala-lang.org/license.html') + ], + (bsd2Clause): [ + 'BSD 2-Clause', + 'BSD 2-Clause "New" or "Revised" License (BSD-2-Clause)', + license('BSD 2-clause', 'http://opensource.org/licenses/BSD-2-Clause'), + license('BSD 2-Clause', 'http://www.scala-lang.org/license.html'), + 'New BSD license' + ], + (mpl): [ + 'MPL', + 'Mozilla Public License', + 'Mozilla Public License 1.0', + license('Mozilla Public License', 'http://www.mozilla.org/MPL') + ], + (mpl1_1): [ + 'MPL 1.1', + 'Mozilla Public License Version 1.1', + license('Mozilla Public License Version 1.1', 'http://www.mozilla.org/media/MPL/1.1/index.0c5913925d40.txt') + ], + (mpl2_0): [ + 'MPL 2.0', + 'Mozilla Public License Version 2.0', + license('Mozilla Public License 2.0', 'http://www.mozilla.org/media/MPL/2.0/index.815ca599c9df.txt') + ], + (cddl): [ + 'CDDL', + 'Common Development and Distribution License 1.0', + 'CDDL + GPLv2 with classpath exception', + 'Dual license consisting of the CDDL v1.1 and GPL v2' + ], + (cddl1_1): [ + 'CDDL 1.1', + 'COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1', + ], + (epl2_0): [ + 'EPL 2.0', + 'Eclipse Public License 2.0', + 'Eclipse Public License - v 2.0', + 'Eclipse Public License v2.0', + license('Eclipse Public License - v 2.0','https://www.eclipse.org/legal/epl-2.0/') + ] + + ] + + licenses = [ + (group('discv5')) : apache, + + // https://checkerframework.org/manual/#license + // The more permissive MIT License applies to code that you might want + // to include in your own program, such as the annotations and run-time utility classes. + (group('org.checkerframework')): mit, + // RocksDB is dual licensed under Apache v2.0 and GPL 2 licenses + // Explicitly declare that we are using the Apache v2.0 license + (group('org.rocksdb')): apache, + /// Explicilitly declare Apache 2.0 license for javassist + (group('org.javassist')): apache, + /// Explicilitly declare Apache 2.0 license for javassist + (group('javax.ws.rs')): cddl1_1, + (group('org.glassfish.jersey.core')): apache, + (group('org.glassfish.jersey.bundles.repackaged')): apache, + (group('org.glassfish.jersey.connectors')): apache, + //Explicitly declare EPL 2.0 for jnr-poxix - it is simultaneously licensed under 3 licenses. + 'com.github.jnr:jnr-posix:3.0.33': epl2_0, + 'com.github.jnr:jnr-posix:3.0.47': epl2_0, + //JMH-Core is licensed under GPLv2 with the Classpath Exception, which allows us to link it and license the derived work under our license. + 'org.openjdk.jmh:jmh-core:1.21': apache, + (group('io.libp2p')): apache, + ] +} + + +task checkLicenses { + description "Verify that all dependencies use white-listed licenses." + dependsOn ':downloadLicenses' + + def bads = "" + doLast { + def xml = new XmlParser().parse('build/reports/license/license-dependency.xml') + xml.each { license -> + if (!acceptedLicenses.contains((license.@name).toLowerCase())) { + def depStrings = [] + license.dependency.each { depStrings << it.text() } + bads = bads + depStrings + " => ${license.@name} \n" + } + } + if (bads != "") { + throw new GradleException("Some 3rd parties are using licenses not in our accepted licenses list:\n" + + bads + + "If it's a license acceptable for us, add it in the file check-licenses.gradle\n"+ + "Be careful, some 3rd parties may accept multiple licenses.\n" + + "In this case, select the one you want to use by changing downloadLicenses.licenses\n" + ) + } + } +} +check.dependsOn checkLicenses diff --git a/gradle/java.license b/gradle/java.license new file mode 100644 index 000000000..6a2733a17 --- /dev/null +++ b/gradle/java.license @@ -0,0 +1,14 @@ +Copyright ${year} ConsenSys AG. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +SPDX-License-Identifier: Apache-2.0 + + diff --git a/gradle/versions.gradle b/gradle/versions.gradle new file mode 100644 index 000000000..4ef31d5d4 --- /dev/null +++ b/gradle/versions.gradle @@ -0,0 +1,15 @@ +dependencyManagement { + dependencies { + + dependency 'com.google.errorprone:javac:9+181-r4173-1' + dependency 'com.google.errorprone:error_prone_check_api:2.3.3' + dependency 'com.google.errorprone:error_prone_core:2.3.3' + dependency 'com.google.errorprone:error_prone_annotation:2.3.3' + dependency 'com.google.errorprone:error_prone_test_helpers:2.3.3' + + dependencySet(group: 'org.junit.jupiter', version: '5.5.2') { + entry 'junit-jupiter-api' + entry 'junit-jupiter-engine' + } + } +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..cc4fdc293 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..bdf2dc9b6 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Nov 26 11:11:41 AEST 2019 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew new file mode 100755 index 000000000..2fe81a7d9 --- /dev/null +++ b/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..9618d8d96 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..f9069d9dc --- /dev/null +++ b/settings.gradle @@ -0,0 +1,10 @@ +/* + * This file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user manual at https://docs.gradle.org/6.0.1/userguide/multi_project_builds.html + */ + +rootProject.name = 'discv5'