diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0e38efb41c1..37ba7e67163 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -74,7 +74,7 @@ jobs: USER_NAME: ${{ secrets.USER_NAME }} ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | - RUN_TESTS="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -ntp "-Dstyle.color=always" -Pdev,examples,assemble,spotbugs -Dmaven.build.cache.enabled=false -Ddeploy -Ddist -T1C clean verify" + RUN_TESTS="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -ntp "-Dstyle.color=always" -Pdev,examples,assemble,spotbugs -Dmaven.build.cache.enabled=false -Ddeploy -Ddist -T1C clean verify -Dutils -Dservices -Dstarters" $RUN_TESTS \ || { echo "***** TESTS FAILED. Attempting retry."; $RUN_TESTS; } \ || { echo "***** TESTS FAILED. Attempting final retry."; $RUN_TESTS; } @@ -110,14 +110,14 @@ jobs: # USER_NAME: ${{ secrets.USER_NAME }} # ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # run: | - # BUILD="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Pdev,examples,assemble,spotbugs -Dmaven.build.cache.enabled=false -DskipServices -Ddeploy -Ddist -T1C -pl "-:config-service" clean install -DskipTests" + # BUILD="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Dstarters -Dservices -Dutils -Pdev,examples,assemble,spotbugs -Dmaven.build.cache.enabled=false -DonlyServiceApis -Ddeploy -Ddist -T1C -pl "-:config-service" clean install -DskipTests" # $BUILD # - name: Run Microservice Unit Tests # env: # USER_NAME: ${{ secrets.USER_NAME }} # ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # run: | - # RUN_TESTS="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Dmaven.build.cache.enabled=false verify" + # RUN_TESTS="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Dstarters -Dservices -Dutils -Dmaven.build.cache.enabled=false verify" # cd microservices # $RUN_TESTS \ # || { echo "***** TESTS FAILED. Attempting retry."; $RUN_TESTS; } \ @@ -183,13 +183,13 @@ jobs: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | # update datawave dependencies to use the latest snapshots - mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e versions:update-properties versions:update-parent -DallowSnapshots=true -Dincludes=gov.nsa.* + mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Dstarters -Dservices -Dutils versions:update-properties versions:update-parent -DallowSnapshots=true -Dincludes=gov.nsa.* - mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Ddeploy -Dtar -DskipTests clean install + mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Dstarters -Dservices -Dutils -Pcompose -Dmicroservice-docker -Dquickstart-docker -Ddeploy -Dtar -DskipTests clean install # free up some space so that we don't run out docker system prune -f - mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Ddeploy -Dtar -DskipTests clean + mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Dstarters -Dservices -Dutils -Pcompose -Dmicroservice-docker -Dquickstart-docker -Ddeploy -Dtar -DskipTests clean cd docker ./bootstrap.sh @@ -264,10 +264,10 @@ jobs: -Durl.hadoop=https://bogus.apache.org/hadoop/common/hadoop-3.3.6/hadoop-3.3.6.tar.gz \ -Durl.maven=https://bogus.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz" - mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Dquickstart-maven ${DIST_URLS} -Ddeploy -Dtar -DskipTests -Dmaven.build.cache.enabled=false clean install + mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Dstarters -Dservices -Dutils -Pcompose -Dmicroservice-docker -Dquickstart-docker -Dquickstart-maven ${DIST_URLS} -Ddeploy -Dtar -DskipTests -Dmaven.build.cache.enabled=false clean install # free up some space so that we don't run out docker system prune -f - mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Dquickstart-maven ${DIST_URLS} -Ddeploy -Dtar -DskipTests -Dmaven.build.cache.enabled=false clean + mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Dstarters -Dservices -Dutils -Pcompose -Dmicroservice-docker -Dquickstart-docker -Dquickstart-maven ${DIST_URLS} -Ddeploy -Dtar -DskipTests -Dmaven.build.cache.enabled=false clean cd docker ./bootstrap.sh attempt=0 diff --git a/.gitmodules b/.gitmodules index 26ad0ff918c..e69de29bb2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,90 +0,0 @@ -[submodule "microservices/services/authorization"] - path = microservices/services/authorization - url = git@github.com:NationalSecurityAgency/datawave-authorization-service.git -[submodule "core/in-memory-accumulo"] - path = core/in-memory-accumulo - url = git@github.com:NationalSecurityAgency/datawave-in-memory-accumulo.git -[submodule "core/utils/accumulo-utils"] - path = core/utils/accumulo-utils - url = git@github.com:NationalSecurityAgency/datawave-accumulo-utils.git -[submodule "core/utils/common-utils"] - path = core/utils/common-utils - url = git@github.com:NationalSecurityAgency/datawave-common-utils.git -[submodule "core/base-rest-responses"] - path = core/base-rest-responses - url = git@github.com:NationalSecurityAgency/datawave-base-rest-responses.git -[submodule "core/utils/type-utils"] - path = core/utils/type-utils - url = git@github.com:NationalSecurityAgency/datawave-type-utils.git -[submodule "core/utils/metadata-utils"] - path = core/utils/metadata-utils - url = git@github.com:NationalSecurityAgency/datawave-metadata-utils.git -[submodule "microservices/services/accumulo"] - path = microservices/services/accumulo - url = git@github.com:NationalSecurityAgency/datawave-accumulo-service.git -[submodule "microservices/services/dictionary"] - path = microservices/services/dictionary - url = git@github.com:NationalSecurityAgency/datawave-dictionary-service.git -[submodule "microservices/services/audit"] - path = microservices/services/audit - url = git@github.com:NationalSecurityAgency/datawave-audit-service.git -[submodule "microservices/services/query-metric"] - path = microservices/services/query-metric - url = git@github.com:NationalSecurityAgency/datawave-query-metric-service.git -[submodule "core/metrics-reporter"] - path = core/metrics-reporter - url = git@github.com:NationalSecurityAgency/datawave-metrics-reporter.git -[submodule "microservices/starters/cache"] - path = microservices/starters/cache - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter-cache.git -[submodule "microservices/starters/datawave"] - path = microservices/starters/datawave - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter.git -[submodule "microservices/services/hazelcast"] - path = microservices/services/hazelcast - url = git@github.com:NationalSecurityAgency/datawave-hazelcast-service.git -[submodule "microservices/starters/metadata"] - path = microservices/starters/metadata - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter-metadata.git -[submodule "microservices/starters/query-metric"] - path = microservices/starters/query-metric - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter-query-metric.git -[submodule "microservices/starters/audit"] - path = microservices/starters/audit - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter-audit.git -[submodule "microservices/services/config"] - path = microservices/services/config - url = git@github.com:NationalSecurityAgency/datawave-config-service.git -[submodule "microservices/microservice-parent"] - path = microservices/microservice-parent - url = git@github.com:NationalSecurityAgency/datawave-parent.git -[submodule "microservices/microservice-service-parent"] - path = microservices/microservice-service-parent - url = git@github.com:NationalSecurityAgency/datawave-service-parent.git -[submodule "contrib/datawave-utils"] - path = contrib/datawave-utils - url = git@github.com:NationalSecurityAgency/datawave-utils.git -[submodule "microservices/starters/query"] - path = microservices/starters/query - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter-query.git -[submodule "microservices/services/query"] - path = microservices/services/query - url = git@github.com:NationalSecurityAgency/datawave-query-service.git -[submodule "microservices/services/query-executor"] - path = microservices/services/query-executor - url = git@github.com:NationalSecurityAgency/datawave-query-executor-service.git -[submodule "microservices/services/modification"] - path = microservices/services/modification - url = git@github.com:NationalSecurityAgency/datawave-modification-service.git -[submodule "microservices/services/mapreduce-query"] - path = microservices/services/mapreduce-query - url = git@github.com:NationalSecurityAgency/datawave-mapreduce-query-service.git -[submodule "microservices/starters/cached-results"] - path = microservices/starters/cached-results - url = git@github.com:NationalSecurityAgency/datawave-spring-boot-starter-cached-results.git -[submodule "microservices/services/map"] - path = microservices/services/map - url = git@github.com:NationalSecurityAgency/datawave-map-service.git -[submodule "microservices/services/file-provider"] - path = microservices/services/file-provider - url = git@github.com:NationalSecurityAgency/datawave-file-provider-service.git diff --git a/BUILDME.md b/BUILDME.md index fbd6744675f..8cdb019042b 100644 --- a/BUILDME.md +++ b/BUILDME.md @@ -65,7 +65,7 @@ mvn -Pdev,assemble,rpm -Ddeploy -Dtar -Ddist -DskipTests clean install Datawave web services utilize several microservices at runtime (currently authorization and auditing, although that list will expand soon). Datawave depends on api modules for some of these services, and the dependencies are set in the parent pom (see `version.datawave.*` properties) to released versions. If you wish to build the microservices -for some reason, you can simply add `-Dservices` to your maven build command. +for some reason, you can simply add `-Dservices` to your maven build command. If you wish to build the starters you can add `-Dstarters` and for the utility modules add `-Dutils`. ### Releasing Microservices diff --git a/README.md b/README.md index 2b154209b7b..98e03f0504a 100644 --- a/README.md +++ b/README.md @@ -19,42 +19,74 @@ Basic build instructions are [here](BUILDME.md) ## How to Use this Repository -The microservices and associated utility projects are intended to be -developed, versioned, and released independently and as such are stored -in separate repositories. This repository includes them all as submodules -in order to provide an easy way to import them all in an IDE for viewing -the code, or refactoring. [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) -require some extra commands over the normal ones that one may be familiar -with. - -### Cloning with all submodules -Cloning with all of the submodules is not required; however, if you are interested in checking -out and building all of the datawave projects under one repo, read this! - -It's easiest to clone the repository pointing the submodules at the same branch -```bash -# Start out by cloning the project as you normally would. -git clone git@github.com:NationalSecurityAgency/datawave.git - -# Now, use git to retrieve all of the datawave submodules. -# This will leave your submodules in a detached head state. -cd datawave -git submodule update --init --recursive - -# You can checkout the main branch for each submodule so that you are no longer in a detached head state. -# The addition of `|| :` will ensure that the command is executed for each submodule, -# ignoring failures for submodules that don't have a main branch. -git submodule foreach 'git checkout main || :' - -# It is recommended to build the project using multiple threads. -mvn -Pdocker,dist clean install -T 1C +The microservices and associated utility projects are intended to be developed, versioned, +and released independently. The following subdirectories contain those independently +versioned modules: + +``` +core/utils/type-utils +contrib/datawave-utils +core/base-rest-responses +core/in-memory-accumulo +core/metrics-reporter +core/utils/accumulo-utils +core/utils/common-utils +core/utils/metadata-utils +microservices/microservice-parent +microservices/microservice-service-parent +microservices/starters/audit +microservices/starters/cache +microservices/starters/cached-results +microservices/starters/datawave +microservices/starters/metadata +microservices/starters/query +microservices/starters/query-metric +microservices/services/accumulo +microservices/services/audit +microservices/services/authorization +microservices/services/config +microservices/services/dictionary +microservices/services/file-provider +microservices/services/hazelcast +microservices/services/map +microservices/services/mapreduce-query +microservices/services/modification +microservices/services/query +microservices/services/query-executor +microservices/services/query-metric +``` -# If you don't want to build the microservices, you can skip them. -mvn -Pdocker,dist -DskipMicroservices clean install -T 1C +Each of those subdirectories contain a .gitrepo file that keeps track of where the code came from. -# If you decide that you no longer need the submodules, you can remove them. -git submodule deinit --all +### Updating one of the datawave sub-repositories +At one point we used submodules to link in a all of the sub-repositories. We have now switched +to including the submodules' code directly into the main datawave repository. The git subrepo +mechanism (https://github.com/ingydotnet/git-subrepo) was used to facilitate the transition. +That same mechanism can be used to pull in changes from the other repositories as needed until +they can be removed altogether. The original cloning of the sub repositories was done using +the subrepo command as follows: ``` +git subrepo clone +``` +If changes need to be pulled in, then the following process can be used: +``` +git subrepo pull +``` +### Building + +It is recommended to build the project using multiple threads. This will not build the starters, utilities, and services. +``` +mvn -Pdocker,dist clean install -T 1C +``` + +If you want to build the starters, util modules, and services as well then try this +``` +mvn -Pdocker,dist -Dstarters -Dservices -Dutils clean install -T 1C +``` +If you want to build the service apis but not the services themselveds then add -DonlyServiceApis + +NOTE: The util modules, starters, and services are actually tagged and deployed separately. + Hence the snapshot versions within those sub repos are not connected together. ### DataWave Microservices diff --git a/contrib/datawave-utils b/contrib/datawave-utils deleted file mode 160000 index 4348fc36a35..00000000000 --- a/contrib/datawave-utils +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4348fc36a3519ca9e5d1b96ac47c3f0b64abe34b diff --git a/contrib/datawave-utils/.gitignore b/contrib/datawave-utils/.gitignore new file mode 100644 index 00000000000..6e170178597 --- /dev/null +++ b/contrib/datawave-utils/.gitignore @@ -0,0 +1,9 @@ +target/ + +.idea/ +*.iml +*.iws + +.classpath +.project +.settings/ diff --git a/contrib/datawave-utils/.gitrepo b/contrib/datawave-utils/.gitrepo new file mode 100644 index 00000000000..6708754832e --- /dev/null +++ b/contrib/datawave-utils/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme +; +[subrepo] + remote = git@github.com:NationalSecurityAgency/datawave-utils.git + branch = main + commit = 4348fc36a3519ca9e5d1b96ac47c3f0b64abe34b + parent = 1f96d1af84c45f32007da0105b8eab514ec3f7d3 + method = merge + cmdver = 0.4.9 diff --git a/contrib/datawave-utils/LICENSE b/contrib/datawave-utils/LICENSE new file mode 100644 index 00000000000..6b0b1270ff0 --- /dev/null +++ b/contrib/datawave-utils/LICENSE @@ -0,0 +1,203 @@ + + 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/contrib/datawave-utils/assert-properties/pom.xml b/contrib/datawave-utils/assert-properties/pom.xml new file mode 100644 index 00000000000..cc29cca46ff --- /dev/null +++ b/contrib/datawave-utils/assert-properties/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + gov.nsa.datawave.plugins + assert-properties + 2.0.2-SNAPSHOT + + maven-plugin + DataWave Assert Properties Plugin + Asserts that required maven properties have been defined. + https://code.nsa.gov/datawave-utils + + + The Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + scm:git:https://github.com/NationalSecurityAgency/datawave-utils.git + scm:git:git@github.com:NationalSecurityAgency/datawave-utils.git + https://github.com/NationalSecurityAgency/datawave-utils + + + + github-datawave + GitHub Datawave Apache Maven Packages + https://maven.pkg.github.com/NationalSecurityAgency/datawave + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + true + UTF-8 + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + @{project.artifactId}_@{project.version} + dist + -Ddist + + + + + + + + org.apache.maven + maven-core + 3.0.5 + + + org.apache.maven + maven-plugin-api + 3.0.5 + + + commons-lang + commons-lang + 2.6 + + + + diff --git a/contrib/datawave-utils/assert-properties/src/main/java/datawave/maven/AssertProperties.java b/contrib/datawave-utils/assert-properties/src/main/java/datawave/maven/AssertProperties.java new file mode 100644 index 00000000000..be266bfe140 --- /dev/null +++ b/contrib/datawave-utils/assert-properties/src/main/java/datawave/maven/AssertProperties.java @@ -0,0 +1,214 @@ +package datawave.maven; + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; + +/** + * @goal assert-properties + * @phase validate + * @threadSafe true + */ +@SuppressWarnings("unused") +public class AssertProperties extends AbstractMojo { + private static final Character COMMENT = '#', COMMA = ','; + + /** + * @parameter default-value="${project}" + * @required + * @readonly + */ + private MavenProject project; + + /** + * @parameter + * @required + */ + private File expectedPropertyNames; + + /** + * @parameter + */ + private File configuredPropertyNames; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + validatePropertyNames(); + + Properties buildProps = getConfiguredProperties(); + + Map getExpectedPropertyMap = getExpectedPropertyMap(); + + // Retain only properties from the build environment that are Entry + Set propertyNames = new HashSet<>(); + for (Entry entry : buildProps.entrySet()) { + Object key = entry.getKey(), value = entry.getValue(); + + if (key instanceof String && value instanceof String) { + propertyNames.add((String)key); + } + } + + // Remove all provided properties + Set expectedProperties = getExpectedPropertyMap.keySet(); + expectedProperties.removeAll(propertyNames); + + if (expectedProperties.size() > 0) { + StringBuilder errorMessage = new StringBuilder(); + errorMessage.append(expectedProperties.size() + " properties were not provided:\n"); + for (Entry entry : getExpectedPropertyMap.entrySet()) { + errorMessage.append("Missing property: " + entry.getKey() + ", Description: " + entry.getValue()).append("\n"); + } + + throw new MojoFailureException(errorMessage.toString()); + } + } + + protected void validatePropertyNames() throws MojoExecutionException { + if (!this.expectedPropertyNames.isFile()) { + throw new MojoExecutionException("expectedPropertyNames must be a file"); + } + + if (null != this.configuredPropertyNames && !this.configuredPropertyNames.isFile()) { + throw new MojoExecutionException("configuredPropertyNames must be a file if provided"); + } + + } + + protected Properties getConfiguredProperties() throws MojoExecutionException { + Properties buildProps = project.getProperties(); + Properties envProps; + + if (null == this.configuredPropertyNames) { + envProps = buildProps; + } else { + FileReader propReader = null; + envProps = new Properties(); + try { + propReader = new FileReader(configuredPropertyNames); + envProps.load(propReader); + } catch (IOException e) { + throw new MojoExecutionException("Could not load configuredPropertyNames", e); + } finally { + // Make sure we don't leave any open file handles laying around + if (null != propReader) { + try { + propReader.close(); + } catch (IOException e) { + throw new MojoExecutionException("Could not load configuredPropertyNames", e); + } + } + } + } + + for (Entry entry : buildProps.entrySet()) { + envProps.put(entry.getKey(), entry.getValue()); + } + + return envProps; + } + + /** + * Fetch the set of strings from the configured filename + * @return + * @throws MojoExecutionException + * @throws IOException + */ + protected Map getExpectedPropertyMap() throws MojoExecutionException { + BufferedReader reader ; + try { + reader = new BufferedReader(new FileReader(this.expectedPropertyNames)); + } catch (FileNotFoundException e) { + getLog().warn("Could not read exepcted properties files"); + + throw new MojoExecutionException("Could not read expected properties file", e); + } + + HashMap expectedProperties = new HashMap<>(); + + String line = null; + try { + while ((line = reader.readLine()) != null) { + // Remove leading/trailing whitespace + line = line.trim(); + + // Ignore empty lines or those starting with a '#' + if (StringUtils.isBlank(line) || line.charAt(0) == COMMENT) { + continue; + } + + // Strip everything after a comma if it exists + int index = line.indexOf(COMMA); + String candidateName, candidateDescription; + + // Trim again to make sure we catch any "new" trailing whitespace + // after the property name but before where the comma was + if (index == -1) { + candidateName = line.trim(); + candidateDescription = ""; + } else { + candidateName = line.substring(0, index).trim(); + candidateDescription = line.substring(index + 1).trim(); + } + + // Add it to the expected set i the line still isn't blank + if (StringUtils.isNotBlank(candidateName)) { + expectedProperties.put(candidateName, candidateDescription); + } + } + } catch (IOException e) { + throw new MojoExecutionException("Could not read expected properties file", e); + } finally { + // Make sure we don't leave any open file handles laying around + try { + reader.close(); + } catch (IOException e) { + throw new MojoExecutionException("Could not close reader to expected properties", e); + } + } + + if (expectedProperties.isEmpty()) { + getLog().warn("No expected properties were loaded from " + this.expectedPropertyNames); + } + + return expectedProperties; + } + + public MavenProject getProject() { + return project; + } + + public void setProject(MavenProject project) { + this.project = project; + } + + public File getExpectedPropertyNames() { + return expectedPropertyNames; + } + + public void setExpectedPropertyNames(File expectedPropertyNames) { + this.expectedPropertyNames = expectedPropertyNames; + } + + public File getConfiguredPropertyNames() { + return configuredPropertyNames; + } + + public void setConfiguredPropertyNames(File configuredPropertyNames) { + this.configuredPropertyNames = configuredPropertyNames; + } +} diff --git a/contrib/datawave-utils/code-style/pom.xml b/contrib/datawave-utils/code-style/pom.xml new file mode 100644 index 00000000000..9febbb7c6ef --- /dev/null +++ b/contrib/datawave-utils/code-style/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + gov.nsa.datawave + datawave-code-style + 1.1-SNAPSHOT + jar + DataWave Code Formatter + This pom configures the formatter-maven-plugin to format the code + according to the DataWave code style. + https://code.nsa.gov/datawave-urils + + + The Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + scm:git:https://github.com/NationalSecurityAgency/datawave-utils.git + scm:git:git@github.com:NationalSecurityAgency/datawave-utils.git + https://github.com/NationalSecurityAgency/datawave-utils + + + + github-datawave + GitHub Datawave Apache Maven Packages + https://maven.pkg.github.com/NationalSecurityAgency/datawave + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + @{project.artifactId}_@{project.version} + dist + -Ddist + + + + + diff --git a/contrib/datawave-utils/code-style/src/main/resources/eclipse/Eclipse-Datawave-Codestyle.xml b/contrib/datawave-utils/code-style/src/main/resources/eclipse/Eclipse-Datawave-Codestyle.xml new file mode 100644 index 00000000000..71f031467b1 --- /dev/null +++ b/contrib/datawave-utils/code-style/src/main/resources/eclipse/Eclipse-Datawave-Codestyle.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/datawave-utils/code-style/src/main/resources/eclipse/Eclipse-Datawave-Template.xml b/contrib/datawave-utils/code-style/src/main/resources/eclipse/Eclipse-Datawave-Template.xml new file mode 100644 index 00000000000..ae67af04738 --- /dev/null +++ b/contrib/datawave-utils/code-style/src/main/resources/eclipse/Eclipse-Datawave-Template.xml @@ -0,0 +1,31 @@ + + +