From eca78b155a69416aaf5a62fb0f5c952c6279490b Mon Sep 17 00:00:00 2001 From: eschleb Date: Fri, 20 Sep 2024 14:35:59 +0200 Subject: [PATCH] initial commit --- .github/actions/mvn-setup/action.yml | 22 + .../workflows/release-and-deploy-release.yml | 79 ++ .github/workflows/verify.yml | 30 + .gitignore | 12 + LICENSE | 674 ++++++++++++++++++ README.md | 112 +++ ci/mvn-release.sh | 35 + ci/semver.sh | 52 ++ ci/setup-git.sh | 4 + common-task/pom.xml | 35 + .../AbstractConfigureSchedulerJobTask.java | 59 ++ .../AbstractInstallDialogFieldTypesTask.java | 65 ++ .../common/AbstractInstallFilterTask.java | 85 +++ .../setup/task/common/InstallLicenseTask.java | 69 ++ .../task/common/ReregisterServletsTask.java | 60 ++ .../common/SetEmptyDefaultExtensionTask.java | 34 + .../setup/task/common/SetupSmtpTask.java | 111 +++ .../security/util/GroupManagerUtil.java | 44 ++ .../common/security/util/RoleManagerUtil.java | 123 ++++ .../common/security/util/UserManagerUtil.java | 77 ++ core/pom.xml | 37 + .../setup/EnhancedModuleVersionHandler.java | 127 ++++ .../oss/magnolia/setup/task/TaskExecutor.java | 119 ++++ .../AbstractContentNodeBuilderTask.java | 73 ++ .../AbstractPathNodeBuilderTask.java | 43 ++ .../setup/task/type/DepdendsOnComparator.java | 41 ++ .../setup/task/type/InstallAndUpdateTask.java | 7 + .../magnolia/setup/task/type/InstallTask.java | 7 + .../type/LocalDevelopmentStartupTask.java | 7 + .../setup/task/type/ModuleStartupTask.java | 7 + .../setup/task/type/SnapshotStartupTask.java | 7 + .../magnolia/setup/task/type/UpdateTask.java | 7 + .../setup/task/type/VersionAwareTask.java | 22 + .../task/type/DepdendsOnComparatorTest.java | 80 +++ pom.xml | 221 ++++++ 35 files changed, 2587 insertions(+) create mode 100644 .github/actions/mvn-setup/action.yml create mode 100644 .github/workflows/release-and-deploy-release.yml create mode 100644 .github/workflows/verify.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100755 ci/mvn-release.sh create mode 100644 ci/semver.sh create mode 100755 ci/setup-git.sh create mode 100644 common-task/pom.xml create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractConfigureSchedulerJobTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallDialogFieldTypesTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallFilterTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/InstallLicenseTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/ReregisterServletsTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetEmptyDefaultExtensionTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetupSmtpTask.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/GroupManagerUtil.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/RoleManagerUtil.java create mode 100644 common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/UserManagerUtil.java create mode 100644 core/pom.xml create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/EnhancedModuleVersionHandler.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/TaskExecutor.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractContentNodeBuilderTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractPathNodeBuilderTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparator.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallAndUpdateTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/LocalDevelopmentStartupTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/ModuleStartupTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/SnapshotStartupTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/UpdateTask.java create mode 100644 core/src/main/java/com/merkle/oss/magnolia/setup/task/type/VersionAwareTask.java create mode 100644 core/src/test/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparatorTest.java create mode 100644 pom.xml diff --git a/.github/actions/mvn-setup/action.yml b/.github/actions/mvn-setup/action.yml new file mode 100644 index 0000000..6224e2a --- /dev/null +++ b/.github/actions/mvn-setup/action.yml @@ -0,0 +1,22 @@ +name: "Setup maven" +description: "Configures maven settings" + +inputs: + mgnl_nexus_user: + description: “Username for magnolia nexus” + required: true + mgnl_nexus_pass: + description: “Password for magnolia nexus” + required: true + +runs: + using: "composite" + steps: + - uses: s4u/maven-settings-action@v2 + with: + servers: | + [{ + "id": "magnolia.enterprise.group", + "username": "${{ inputs.mgnl_nexus_user }}", + "password": "${{ inputs.mgnl_nexus_pass }}" + }] \ No newline at end of file diff --git a/.github/workflows/release-and-deploy-release.yml b/.github/workflows/release-and-deploy-release.yml new file mode 100644 index 0000000..d4c3198 --- /dev/null +++ b/.github/workflows/release-and-deploy-release.yml @@ -0,0 +1,79 @@ +name: release and deploy + +on: + push: + branches: + - main + +jobs: + release: + + runs-on: ubuntu-latest + + steps: + # Checkout source code + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: '0' + # Setup Java environment + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Maven setup + uses: ./.github/actions/mvn-setup + with: + mgnl_nexus_user: ${{secrets.MGNL_NEXUS_USER}} + mgnl_nexus_pass: ${{secrets.MGNL_NEXUS_PASS}} + # Install xmllint + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install libxml2-utils + # Set git user name and email + - name: Set up Git + run: | + chmod +x ci/setup-git.sh + ci/setup-git.sh + # Release, set correct versions and create tag + - name: Release (versioning/tag) + run: | + chmod +x ci/mvn-release.sh + ci/mvn-release.sh + + deploy-release: + + needs: release + runs-on: ubuntu-latest + + steps: + # Checkout source code + - name: Checkout + uses: actions/checkout@v2 + with: + ref: 'main' + # Setup Java environment + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + server-id: central + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-passphrase: MAVEN_GPG_PASSPHRASE + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + - name: Maven setup + uses: ./.github/actions/mvn-setup + with: + mgnl_nexus_user: ${{secrets.MGNL_NEXUS_USER}} + mgnl_nexus_pass: ${{secrets.MGNL_NEXUS_PASS}} + # Run maven verify + - name: Maven verify + run: mvn verify --batch-mode + # Publish + - name: Release Maven package (SNAPSHOT) + run: mvn deploy -Pdeploy + env: + MAVEN_USERNAME: ${{ secrets.SONATYPE_USER }} + MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} \ No newline at end of file diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..760753c --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,30 @@ +name: verify + +on: + push: + branches-ignore: + - main + +jobs: + verify: + + runs-on: ubuntu-latest + + steps: + # Checkout source code + - name: Checkout + uses: actions/checkout@v2 + # Setup Java environment + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + - name: Maven setup + uses: ./.github/actions/mvn-setup + with: + mgnl_nexus_user: ${{secrets.MGNL_NEXUS_USER}} + mgnl_nexus_pass: ${{secrets.MGNL_NEXUS_PASS}} + # Run maven verify + - name: Maven verify + run: mvn verify --batch-mode \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed400e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# OS +.DS_Store +Thumbs.db + +target + +.idea +*.iml + +#JRebel +rebel.xml +codesigning.asc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b73d619 --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +# Magnolia setup task + +Setup task to help bootstrap magnolia. + +## Implementation + +```java +import info.magnolia.module.InstallContext; +import info.magnolia.module.model.Version; + +import java.util.Optional; + +import javax.annotation.Nullable; + +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; +import com.merkle.oss.magnolia.setup.task.type.VersionAwareTask; + +public class SomeTask implements InstallAndUpdateTask { + + @Override + public String getName() { + return "someTask"; + } + + @Override + public String getDescription() { + return "someTask description"; + } + + @Override + public void execute(InstallContext installContext) { + //do stuff + } + + //Optional + @Override + public boolean test(final Version forVersion, @Nullable final Version fromVersion) { + return true; + } + + //Optional + @Override + public Optional dependsOn() { + return Optional.empty(); + } +} + +``` + + +## Setup +### Guice Set-Binding +```java +import com.google.inject.Binder; +import com.google.inject.multibindings.Multibinder; + +import info.magnolia.objectfactory.guice.AbstractGuiceComponentConfigurer; + +public class CustomGuiceComponentConfigurer extends AbstractGuiceComponentConfigurer { + @Override + protected void configure() { + super.configure(); + final Multibinder installTaskSetBinder = Multibinder.newSetBinder(binder(), InstallTask.class, Names.named("myModule")); + installTaskSetBinder.addBinding().to(SomeInstallTask.class); + ... + } +} +``` + +### Module version handler +```xml + + myModule + ...MyModuleVersionHandler + ... + +``` +```java +import java.util.Set; + +import javax.inject.Inject; +import javax.inject.Named; + +import com.merkle.oss.magnolia.setup.EnhancedModuleVersionHandler; +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; +import com.merkle.oss.magnolia.setup.task.type.InstallTask; +import com.merkle.oss.magnolia.setup.task.type.LocalDevelopmentStartupTask; +import com.merkle.oss.magnolia.setup.task.type.ModuleStartupTask; +import com.merkle.oss.magnolia.setup.task.type.SnapshotStartupTask; +import com.merkle.oss.magnolia.setup.task.type.UpdateTask; + +public class MyModuleVersionHandler extends EnhancedModuleVersionHandler { + + // Multibinding configured in SetupTasksGuiceComponentConfigurer + @Inject + public MyModuleVersionHandler( + @Named("myModule") final Set installTasks, + @Named("myModule") final Set updateTasks, + @Named("myModule") final Set installAndUpdateTasks, + @Named("myModule") final Set moduleStartupTasks, + @Named("myModule") final Set snapshotStartupTasks, + @Named("myModule") final Set localDevelopmentStartupTasks + ) { + super(installTasks, updateTasks, installAndUpdateTasks, moduleStartupTasks, snapshotStartupTasks, localDevelopmentStartupTasks); + } + + @Override + protected boolean isLocalDevelopmentEnvironment() { + return false; //TODO implement + } +} +``` \ No newline at end of file diff --git a/ci/mvn-release.sh b/ci/mvn-release.sh new file mode 100755 index 0000000..f2383b1 --- /dev/null +++ b/ci/mvn-release.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +CURRENT_VERSION=`xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml` + +if [[ $CURRENT_VERSION == *-SNAPSHOT ]]; then + NEW_VERSION=${CURRENT_VERSION%'-SNAPSHOT'} + NEXT_VERSION=`bash ci/semver.sh -p $NEW_VERSION` + NEXT_SNAPSHOT="$NEXT_VERSION-SNAPSHOT" + echo "perform release of $NEW_VERSION from $CURRENT_VERSION and set next develop version $NEXT_SNAPSHOT" + + mvn versions:set -DnewVersion=$NEW_VERSION versions:commit --no-transfer-progress + + echo "commit new release version" + git commit -a -m "Release $NEW_VERSION: set main to new release version" + + echo "Update version in README.md" + sed -i -e "s|[0-9A-Za-z._-]\{1,\}|$NEW_VERSION|g" README.md && rm -f README.md-e + git commit -a -m "Release $NEW_VERSION: Update README.md" + + echo "create tag for new release" + git tag -a $NEW_VERSION -m "Release $NEW_VERSION: tag release" + + echo "merge main back to develop" + git fetch --all + git checkout develop + git merge main + + mvn versions:set -DnewVersion=$NEXT_SNAPSHOT versions:commit --no-transfer-progress + + echo "commit new snapshot version" + git commit -a -m "Release $NEW_VERSION: set develop to next development version $NEXT_SNAPSHOT" + + git push --all + git push --tags +fi diff --git a/ci/semver.sh b/ci/semver.sh new file mode 100644 index 0000000..b731ce9 --- /dev/null +++ b/ci/semver.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Increment a version string using Semantic Versioning (SemVer) terminology. + +# Parse command line options. + +while getopts ":Mmp" Option +do + case $Option in + M ) major=true;; + m ) minor=true;; + p ) patch=true;; + esac +done + +shift $(($OPTIND - 1)) + +version=$1 + +# Build array from version string. + +a=( ${version//./ } ) + +# If version string is missing or has the wrong number of members, show usage message. + +if [ ${#a[@]} -ne 3 ] +then + echo "usage: $(basename $0) [-Mmp] major.minor.patch" + exit 1 +fi + +# Increment version numbers as requested. + +if [ ! -z $major ] +then + ((a[0]++)) + a[1]=0 + a[2]=0 +fi + +if [ ! -z $minor ] +then + ((a[1]++)) + a[2]=0 +fi + +if [ ! -z $patch ] +then + ((a[2]++)) +fi + +echo "${a[0]}.${a[1]}.${a[2]}" diff --git a/ci/setup-git.sh b/ci/setup-git.sh new file mode 100755 index 0000000..ca2210a --- /dev/null +++ b/ci/setup-git.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +git config --global user.email "oss@merkle.com" +git config --global user.name "Merkle OSS CI" diff --git a/common-task/pom.xml b/common-task/pom.xml new file mode 100644 index 0000000..a266b33 --- /dev/null +++ b/common-task/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + + com.merkle.oss.magnolia + magnolia-setup-task + 0.0.1-SNAPSHOT + + + magnolia-setup-task-common + + + + com.merkle.oss.magnolia + magnolia-setup-task-core + + + com.namics.oss.magnolia + magnolia-powernode + + + info.magnolia.scheduler + magnolia-module-scheduler + provided + + + info.magnolia.ui + magnolia-ui-framework + provided + + + \ No newline at end of file diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractConfigureSchedulerJobTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractConfigureSchedulerJobTask.java new file mode 100644 index 0000000..55c41b9 --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractConfigureSchedulerJobTask.java @@ -0,0 +1,59 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import info.magnolia.jcr.nodebuilder.NodeOperation; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.jcr.util.PropertyUtil; +import info.magnolia.module.InstallContext; +import info.magnolia.module.scheduler.JobDefinition; +import info.magnolia.repository.RepositoryConstants; + +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; + +import org.apache.commons.lang3.StringUtils; +import org.apache.jackrabbit.value.ValueFactoryImpl; + +import com.merkle.oss.magnolia.powernode.NodeOperationFactory; +import com.merkle.oss.magnolia.powernode.ValueConverter; +import com.merkle.oss.magnolia.setup.task.nodebuilder.AbstractPathNodeBuilderTask; +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; + +public abstract class AbstractConfigureSchedulerJobTask extends AbstractPathNodeBuilderTask implements InstallAndUpdateTask { + private static final String PATH = "/modules/scheduler/config/jobs"; + + private final NodeOperationFactory ops; + + protected AbstractConfigureSchedulerJobTask( + final NodeOperationFactory nodeOperationFactory, + final String taskName, + final String description, + final ErrorHandling errorHandling + ) { + super(taskName, description, errorHandling, RepositoryConstants.CONFIG, PATH); + this.ops = nodeOperationFactory; + } + + @Override + protected NodeOperation[] getNodeOperations(InstallContext ctx) { + return getJobs().map(this::configureJob).toArray(NodeOperation[]::new); + } + + protected abstract Stream getJobs(); + + private NodeOperation configureJob(final JobDefinition jobDefinition) { + return ops.getOrAddContentNode(jobDefinition.getName()).then( + ops.setProperty("catalog", jobDefinition.getCatalog(), ValueConverter::toValue), + ops.setProperty("command", jobDefinition.getCommand(), ValueConverter::toValue), + ops.setProperty("cron", jobDefinition.getCron(), ValueConverter::toValue), + ops.setProperty("description", Optional.ofNullable(jobDefinition.getDescription()).orElse(StringUtils.EMPTY), ValueConverter::toValue), + ops.setProperty("concurrent", jobDefinition.isConcurrent(), ValueConverter::toValue), + ops.getOrAddContentNode("params").then( + ((Map) jobDefinition.getParams()).entrySet().stream().map(entry -> + ops.setProperty(entry.getKey(), entry.getValue(), (valueConverter, property) -> Optional.of(PropertyUtil.createValue(property, ValueFactoryImpl.getInstance()))) + ).toArray(NodeOperation[]::new) + ), + ops.setEnabledProperty(jobDefinition.isEnabled()) + ); + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallDialogFieldTypesTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallDialogFieldTypesTask.java new file mode 100644 index 0000000..3930635 --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallDialogFieldTypesTask.java @@ -0,0 +1,65 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import info.magnolia.jcr.nodebuilder.NodeOperation; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.module.InstallContext; +import info.magnolia.repository.RepositoryConstants; +import info.magnolia.ui.field.ConfiguredFieldDefinition; +import info.magnolia.ui.field.factory.AbstractFieldFactory; + +import java.lang.invoke.MethodHandles; +import java.text.MessageFormat; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.merkle.oss.magnolia.powernode.NodeOperationFactory; +import com.merkle.oss.magnolia.powernode.ValueConverter; +import com.merkle.oss.magnolia.setup.task.nodebuilder.AbstractPathNodeBuilderTask; + +/** + * Base class for dialog field type install tasks. + */ +public abstract class AbstractInstallDialogFieldTypesTask extends AbstractPathNodeBuilderTask { + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private static final String TASK_NAME = "Install Dialog Field Types"; + private static final String TASK_DESCRIPTION = "Install Dialog Field Types"; + + public static final String MODULE_PATH = "modules/{0}"; + + private final NodeOperationFactory ops; + private final String fieldTypeName; + private final Class definitionClass; + private final Class factoryClass; + + protected AbstractInstallDialogFieldTypesTask( + final NodeOperationFactory nodeOperationFactory, + final String fieldTypeName, + final Class definitionClass, + final Class factoryClass + ) { + super(TASK_NAME, TASK_DESCRIPTION, ErrorHandling.strict, RepositoryConstants.CONFIG); + this.ops = nodeOperationFactory; + this.fieldTypeName = fieldTypeName; + this.definitionClass = definitionClass; + this.factoryClass = factoryClass; + } + + @Override + protected NodeOperation[] getNodeOperations(final InstallContext ctx) { + final String moduleName = ctx.getCurrentModuleDefinition().getName(); + final String modulePath = MessageFormat.format(MODULE_PATH, moduleName); + LOG.info("installing dialogFieldType '{}' for module {}", fieldTypeName, modulePath); + return new NodeOperation[]{ + ops.getOrAddContentNode(modulePath).then( + ops.getOrAddContentNode("fieldTypes").then( + ops.getOrAddContentNode(fieldTypeName).then( + ops.setProperty("definitionClass", definitionClass.getName(), ValueConverter::toValue), + ops.setProperty("factoryClass", factoryClass.getName(), ValueConverter::toValue) + ) + ) + ) + }; + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallFilterTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallFilterTask.java new file mode 100644 index 0000000..5fafecd --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/AbstractInstallFilterTask.java @@ -0,0 +1,85 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import com.merkle.oss.magnolia.powernode.NodeOperationFactory; +import com.merkle.oss.magnolia.setup.task.nodebuilder.AbstractPathNodeBuilderTask; +import com.merkle.oss.magnolia.powernode.ValueConverter; +import info.magnolia.cms.filters.FilterManager; +import info.magnolia.cms.filters.MgnlFilter; +import info.magnolia.jcr.nodebuilder.NodeOperation; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.FilterOrderingTask; +import info.magnolia.module.delta.TaskExecutionException; +import info.magnolia.repository.RepositoryConstants; + +import javax.jcr.RepositoryException; +import java.util.Arrays; +import java.util.stream.Stream; + +public abstract class AbstractInstallFilterTask extends AbstractPathNodeBuilderTask { + protected final NodeOperationFactory ops; + private final Class filterClass; + private final String filterName; + private final String[] requiredFiltersBefore; + + /** + * Installs a Filter into the filter chain (and replaces an existing filter at the same place with the same name) + * + * @param filterClass class of the magnolia filter + * @param filterName name of the node the filter should be created in. Must be a relative path below the root path of the filter chain (/server/filters) + * @param requiredFiltersBefore an array of filter names that must appear before the filter specified as filterName. + */ + protected AbstractInstallFilterTask( + final NodeOperationFactory nodeOperationFactory, + final Class filterClass, + final String filterName, + final String... requiredFiltersBefore + ) { + super( + "Install Filter " + filterName + "(" + filterClass + ")", + "", + ErrorHandling.strict, + RepositoryConstants.CONFIG, + FilterManager.SERVER_FILTERS + ); + this.ops = nodeOperationFactory; + this.filterClass = filterClass; + this.filterName = filterName; + this.requiredFiltersBefore = requiredFiltersBefore; + } + + @Override + protected final void doExecute(final InstallContext installContext) throws RepositoryException, TaskExecutionException { + super.doExecute(installContext); + new FilterOrderingTask(filterName, requiredFiltersBefore).execute(installContext); + } + + @Override + protected final NodeOperation[] getNodeOperations(InstallContext ctx) { + return new NodeOperation[]{ + ops.getOrAddNode(filterName).then( + append( + getFilterNodeOperations(), + ops.setProperty("class", filterClass.getName(), ValueConverter::toValue), + ops.setProperty("enabled", true, ValueConverter::toValue) + ) + ) + }; + } + + private NodeOperation[] append(final NodeOperation[] ops1, final NodeOperation... ops2) { + return Stream + .concat( + Arrays.stream(ops1), + Arrays.stream(ops2) + ) + .toArray(NodeOperation[]::new); + } + + /** + * NodeOperations to be executed in the context of the newly created filter node. + */ + protected NodeOperation[] getFilterNodeOperations() { + return new NodeOperation[]{}; + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/InstallLicenseTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/InstallLicenseTask.java new file mode 100644 index 0000000..aaa4501 --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/InstallLicenseTask.java @@ -0,0 +1,69 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import info.magnolia.init.MagnoliaConfigurationProperties; +import info.magnolia.jcr.nodebuilder.NodeOperation; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.module.InstallContext; +import info.magnolia.repository.RepositoryConstants; + +import java.util.Optional; + +import javax.inject.Inject; + +import com.merkle.oss.magnolia.powernode.NodeOperationFactory; +import com.merkle.oss.magnolia.powernode.ValueConverter; +import com.merkle.oss.magnolia.setup.task.nodebuilder.AbstractPathNodeBuilderTask; +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; +import com.merkle.oss.magnolia.setup.task.type.LocalDevelopmentStartupTask; + +/** + * Configure magnolia license. + *

+ * Use the following properties in magnolia.properties: + *

+ * magnolia.license.owner= + * magnolia.license.key= + *

+ * - Add to according 'ModuleVersionHandler' in a project + * - Execute as getInstallAndUpdateTask + */ +public class InstallLicenseTask extends AbstractPathNodeBuilderTask implements InstallAndUpdateTask { + private static final String TASK_NAME = "Install License Task"; + private static final String TASK_DESCRIPTION = "This task installs the Magnolia license."; + private static final String PATH = "/modules/enterprise"; + + private final MagnoliaConfigurationProperties properties; + private final NodeOperationFactory ops; + + @Inject + public InstallLicenseTask( + final NodeOperationFactory nodeOperationFactory, + final MagnoliaConfigurationProperties properties + ) { + super(TASK_NAME, TASK_DESCRIPTION, ErrorHandling.strict, RepositoryConstants.CONFIG, PATH); + this.ops = nodeOperationFactory; + this.properties = properties; + } + + @Override + protected NodeOperation[] getNodeOperations(final InstallContext ctx) { + return getOwner().flatMap(owner -> getKey().map(key -> + ops.getOrAddContentNode("license").then( + ops.setProperty("owner", owner, ValueConverter::toValue), + ops.setProperty("key", key, ValueConverter::toValue) + ) + )).stream().toArray(NodeOperation[]::new); + } + + private Optional getOwner() { + return getProperty("magnolia.license.owner"); + } + + private Optional getKey() { + return getProperty("magnolia.license.key"); + } + + private Optional getProperty(final String key) { + return Optional.ofNullable(properties.getProperty(key)); + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/ReregisterServletsTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/ReregisterServletsTask.java new file mode 100644 index 0000000..95ecba1 --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/ReregisterServletsTask.java @@ -0,0 +1,60 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import info.magnolia.jcr.util.NodeNameHelper; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.ArrayDelegateTask; +import info.magnolia.module.delta.RegisterServletTask; +import info.magnolia.module.delta.TaskExecutionException; +import info.magnolia.module.model.ModuleDefinition; +import info.magnolia.module.model.ServletDefinition; + +import javax.inject.Inject; +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; + +/** + * Reregistering servlets. Normally they only get registered on install, but not on update (info.magnolia.module.delta.RegisterModuleServletsTask) + */ +public class ReregisterServletsTask extends ArrayDelegateTask implements InstallAndUpdateTask { + private static final String DEFAULT_SERVLET_FILTER_PATH = "server/filters/servlets"; + private final NodeNameHelper nodeNameHelper; + + @Inject + public ReregisterServletsTask(final NodeNameHelper nodeNameHelper) { + super("Reregister module servlets", "Reregisters servlets for this module."); + this.nodeNameHelper = nodeNameHelper; + } + + @Override + public void execute(InstallContext installContext) throws TaskExecutionException { + final ModuleDefinition moduleDefinition = installContext.getCurrentModuleDefinition(); + for (ServletDefinition servletDefinition : moduleDefinition.getServlets()) { + addTask(new ReregisterServletTask(servletDefinition, nodeNameHelper)); + } + super.execute(installContext); + } + + private static class ReregisterServletTask extends RegisterServletTask { + public ReregisterServletTask(ServletDefinition servletDefinition, NodeNameHelper nodeNameHelper) { + super(servletDefinition, nodeNameHelper); + } + + @Override + public void execute(final InstallContext installContext) throws TaskExecutionException { + if(!isRegistered(installContext)) { + super.execute(installContext); + } + } + + private boolean isRegistered(final InstallContext installContext) throws TaskExecutionException { + try { + final Session session = installContext.getConfigJCRSession(); + return session.getRootNode().hasNode(DEFAULT_SERVLET_FILTER_PATH + "/" + getServletDefinition().getName()); + } catch (RepositoryException e) { + throw new TaskExecutionException("Failed to reregister servlet "+getServletDefinition().getName(), e); + } + } + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetEmptyDefaultExtensionTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetEmptyDefaultExtensionTask.java new file mode 100644 index 0000000..0ae2f0a --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetEmptyDefaultExtensionTask.java @@ -0,0 +1,34 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import com.merkle.oss.magnolia.powernode.NodeOperationFactory; +import com.merkle.oss.magnolia.powernode.ValueConverter; +import com.merkle.oss.magnolia.setup.task.nodebuilder.AbstractPathNodeBuilderTask; +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; + +import info.magnolia.jcr.nodebuilder.NodeOperation; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.module.InstallContext; +import info.magnolia.repository.RepositoryConstants; +import org.apache.commons.lang3.StringUtils; + +import javax.inject.Inject; + +public class SetEmptyDefaultExtensionTask extends AbstractPathNodeBuilderTask implements InstallAndUpdateTask { + private static final String TASK_NAME = "Set default Extension"; + private static final String TASK_DESCRIPTION = "Set default Extension"; + private static final String ACTIONS_PATH = "/server"; + private final NodeOperationFactory ops; + + @Inject + public SetEmptyDefaultExtensionTask(final NodeOperationFactory nodeOperationFactory) { + super(TASK_NAME, TASK_DESCRIPTION, ErrorHandling.strict, RepositoryConstants.CONFIG, ACTIONS_PATH); + ops = nodeOperationFactory; + } + + @Override + protected NodeOperation[] getNodeOperations(final InstallContext ctx) { + return new NodeOperation[]{ + ops.setProperty("defaultExtension", StringUtils.EMPTY, ValueConverter::toValue) + }; + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetupSmtpTask.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetupSmtpTask.java new file mode 100644 index 0000000..84a02fc --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/SetupSmtpTask.java @@ -0,0 +1,111 @@ +package com.merkle.oss.magnolia.setup.task.common; + +import com.merkle.oss.magnolia.powernode.NodeOperationFactory; +import com.merkle.oss.magnolia.powernode.PowerNode; +import com.merkle.oss.magnolia.powernode.PowerNodeService; +import com.merkle.oss.magnolia.powernode.ValueConverter; +import com.merkle.oss.magnolia.setup.task.nodebuilder.AbstractPathNodeBuilderTask; +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; + +import info.magnolia.init.MagnoliaConfigurationProperties; +import info.magnolia.jcr.nodebuilder.NodeOperation; +import info.magnolia.jcr.nodebuilder.Ops; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.module.InstallContext; +import info.magnolia.objectfactory.Components; +import info.magnolia.repository.RepositoryConstants; + +import javax.inject.Inject; +import java.util.Optional; + +import org.apache.commons.lang3.StringUtils; + +/** + * Configure SMTP server. + *

+ * Use the following properties in magnolia.properties: + *

+ * magnolia.smtp.security=none|ssl|tls + * magnolia.smtp.auth=null|userPassword + * magnolia.smtp.user=user + * magnolia.smtp.keystorePath=/folder/smtp # get path from the password app + * magnolia.smtp.server=mailgateway.sg.ch.namics.com + * magnolia.smtp.port=25 + *

+ * - Add to according 'ModuleVersionHandler' in a project + * - Execute as getInstallAndUpdateTask + */ +public class SetupSmtpTask extends AbstractPathNodeBuilderTask implements InstallAndUpdateTask { + private static final String TASK_NAME = "SetupSmtpTask"; + private static final String TASK_DESCRIPTION = "Set SMTP configuration from magnolia.properties"; + + private static final String MAIL_MODULE_CONFIG_PATH = "/modules/mail/config"; + + private final MagnoliaConfigurationProperties properties; + private final PowerNodeService powerNodeService; + private final NodeOperationFactory ops; + + @Inject + public SetupSmtpTask( + final PowerNodeService powerNodeService, + final NodeOperationFactory nodeOperationFactory + ) { + super(TASK_NAME, TASK_DESCRIPTION, ErrorHandling.strict, RepositoryConstants.CONFIG, MAIL_MODULE_CONFIG_PATH); + this.powerNodeService = powerNodeService; + this.ops = nodeOperationFactory; + this.properties = Components.getComponent(MagnoliaConfigurationProperties.class); + } + + @Override + protected NodeOperation[] getNodeOperations(final InstallContext ctx) { + final String security = getProperty("magnolia.smtp.security", "none"); + final String auth = getProperty("magnolia.smtp.auth", "null"); + final String server = getProperty("magnolia.smtp.server", "localhost"); + final String port = getProperty("magnolia.smtp.port", "25"); + final String user = getProperty("magnolia.smtp.user", StringUtils.EMPTY); + final String keystorePath = getProperty("magnolia.smtp.keystorePath", StringUtils.EMPTY); + + return new NodeOperation[]{ + ops.getOrAddContentNode("smtpConfiguration").then( + ops.getOrAddNode("authentication").then(ops.clearProperties().then( + getAuth(auth, user, keystorePath) + )), + ops.setProperty("server", server, ValueConverter::toValue), + ops.setProperty("port", port, ValueConverter::toValue), + ops.setProperty("security", security, ValueConverter::toValue) + ) + }; + } + + private NodeOperation[] getAuth(final String auth, final String user, final String keystorePath) { + if ("userPassword".equals(auth)) { + return getUserPasswordAuth(user, getKeystoreId(keystorePath).orElse(null)); + } + return getNullAuth(); + } + + private Optional getKeystoreId(final String keystorePath) { + return powerNodeService.getByPath("keystore", keystorePath).map(PowerNode::getIdentifier); + } + + private NodeOperation[] getUserPasswordAuth(final String user, final String passwordKeyStoreId) { + return new NodeOperation[]{ + ops.setProperty("class", "info.magnolia.module.mail.smtp.authentication.UsernamePasswordSmtpAuthentication", ValueConverter::toValue), + ops.setProperty("user", user, ValueConverter::toValue), + passwordKeyStoreId != null ? ops.setProperty("passwordKeyStoreId", passwordKeyStoreId, ValueConverter::toValue) : Ops.noop() + }; + } + + private NodeOperation[] getNullAuth() { + return new NodeOperation[]{ + ops.setProperty("class", "info.magnolia.module.mail.smtp.authentication.NullSmtpAuthentication", ValueConverter::toValue) + }; + } + + private String getProperty(final String name, final String fallback) { + if (properties.hasProperty(name)) { + return properties.getProperty(name); + } + return fallback; + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/GroupManagerUtil.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/GroupManagerUtil.java new file mode 100644 index 0000000..9102420 --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/GroupManagerUtil.java @@ -0,0 +1,44 @@ +package com.merkle.oss.magnolia.setup.task.common.security.util; + +import info.magnolia.cms.security.AccessDeniedException; +import info.magnolia.cms.security.Group; +import info.magnolia.cms.security.GroupManager; +import info.magnolia.cms.security.SecuritySupport; + +import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.Optional; +import java.util.Set; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import javax.inject.Inject; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GroupManagerUtil { + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private final Supplier groupManager; + + @Inject + public GroupManagerUtil(final SecuritySupport securitySupport) { + groupManager = securitySupport::getGroupManager; + } + + public Set getGroups(final String... groupNames) { + return Arrays.stream(groupNames) + .map(this::getGroup) + .flatMap(Optional::stream) + .collect(Collectors.toSet()); + } + + public Optional getGroup(final String groupName) { + try { + return Optional.ofNullable(groupManager.get().getGroup(groupName)); + } catch (AccessDeniedException e) { + LOG.error("Access denied to get group " + groupName, e); + return Optional.empty(); + } + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/RoleManagerUtil.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/RoleManagerUtil.java new file mode 100644 index 0000000..0d124d7 --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/RoleManagerUtil.java @@ -0,0 +1,123 @@ +package com.merkle.oss.magnolia.setup.task.common.security.util; + +import info.magnolia.cms.security.Permission; +import info.magnolia.cms.security.Role; +import info.magnolia.cms.security.RoleManager; +import info.magnolia.cms.security.SecuritySupport; +import info.magnolia.cms.security.SilentSessionOp; +import info.magnolia.cms.security.auth.ACL; +import info.magnolia.context.MgnlContext; +import info.magnolia.jcr.util.NodeTypes; +import info.magnolia.jcr.util.NodeUtil; +import info.magnolia.repository.RepositoryConstants; + +import java.util.Arrays; +import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; +import java.util.function.Supplier; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +import org.apache.commons.lang3.StringUtils; + +public class RoleManagerUtil { + private static final String WEB_ACCESS_WORKSPACE = "uri"; + private final Supplier roleManager; + + @Inject + public RoleManagerUtil(final SecuritySupport securitySupport) { + roleManager = securitySupport::getRoleManager; + } + + public Optional getRole(final String name) { + return Optional.ofNullable(roleManager.get().getRole(name)); + } + + public Role getOrCreateRole(final String name) throws Exception { + return getOrCreateRole(null, name); + } + + public Role getOrCreateRole(@Nullable final String path, final String name) throws Exception { + @Nullable final Role role = getRole(name).orElse(null); + if (role == null) { + final Node parent = getOrCreateNode(path); + return roleManager.get().createRole(parent.getPath(), name); + } + return role; + } + + private Node getOrCreateNode(@Nullable final String path) { + return MgnlContext.doInSystemContext(new SilentSessionOp<>(RepositoryConstants.USER_ROLES) { + @Override + public Node doExec(final Session session) throws RepositoryException { + if(path != null) { + return NodeUtil.createPath(session.getRootNode(), StringUtils.removeStart(path, "/"), NodeTypes.Folder.NAME); + } + return session.getRootNode(); + } + }); + } + + public void addWebAccess(final Role role, final long permission, final String... paths) { + addPermission(role, WEB_ACCESS_WORKSPACE, permission, paths); + } + + public void removeWebAccess(final Role role, final long permission, final String... paths) { + removePermission(role, WEB_ACCESS_WORKSPACE, permission, paths); + } + + public void removeAllWebAccess(final Role role) { + removePermissions(role, WEB_ACCESS_WORKSPACE, permission -> true); + } + + public void setPermission(final Role role, final String workspace, final long permission, final String... paths) { + removePermissions(role, workspace, paths); + addPermission(role, workspace, permission, paths); + } + + public void addPermission(final Role role, final String workspace, final long permission, final String... paths) { + Arrays.stream(paths).forEach(path -> + roleManager.get().addPermission(role, workspace, path, permission) + ); + } + + public void removePermission(final Role role, final String workspace, final long permission, final String... paths) { + Arrays.stream(paths).forEach(path -> + roleManager.get().removePermission(role, workspace, path, permission) + ); + } + + public void removePermissions(final Role role, final String workspace, final String... paths) { + removePermissions(role, workspace, permission -> Set.of(paths).contains(permission.getPattern().getPatternString())); + } + + public void removeAllPermissions(final Role role) { + roleManager.get().getACLs(role.getName()).entrySet().stream() + .filter(entry -> !WEB_ACCESS_WORKSPACE.equals(entry.getKey())) + .forEach(entry -> + removePermissions(role, entry.getKey(), entry.getValue(), permission -> true) + ); + } + + private void removePermissions(final Role role, final String workspace, final Predicate filter) { + Optional.ofNullable(roleManager.get().getACLs(role.getName()).get(workspace)).ifPresent(acls -> + removePermissions(role, workspace, acls, filter) + ); + } + + private void removePermissions(final Role role, final String workspace, final ACL acl, final Predicate filter) { + acl.getList().stream().filter(filter).forEach(permission -> + removePermission( + role, + workspace, + permission.getPermissions(), + permission.getPattern().getPatternString() + ) + ); + } +} diff --git a/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/UserManagerUtil.java b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/UserManagerUtil.java new file mode 100644 index 0000000..c4c561a --- /dev/null +++ b/common-task/src/main/java/com/merkle/oss/magnolia/setup/task/common/security/util/UserManagerUtil.java @@ -0,0 +1,77 @@ +package com.merkle.oss.magnolia.setup.task.common.security.util; + +import info.magnolia.cms.security.Group; +import info.magnolia.cms.security.MgnlUserManager; +import info.magnolia.cms.security.Realm; +import info.magnolia.cms.security.Role; +import info.magnolia.cms.security.SecuritySupport; +import info.magnolia.cms.security.User; +import info.magnolia.cms.security.UserManager; + +import java.util.Optional; +import java.util.Set; +import java.util.function.Supplier; + +import javax.inject.Inject; + +import org.apache.http.auth.Credentials; + +public class UserManagerUtil { + private final Supplier userManager; + + public UserManagerUtil( + final SecuritySupport securitySupport, + final Realm realm + ) { + userManager = () -> securitySupport.getUserManager(realm.getName()); + } + + public Optional getUser(final String username) { + return Optional.ofNullable(userManager.get().getUser(username)); + } + + public Optional getOrCreateUserAndSetPassword(final Credentials credentials, final Set groups, final Set roles) { + final User user = getOrCreateUserAndSetPassword(credentials.getUserPrincipal().getName(), credentials.getPassword()); + for (String group : user.getGroups()) { + if(groups.stream().map(Group::getName).noneMatch(group::equals)) { + userManager.get().removeGroup(user, group); + } + } + for (Group group : groups) { + userManager.get().addGroup(user, group.getName()); + } + for (String role : user.getRoles()) { + if(roles.stream().map(Role::getName).noneMatch(role::equals)) { + userManager.get().removeRole(user, role); + } + } + for (Role role : roles) { + userManager.get().addRole(user, role.getName()); + } + return Optional.ofNullable(userManager.get().getUser(user.getName())); + } + + private User getOrCreateUserAndSetPassword(final String name, final String password) { + return Optional + .ofNullable(userManager.get().getUser(name)) + .map(user -> userManager.get().changePassword(user, password)) + .orElseGet(() -> userManager.get().createUser(name, password)); + } + + public void enable(final User user) { + userManager.get().setProperty(user, MgnlUserManager.PROPERTY_ENABLED, "true"); + } + + public static class Factory { + private final SecuritySupport securitySupport; + + @Inject + public Factory(final SecuritySupport securitySupport) { + this.securitySupport = securitySupport; + } + + public UserManagerUtil create(final Realm realm) { + return new UserManagerUtil(securitySupport, realm); + } + } +} diff --git a/core/pom.xml b/core/pom.xml new file mode 100644 index 0000000..0503cd5 --- /dev/null +++ b/core/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + com.merkle.oss.magnolia + magnolia-setup-task + 0.0.1-SNAPSHOT + + + magnolia-setup-task-core + + + + info.magnolia + magnolia-core + + + com.google.code.findbugs + jsr305 + + + + + org.junit.jupiter + junit-jupiter + test + + + org.mockito + mockito-core + test + + + \ No newline at end of file diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/EnhancedModuleVersionHandler.java b/core/src/main/java/com/merkle/oss/magnolia/setup/EnhancedModuleVersionHandler.java new file mode 100644 index 0000000..9142bdd --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/EnhancedModuleVersionHandler.java @@ -0,0 +1,127 @@ +package com.merkle.oss.magnolia.setup; + +import info.magnolia.module.DefaultModuleVersionHandler; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.Delta; +import info.magnolia.module.delta.DeltaBuilder; +import info.magnolia.module.delta.Task; +import info.magnolia.module.model.Version; + +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import com.merkle.oss.magnolia.setup.task.type.DepdendsOnComparator; +import com.merkle.oss.magnolia.setup.task.type.InstallAndUpdateTask; +import com.merkle.oss.magnolia.setup.task.type.InstallTask; +import com.merkle.oss.magnolia.setup.task.type.LocalDevelopmentStartupTask; +import com.merkle.oss.magnolia.setup.task.type.ModuleStartupTask; +import com.merkle.oss.magnolia.setup.task.type.SnapshotStartupTask; +import com.merkle.oss.magnolia.setup.task.type.UpdateTask; +import com.merkle.oss.magnolia.setup.task.type.VersionAwareTask; + +public abstract class EnhancedModuleVersionHandler extends DefaultModuleVersionHandler { + private final Set installTasks; + private final Set updateTasks; + private final Set installAndUpdateTasks; + private final Set moduleStartupTasks; + private final Set snapshotStartupTasks; + private final Set localDevelopmentStartupTasks; + + protected EnhancedModuleVersionHandler( + final Set installTasks, + final Set updateTasks, + final Set installAndUpdateTasks, + final Set moduleStartupTasks, + final Set snapshotStartupTasks, + final Set localDevelopmentStartupTasks + ) { + this.installTasks = installTasks; + this.updateTasks = updateTasks; + this.installAndUpdateTasks = installAndUpdateTasks; + this.moduleStartupTasks = moduleStartupTasks; + this.snapshotStartupTasks = snapshotStartupTasks; + this.localDevelopmentStartupTasks = localDevelopmentStartupTasks; + } + + @Override + public List getDeltas(final InstallContext installContext, @Nullable final Version versionFrom) { + final Version forVersion = installContext.getCurrentModuleDefinition().getVersion(); + return Stream.concat( + super.getDeltas(installContext, versionFrom).stream(), + getDeltas(installContext, forVersion, versionFrom) + ).toList(); + } + + private Stream getDeltas(final InstallContext installContext, final Version forVersion, @Nullable final Version versionFrom) { + return Stream.of( + getInstallAndUpdateTasksDelta(installContext, forVersion, versionFrom), + getStartupTasksDelta(installContext, forVersion, versionFrom) + ); + } + + private Delta getInstallAndUpdateTasksDelta(final InstallContext installContext, final Version forVersion, @Nullable final Version versionFrom) { + final boolean isUpdate = forVersion.isStrictlyAfter(versionFrom); + final boolean isInstall = versionFrom == null; + + return DeltaBuilder.install(forVersion, "setup-task install and update").addTasks(Stream.of( + isInstall ? getInstallTasks(installContext, forVersion) : Stream.empty(), + isUpdate ? getInstallAndUpdateTasks(installContext, forVersion, null) : Stream.empty(), + (isInstall || isUpdate)? getUpdateTasks(installContext, forVersion, versionFrom) : Stream.empty() + ).flatMap(Function.identity()).sorted(new DepdendsOnComparator()).toList()); + } + + private Delta getStartupTasksDelta(final InstallContext installContext, final Version forVersion, @Nullable final Version versionFrom) { + return DeltaBuilder.startup(forVersion, "setup-task startup").addTasks( Stream.of( + getModuleStartupTasks(installContext, forVersion, versionFrom), + isSnapshot(forVersion) ? getSnapshotStartupTasks(installContext, forVersion, versionFrom) : Stream.empty(), + isLocalDevelopmentEnvironment() ? getLocalDevelopmentStartupTasks(installContext, forVersion, versionFrom) : Stream.empty() + ).flatMap(Function.identity()).sorted(new DepdendsOnComparator()).toList()); + } + + protected abstract boolean isLocalDevelopmentEnvironment(); + + private boolean isSnapshot(final Version version) { + return "SNAPSHOT".equalsIgnoreCase(version.getClassifier()); + } + + protected Stream getInstallTasks(final InstallContext installContext, final Version forVersion) { + return filter(installTasks, forVersion, null); + } + + protected Stream getInstallAndUpdateTasks(final InstallContext installContext, final Version forVersion, @Nullable final Version fromVersion) { + return filter(installAndUpdateTasks, forVersion, fromVersion); + } + + protected Stream getUpdateTasks(final InstallContext installContext, final Version forVersion, @Nullable final Version fromVersion) { + return filter(updateTasks, forVersion, fromVersion); + } + + protected Stream getModuleStartupTasks(final InstallContext installContext, final Version forVersion, @Nullable final Version fromVersion) { + return filter(moduleStartupTasks, forVersion, fromVersion); + } + + protected Stream getSnapshotStartupTasks(final InstallContext installContext, final Version forVersion, @Nullable final Version fromVersion) { + return Stream.of( + filter(snapshotStartupTasks, forVersion, fromVersion), + // execute all general install and update tasks on snapshot + getInstallAndUpdateTasks(installContext, forVersion, fromVersion), + getUpdateTasks(installContext, forVersion, fromVersion) + ).flatMap(Function.identity()); + } + + protected Stream getLocalDevelopmentStartupTasks(final InstallContext installContext, final Version forVersion, @Nullable final Version fromVersion) { + return filter(localDevelopmentStartupTasks, forVersion, fromVersion); + } + + protected Stream filter(final Collection tasks, final Version forVersion, @Nullable final Version fromVersion) { + return tasks + .stream() + .filter(task -> task.test(forVersion, fromVersion)) + .map(task -> task); + } +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/TaskExecutor.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/TaskExecutor.java new file mode 100644 index 0000000..8eb37ad --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/TaskExecutor.java @@ -0,0 +1,119 @@ +package com.merkle.oss.magnolia.setup.task; + +import info.magnolia.module.InstallContextImpl; +import info.magnolia.module.InstallStatus; +import info.magnolia.module.ModuleRegistry; +import info.magnolia.module.delta.Delta; +import info.magnolia.module.delta.Task; +import info.magnolia.module.delta.TaskExecutionException; +import info.magnolia.module.model.ModuleDefinition; +import info.magnolia.module.model.Version; +import info.magnolia.objectfactory.ComponentProvider; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; + +import javax.annotation.Nullable; +import javax.inject.Inject; +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +/** + * Can be used to execute tasks from magnolia groovy console: + *

{@code
+ * import com.namics.common.setup.task.TaskExecutor;
+ * import info.magnolia.objectfactory.Components;
+ *
+ * final TaskExecutor executor = Components.newInstance(TaskExecutor.class);
+ * executor.execute(com.namics.snb.web.setup.task.migration.VisionTeaserTargetNodeNameMigrationTask.class)
+ * }
+ */ +public class TaskExecutor { + private final ModuleRegistry moduleRegistry; + private final ComponentProvider componentProvider; + private final Set sessions = new HashSet<>(); + + @Inject + public TaskExecutor( + final ModuleRegistry moduleRegistry, + final ComponentProvider componentProvider + ) { + this.moduleRegistry = moduleRegistry; + this.componentProvider = componentProvider; + } + + public void execute(final Class taskClazz) throws TaskExecutionException { + execute(componentProvider.newInstance(taskClazz)); + } + + public void execute(final Task task) throws TaskExecutionException { + execute(task, getModuleDefinition(task.getClass()).orElse(null)); + } + + public void execute(final Class taskClazz, @Nullable final ModuleDefinition module) throws TaskExecutionException { + execute(componentProvider.newInstance(taskClazz), module); + } + + public void execute(final Task task, @Nullable final ModuleDefinition module) throws TaskExecutionException { + execute(task, module, true); + } + + public void execute(final Task task, @Nullable final ModuleDefinition module, final boolean saveSession) throws TaskExecutionException { + final InstallContextImpl installContext = new InstallContextImpl(moduleRegistry) { + @Override + public int getTotalTaskCount() { + return 1; + } + @Override + public InstallStatus getStatus() { + return InstallStatus.inProgress; + } + @Override + public Session getJCRSession(String workspaceName) throws RepositoryException { + final Session session = super.getJCRSession(workspaceName); + sessions.add(session); + return session; + } + }; + if(module != null) { + installContext.setCurrentModule(module); + } + task.execute(installContext); + if(saveSession) { + for (Session session : sessions) { + try { + session.save(); + } catch (Exception e) { + throw new TaskExecutionException("Failed to save session", e); + } + } + } + } + + private Optional getModuleDefinition(final Class taskClass) { + return moduleRegistry.getModuleNames().stream() + .map(moduleRegistry::getDefinition) + .filter(moduleDefinition -> contains(moduleDefinition, taskClass)) + .findFirst(); + } + + private boolean contains(final ModuleDefinition moduleDefinition, final Class taskClass) { + final InstallContextImpl installContext = new InstallContextImpl(moduleRegistry); + installContext.setCurrentModule(new ModuleDefinition( + moduleDefinition.getName(), + Version.parseVersion(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE), + moduleDefinition.getClassName(), + moduleDefinition.getVersionHandler() + )); + return moduleRegistry + .getVersionHandler(moduleDefinition.getName()) + .getDeltas(installContext, null) + .stream() + .map(Delta::getTasks) + .flatMap(Collection::stream) + .map(Object::getClass) + .anyMatch(taskClass::equals); + } +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractContentNodeBuilderTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractContentNodeBuilderTask.java new file mode 100644 index 0000000..79975c1 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractContentNodeBuilderTask.java @@ -0,0 +1,73 @@ +package com.merkle.oss.magnolia.setup.task.nodebuilder; + + +import info.magnolia.jcr.nodebuilder.*; +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.jcr.nodebuilder.task.TaskLogErrorHandler; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.TaskExecutionException; + +import java.lang.invoke.MethodHandles; + +import javax.jcr.Node; +import javax.jcr.RepositoryException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public abstract class AbstractContentNodeBuilderTask extends AbstractRepositoryTask { + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private final ErrorHandling errorHandling; + + protected AbstractContentNodeBuilderTask(String name, String description, ErrorHandling errorHandling) { + super(name, description); + this.errorHandling = errorHandling; + } + + @Override + protected void doExecute(final InstallContext ctx) throws RepositoryException, TaskExecutionException { + final Node root = getRootNode(ctx); + final NodeOperation[] operations = obtainNodeOperations(ctx); + final ErrorHandler errorHandler = newErrorHandler(ctx); + final NodeBuilder nodeBuilder = new NodeBuilder(errorHandler, root, operations); + try { + nodeBuilder.exec(); + } catch (NodeOperationException e) { + LOG.error("Could not execute node builder task", e); + throw new TaskExecutionException(e.getMessage(), e.getCause()); + } + } + + /** + * This method must be used to set NodeOperations. Use this pattern: + * return new NodeOperation[]{ addNode(...).then( ) }; + * + * @return node operations to be used in this tasks + * @param ctx install context + */ + protected abstract NodeOperation[] getNodeOperations(final InstallContext ctx); + + protected abstract Node getRootNode(final InstallContext ctx) throws RepositoryException; + + protected ErrorHandler newErrorHandler(final InstallContext ctx) { + if (errorHandling == ErrorHandling.strict) { + return new StrictErrorHandler(); + } + return new TaskLogErrorHandler(ctx); + } + + private NodeOperation[] obtainNodeOperations(final InstallContext ctx) throws TaskExecutionException { + final NodeOperation[] operations = getNodeOperations(ctx); + if (operations == null) { + if (errorHandling == ErrorHandling.logging) { + LOG.warn("No NodeOperations have been specified. Doing nothing"); + return new NodeOperation[0]; + } + throw new TaskExecutionException("Please specify NodeOperations. Can be an empty array if no operations should be done..."); + } + return operations; + } +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractPathNodeBuilderTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractPathNodeBuilderTask.java new file mode 100644 index 0000000..f5163fc --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/nodebuilder/AbstractPathNodeBuilderTask.java @@ -0,0 +1,43 @@ +package com.merkle.oss.magnolia.setup.task.nodebuilder; + +import info.magnolia.jcr.nodebuilder.task.ErrorHandling; +import info.magnolia.module.InstallContext; + +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +/** + * A task using the NodeBuilder API, applying operations on a given path. + */ +public abstract class AbstractPathNodeBuilderTask extends AbstractContentNodeBuilderTask { + private final String workspaceName; + private final String rootPath; + + protected AbstractPathNodeBuilderTask( + final String taskName, + final String description, + final ErrorHandling errorHandling, + final String workspaceName + ) { + this(taskName, description, errorHandling, workspaceName, "/"); + } + + protected AbstractPathNodeBuilderTask( + final String taskName, + final String description, + final ErrorHandling errorHandling, + final String workspaceName, + final String rootPath + ) { + super(taskName, description, errorHandling); + this.workspaceName = workspaceName; + this.rootPath = rootPath; + } + + @Override + protected Node getRootNode(final InstallContext ctx) throws RepositoryException { + final Session hm = ctx.getJCRSession(workspaceName); + return hm.getNode(rootPath); + } +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparator.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparator.java new file mode 100644 index 0000000..1860f83 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparator.java @@ -0,0 +1,41 @@ +package com.merkle.oss.magnolia.setup.task.type; + +import info.magnolia.module.delta.Task; + +import java.util.Comparator; +import java.util.Objects; + + +public class DepdendsOnComparator implements Comparator { + @Override + public int compare(final Task task1, final Task task2) { + if (!(task1 instanceof VersionAwareTask) && !(task2 instanceof VersionAwareTask)) { + return 0; + } + if (!(task1 instanceof VersionAwareTask versionAwareTask1)) { + return -1; + } + if (!(task2 instanceof VersionAwareTask versionAwareTask2)) { + return 1; + } + + if (versionAwareTask1.dependsOn().isEmpty() && versionAwareTask2.dependsOn().isEmpty()) { + return 0; + } + if (versionAwareTask1.dependsOn().isEmpty()) { + return -1; + } + if (versionAwareTask2.dependsOn().isEmpty()) { + return 1; + } + + if (Objects.equals(versionAwareTask1.dependsOn().get().getClass(), versionAwareTask2.getClass())) { + return 1; + } + if (Objects.equals(versionAwareTask2.dependsOn().get().getClass(), versionAwareTask1.getClass())) { + return -1; + } + return compare(versionAwareTask1.dependsOn().get(), versionAwareTask2.dependsOn().get()); + + } +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallAndUpdateTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallAndUpdateTask.java new file mode 100644 index 0000000..3a14d7e --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallAndUpdateTask.java @@ -0,0 +1,7 @@ +package com.merkle.oss.magnolia.setup.task.type; + +/** + * Tasks to be executed on Module install and update + */ +public interface InstallAndUpdateTask extends VersionAwareTask { +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallTask.java new file mode 100644 index 0000000..12e5e60 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/InstallTask.java @@ -0,0 +1,7 @@ +package com.merkle.oss.magnolia.setup.task.type; + +/** + * Tasks to be executed on Module Install + */ +public interface InstallTask extends VersionAwareTask { +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/LocalDevelopmentStartupTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/LocalDevelopmentStartupTask.java new file mode 100644 index 0000000..3ea5f63 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/LocalDevelopmentStartupTask.java @@ -0,0 +1,7 @@ +package com.merkle.oss.magnolia.setup.task.type; + +/** + * Tasks to be executed when the module starts up in local development. + */ +public interface LocalDevelopmentStartupTask extends VersionAwareTask { +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/ModuleStartupTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/ModuleStartupTask.java new file mode 100644 index 0000000..88f77b8 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/ModuleStartupTask.java @@ -0,0 +1,7 @@ +package com.merkle.oss.magnolia.setup.task.type; + +/** + * Tasks to be executed when the module starts up + */ +public interface ModuleStartupTask extends VersionAwareTask { +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/SnapshotStartupTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/SnapshotStartupTask.java new file mode 100644 index 0000000..32f3bb7 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/SnapshotStartupTask.java @@ -0,0 +1,7 @@ +package com.merkle.oss.magnolia.setup.task.type; + +/** + * Tasks to be executed when the module starts up with a SNAPSHOT version. + */ +public interface SnapshotStartupTask extends VersionAwareTask { +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/UpdateTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/UpdateTask.java new file mode 100644 index 0000000..44246c7 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/UpdateTask.java @@ -0,0 +1,7 @@ +package com.merkle.oss.magnolia.setup.task.type; + +/** + * Tasks to be executed on Module update + */ +public interface UpdateTask extends VersionAwareTask { +} diff --git a/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/VersionAwareTask.java b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/VersionAwareTask.java new file mode 100644 index 0000000..36410d2 --- /dev/null +++ b/core/src/main/java/com/merkle/oss/magnolia/setup/task/type/VersionAwareTask.java @@ -0,0 +1,22 @@ +package com.merkle.oss.magnolia.setup.task.type; + +import info.magnolia.module.delta.Task; +import info.magnolia.module.model.Version; + +import java.util.Optional; +import java.util.function.BiPredicate; +import java.util.function.Predicate; + +import javax.annotation.Nullable; + +public interface VersionAwareTask extends Task, BiPredicate { + + @Override + default boolean test(final Version forVersion, @Nullable final Version fromVersion) { + return true; + } + + default Optional dependsOn() { + return Optional.empty(); + } +} diff --git a/core/src/test/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparatorTest.java b/core/src/test/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparatorTest.java new file mode 100644 index 0000000..1eb78d9 --- /dev/null +++ b/core/src/test/java/com/merkle/oss/magnolia/setup/task/type/DepdendsOnComparatorTest.java @@ -0,0 +1,80 @@ +package com.merkle.oss.magnolia.setup.task.type; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.Task; +import info.magnolia.module.delta.TaskExecutionException; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; + +class DepdendsOnComparatorTest { + + @Test + void sort() { + final VersionAwareTask task2 = new Task2(); + final VersionAwareTask task1 = new Task1(); + final VersionAwareTask task3 = new Task3(); + final VersionAwareTask task4 = new Task4(); + final VersionAwareTask task5 = new Task5(); + final Task task6 = new MockTask(); + assertEquals( + List.of(task6, task1, task2, task5, task4, task3), + Stream.of(task2, task4, task5, task6, task1, task3).sorted(new DepdendsOnComparator()).toList() + ); + + assertEquals( + List.of(task6, task1, task5, task2, task3, task4), + Stream.of(task3, task6, task1, task5, task2, task4).sorted(new DepdendsOnComparator()).toList() + ); + } + + private static class Task1 extends MockVersionAwareTask {} + private static class Task2 extends MockVersionAwareTask { + @Override + public Optional dependsOn() { + return Optional.of(new Task1()); + } + } + private static class Task3 extends MockVersionAwareTask { + @Override + public Optional dependsOn() { + return Optional.of(new Task2()); + } + } + private static class Task4 extends MockVersionAwareTask { + @Override + public Optional dependsOn() { + return Optional.of(new Task2()); + } + } + private static class Task5 extends MockVersionAwareTask { + @Override + public Optional dependsOn() { + return Optional.of(new Task1()); + } + } + + private static abstract class MockVersionAwareTask extends MockTask implements VersionAwareTask {} + + private static class MockTask implements Task { + @Override + public String getName() { + return getClass().getSimpleName(); + } + @Override + public String getDescription() { + return getClass().getSimpleName()+"_description"; + } + @Override + public void execute(final InstallContext installContext) {} + @Override + public String toString() { + return getName(); + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..014ad28 --- /dev/null +++ b/pom.xml @@ -0,0 +1,221 @@ + + + 4.0.0 + + com.merkle.oss.magnolia + magnolia-setup-task + pom + 0.0.1-SNAPSHOT + + ${project.artifactId} + https://github.com/merkle-open/magnolia-setup-task + Setup task to help bootstrap magnolia + + + + MIT License + https://opensource.org/licenses/MIT + repo + + + + + + Merkle Magnolia + magnolia@merkle.com + Merkle DACH + https://merkleinc.ch + + + + + https://github.com/merkle-open/magnolia-setup-task + scm:git:git@github.com:merkle-open/magnolia-setup-task.git + scm:git:git@github.com:merkle-open/magnolia-setup-task.git + + + + common-task + core + + + + + 6.3.0 + 3.0.2 + 2.1.1 + + + 3.11.0 + 3.3.0 + 3.8.0 + 3.2.5 + 0.5.0 + 3.5.0 + + + 5.11.0 + 5.13.0 + + 17 + UTF-8 + + + + + + info.magnolia.bundle + magnolia-bundle-parent + ${magnolia.version} + pom + import + + + com.merkle.oss.magnolia + magnolia-setup-task-core + ${project.version} + + + com.namics.oss.magnolia + magnolia-powernode + ${namics.oss.powernode.version} + + + com.google.code.findbugs + jsr305 + ${jsr305.nullable.version} + + + + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${mvn.compiler.plugin.version} + + ${javaVersion} + + + + org.apache.maven.plugins + maven-source-plugin + ${mvn.source.plugin.version} + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${mvn.javadoc.version} + + false + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${mvn.surefire.plugin.version} + + + + + + + + magnolia.public.group + https://nexus.magnolia-cms.com/content/groups/public + + true + + + + magnolia.enterprise.group + https://nexus.magnolia-cms.com/content/groups/enterprise + + false + + + + + + + + central + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + deploy + + + + org.apache.maven.plugins + maven-gpg-plugin + ${mvn.gpg.plugin.version} + + + sign-artifacts + verify + + sign + + + + + --pinentry-mode + loopback + + + + + + + org.sonatype.central + central-publishing-maven-plugin + ${mvn.sonatype.publishing.plugin.version} + true + + central + true + published + + + + + + + \ No newline at end of file