[
  {
    "path": ".all-contributorsrc",
    "content": "{\n  \"files\": [\n    \"README.md\"\n  ],\n  \"imageSize\": 100,\n  \"commit\": false,\n  \"commitType\": \"docs\",\n  \"commitConvention\": \"angular\",\n  \"contributors\": [\n    {\n      \"login\": \"tms0\",\n      \"name\": \"Valentin Day\",\n      \"avatar_url\": \"https://avatars.githubusercontent.com/u/5920998?v=4\",\n      \"profile\": \"https://colibris.xyz\",\n      \"contributions\": [\n        \"code\",\n        \"maintenance\"\n      ]\n    },\n    {\n      \"login\": \"mswiderski\",\n      \"name\": \"Maciej Swiderski\",\n      \"avatar_url\": \"https://avatars.githubusercontent.com/u/904474?v=4\",\n      \"profile\": \"https://automatiko.io\",\n      \"contributions\": [\n        \"code\"\n      ]\n    }\n  ],\n  \"contributorsPerLine\": 7,\n  \"skipCi\": true,\n  \"repoType\": \"github\",\n  \"repoHost\": \"https://github.com\",\n  \"projectName\": \"quarkus-mongock\",\n  \"projectOwner\": \"quarkiverse\"\n}\n"
  },
  {
    "path": ".github/CODEOWNERS",
    "content": "# Lines starting with '#' are comments.\n# Each line is a file pattern followed by one or more owners.\n\n# More details are here: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners\n\n# The '*' pattern is global owners.\n\n# Order is important. The last matching pattern has the most precedence.\n# The folders are ordered as follows:\n\n# In each subsection folders are ordered first by depth, then alphabetically.\n# This should make it easy to add new rules without breaking existing ones.\n\n*   @quarkiverse/quarkiverse-mongock\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "# To get started with Dependabot version updates, you'll need to specify which\n# package ecosystems to update and where the package manifests are located.\n# Please see the documentation for all configuration options:\n# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates\n\nversion: 2\nupdates:\n  - package-ecosystem: \"maven\" # See documentation for possible values\n    directory: \"/\" # Location of package manifests\n    schedule:\n      interval: \"daily\"\n"
  },
  {
    "path": ".github/project.yml",
    "content": "release:\n  current-version: \"0.6.0\"\n  next-version: \"0.7.0-SNAPSHOT\"\n\n"
  },
  {
    "path": ".github/workflows/build.yml",
    "content": "name: Build\n\non:\n  push:\n    branches:\n      - \"main\"\n    paths-ignore:\n      - '.gitignore'\n      - 'CODEOWNERS'\n      - 'LICENSE'\n      - '*.md'\n      - '*.adoc'\n      - '*.txt'\n      - '.all-contributorsrc'\n  pull_request:\n    paths-ignore:\n      - '.gitignore'\n      - 'CODEOWNERS'\n      - 'LICENSE'\n      - '*.md'\n      - '*.adoc'\n      - '*.txt'\n      - '.all-contributorsrc'\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\ndefaults:\n  run:\n    shell: bash\n\njobs:\n  build:\n    name: Build on ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n#        os: [windows-latest, macos-latest, ubuntu-latest]\n        os: [ubuntu-latest]\n    runs-on: ${{ matrix.os }}\n    steps:\n      - name: Prepare git\n        run: git config --global core.autocrlf false\n        if: startsWith(matrix.os, 'windows')\n\n      - uses: actions/checkout@v4\n      - name: Set up JDK 17\n        uses: actions/setup-java@v4\n        with:\n          distribution: temurin\n          java-version: 17\n          cache: 'maven'\n\n      - name: Build with Maven\n        run: mvn -B clean install -Dno-format\n\n      - name: Build with Maven (Native)\n        run: mvn -B install -Dnative -Dquarkus.native.container-build -Dnative.surefire.skip"
  },
  {
    "path": ".github/workflows/deploy-snapshots.yml.disabled",
    "content": "# This workflow will build and deploy a snapshot of your artifact to Sonatype Snapshots repository\nname: Deploy Snapshots\n\nconcurrency:\n  group: ${{ github.ref }}-${{ github.workflow }}\n  cancel-in-progress: true\non:\n  workflow_dispatch:\n  push:\n    branches: [ main ]\n\ndefaults:\n  run:\n    shell: bash\n\njobs:\n  deploy-snapshot:\n    runs-on: ubuntu-latest\n    name: Deploy Snapshot artifacts\n    steps:\n      - uses: actions/checkout@v4\n\n      - uses: actions/setup-java@v4\n        with:\n          distribution: 'temurin'\n          java-version: 17\n          cache: 'maven'\n          server-id: 'ossrh'\n          server-username: MAVEN_USERNAME\n          server-password: MAVEN_PASSWORD\n          gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}\n          gpg-passphrase: MAVEN_GPG_PASSPHRASE\n\n      - name: Deploy Snapshot\n        run: |\n          mvn -B clean deploy -DperformRelease=true -Drelease\n        env:\n            MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}\n            MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}\n            MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}\n"
  },
  {
    "path": ".github/workflows/pre-release.yml",
    "content": "name: Quarkiverse Pre Release\n\non:\n  pull_request:\n    paths:\n      - '.github/project.yml'\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  pre-release:\n    name: Pre-Release\n    uses: quarkiverse/.github/.github/workflows/pre-release.yml@main\n    secrets: inherit\n"
  },
  {
    "path": ".github/workflows/quarkus-snapshot.yaml",
    "content": "name: \"Quarkus ecosystem CI\"\non:\n  workflow_dispatch:\n  watch:\n    types: [started]\n\npermissions:\n  contents: read\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  build:\n    uses: quarkiverse/.github/.github/workflows/quarkus-ecosystem-ci.yml@main\n    secrets: inherit\n    with:\n      ecosystem_ci_repo_path: quarkiverse-mongock\n      java_version: 17\n"
  },
  {
    "path": ".github/workflows/release-perform.yml",
    "content": "name: Quarkiverse Perform Release\nrun-name: Perform ${{github.event.inputs.tag || github.ref_name}} Release\non:\n  push:\n    tags:\n      - '*'\n  workflow_dispatch:\n    inputs:\n      tag:\n        description: 'Tag to release'\n        required: true\n\npermissions:\n  attestations: write\n  id-token: write\n  contents: read\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  perform-release:\n    name: Perform Release\n    uses: quarkiverse/.github/.github/workflows/perform-release.yml@main\n    secrets: inherit\n    with:\n      version: ${{github.event.inputs.tag || github.ref_name}}\n"
  },
  {
    "path": ".github/workflows/release-prepare.yml",
    "content": "name: Quarkiverse Prepare Release\n\non:\n  pull_request:\n    types: [ closed ]\n    paths:\n      - '.github/project.yml'\n\nconcurrency:\n  group: ${{ github.workflow }}-${{ github.ref }}\n  cancel-in-progress: true\n\njobs:\n  prepare-release:\n    name: Prepare Release\n    if: ${{ github.event.pull_request.merged == true}}\n    uses: quarkiverse/.github/.github/workflows/prepare-release.yml@main\n    secrets: inherit\n"
  },
  {
    "path": ".gitignore",
    "content": "# Compiled class file\n*.class\n\n# Log file\n*.log\n\n# BlueJ files\n*.ctxt\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Package Files #\n*.jar\n*.war\n*.nar\n*.ear\n*.zip\n*.tar.gz\n*.rar\n\n# virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml\nhs_err_pid*\n\n# Eclipse\n.project\n.classpath\n.settings/\nbin/\n\n# IntelliJ\n.idea\n*.ipr\n*.iml\n*.iws\n\n# NetBeans\nnb-configuration.xml\n\n# Visual Studio Code\n.vscode\n.factorypath\n\n# OSX\n.DS_Store\n\n# Vim\n*.swp\n*.swo\n\n# patch\n*.orig\n*.rej\n\n# Gradle\n.gradle/\nbuild/\n\n# Maven\ntarget/\npom.xml.tag\npom.xml.releaseBackup\npom.xml.versionsBackup\nrelease.properties\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# Quarkus Mongock\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n[![Build](https://github.com/quarkiverse/quarkus-mongock/workflows/Build/badge.svg)](https://github.com/quarkiverse/quarkus-mongock/actions?query=workflow%3ABuild)\n[![Version](https://img.shields.io/maven-central/v/io.quarkiverse.mongock/quarkus-mongock?logo=apache-maven&style=flat-square)](https://central.sonatype.com/artifact/io.quarkiverse.mongock/quarkus-mongock-parent)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nThis Quarkus extension allows you to use [Mongock](https://mongock.io/) with Quarkus.\n\nWith Maven, add the following dependency to your `pom.xml` to get started:\n\n```xml\n<dependency>\n    <groupId>io.quarkiverse.mongock</groupId>\n    <artifactId>quarkus-mongock</artifactId>\n    <version>${quarkusMongockVersion}</version>\n</dependency>\n```\n\nOr with Gradle, add the following dependency to your `build.gradle`:\n\n```groovy\nimplementation \"io.quarkiverse.mongock:quarkus-mongock:${quarkusMongockVersion}\"\n```\n\nFor more information and quickstart, you can check the complete [documentation](https://quarkiverse.github.io/quarkiverse-docs/quarkus-mongock/dev/index.html).\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://colibris.xyz\"><img src=\"https://avatars.githubusercontent.com/u/5920998?v=4?s=100\" width=\"100px;\" alt=\"Valentin Day\"/><br /><sub><b>Valentin Day</b></sub></a><br /><a href=\"https://github.com/quarkiverse/quarkus-mongock/commits?author=tms0\" title=\"Code\">💻</a> <a href=\"#maintenance-tms0\" title=\"Maintenance\">🚧</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://automatiko.io\"><img src=\"https://avatars.githubusercontent.com/u/904474?v=4?s=100\" width=\"100px;\" alt=\"Maciej Swiderski\"/><br /><sub><b>Maciej Swiderski</b></sub></a><br /><a href=\"https://github.com/quarkiverse/quarkus-mongock/commits?author=mswiderski\" title=\"Code\">💻</a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!"
  },
  {
    "path": "deployment/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <parent>\n        <groupId>io.quarkiverse.mongock</groupId>\n        <artifactId>quarkus-mongock-parent</artifactId>\n        <version>0.7.0-SNAPSHOT</version>\n    </parent>\n\n    <artifactId>quarkus-mongock-deployment</artifactId>\n    <name>Quarkus Mongock - Deployment</name>\n\n    <dependencies>\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-arc-deployment</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-mongodb-client-deployment</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.quarkiverse.mongock</groupId>\n            <artifactId>quarkus-mongock</artifactId>\n            <version>${project.version}</version>\n        </dependency>\n\n        <!-- test dependencies -->\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-junit5-internal</artifactId>\n            <scope>test</scope>\n        </dependency>\n    </dependencies>\n\n    <build>\n        <plugins>\n            <plugin>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <configuration>\n                    <annotationProcessorPaths>\n                        <path>\n                            <groupId>io.quarkus</groupId>\n                            <artifactId>quarkus-extension-processor</artifactId>\n                            <version>${quarkus.version}</version>\n                        </path>\n                    </annotationProcessorPaths>\n                </configuration>\n            </plugin>\n        </plugins>\n    </build>\n</project>\n"
  },
  {
    "path": "deployment/src/main/java/io/quarkiverse/mongock/deployment/MongockEnabled.java",
    "content": "package io.quarkiverse.mongock.deployment;\n\nimport java.util.function.BooleanSupplier;\n\nimport io.quarkiverse.mongock.runtime.MongockBuildTimeConfig;\n\n/**\n * Supplier that can be used to only run build steps\n * if the Mongock extension is enabled.\n */\npublic class MongockEnabled implements BooleanSupplier {\n\n    private final MongockBuildTimeConfig config;\n\n    MongockEnabled(MongockBuildTimeConfig config) {\n        this.config = config;\n    }\n\n    @Override\n    public boolean getAsBoolean() {\n        return config.enabled();\n    }\n\n}\n"
  },
  {
    "path": "deployment/src/main/java/io/quarkiverse/mongock/deployment/MongockProcessor.java",
    "content": "package io.quarkiverse.mongock.deployment;\n\nimport static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Map;\n\nimport jakarta.inject.Singleton;\n\nimport org.jboss.jandex.ClassType;\nimport org.jboss.jandex.DotName;\n\nimport com.mongodb.client.MongoClient;\n\nimport io.mongock.api.annotations.ChangeUnit;\nimport io.quarkiverse.mongock.MongockFactory;\nimport io.quarkiverse.mongock.runtime.MongockRecorder;\nimport io.quarkus.arc.deployment.BeanContainerBuildItem;\nimport io.quarkus.arc.deployment.SyntheticBeanBuildItem;\nimport io.quarkus.deployment.annotations.*;\nimport io.quarkus.deployment.annotations.Record;\nimport io.quarkus.deployment.builditem.*;\nimport io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;\nimport io.quarkus.deployment.recording.RecorderContext;\n\n@BuildSteps(onlyIf = MongockEnabled.class)\nclass MongockProcessor {\n\n    @BuildStep\n    @Record(STATIC_INIT)\n    void build(\n            MongockRecorder recorder,\n            CombinedIndexBuildItem combinedIndex,\n            RecorderContext context,\n            BuildProducer<ReflectiveClassBuildItem> reflectiveClassProducer) {\n        List<Class<?>> migrationClasses = new ArrayList<>();\n        addMigrationClasses(combinedIndex, context, reflectiveClassProducer, migrationClasses);\n        recorder.setMigrationClasses(migrationClasses);\n    }\n\n    @BuildStep\n    @Record(ExecutionTime.RUNTIME_INIT)\n    void createBeans(MongockRecorder recorder,\n            BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer) {\n\n        SyntheticBeanBuildItem.ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem\n                .configure(MongockFactory.class)\n                .scope(Singleton.class)\n                .setRuntimeInit()\n                .unremovable()\n                .addInjectionPoint(ClassType.create(DotName.createSimple(MongoClient.class)))\n                .createWith(recorder.mongockFunction());\n\n        syntheticBeanBuildItemBuildProducer.produce(configurator.done());\n    }\n\n    @BuildStep\n    @Consume(BeanContainerBuildItem.class)\n    @Record(ExecutionTime.RUNTIME_INIT)\n    ServiceStartBuildItem startLiquibase(MongockRecorder recorder,\n            BuildProducer<InitTaskCompletedBuildItem> initializationCompleteBuildItem) {\n        recorder.doStartActions();\n        initializationCompleteBuildItem.produce(new InitTaskCompletedBuildItem(\"mongock\"));\n        return new ServiceStartBuildItem(\"mongock\");\n    }\n\n    @BuildStep\n    public InitTaskBuildItem configureInitTask(ApplicationInfoBuildItem app) {\n        return InitTaskBuildItem.create()\n                .withName(app.getName() + \"-mongock-init\")\n                .withTaskEnvVars(\n                        Map.of(\"QUARKUS_INIT_AND_EXIT\", \"true\", \"QUARKUS_MONGOCK_ENABLED\", \"true\"))\n                .withAppEnvVars(Map.of(\"QUARKUS_MONGOCK_ENABLED\", \"false\"))\n                .withSharedEnvironment(true)\n                .withSharedFilesystem(true);\n    }\n\n    private void addMigrationClasses(\n            CombinedIndexBuildItem combinedIndex,\n            RecorderContext context,\n            BuildProducer<ReflectiveClassBuildItem> reflectiveClassProducer,\n            List<Class<?>> migrationClasses) {\n\n        combinedIndex.getIndex().getAnnotations(DotName.createSimple(ChangeUnit.class.getName())).stream()\n                .map(annotationInstance -> annotationInstance.target().asClass())\n                .forEach(classInfo -> {\n                    migrationClasses.add(context.classProxy(classInfo.name().toString()));\n                    reflectiveClassProducer.produce(\n                            ReflectiveClassBuildItem\n                                    .builder(classInfo.name().toString())\n                                    .methods()\n                                    .build());\n                });\n    }\n}\n"
  },
  {
    "path": "deployment/src/test/java/io/quarkiverse/mongock/test/MongockDisabledTest.java",
    "content": "package io.quarkiverse.mongock.test;\n\nimport static org.junit.jupiter.api.Assertions.assertTrue;\n\nimport jakarta.enterprise.inject.Instance;\nimport jakarta.inject.Inject;\n\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.extension.RegisterExtension;\n\nimport io.quarkiverse.mongock.MongockFactory;\nimport io.quarkus.test.QuarkusUnitTest;\n\npublic class MongockDisabledTest {\n\n    @RegisterExtension\n    static final QuarkusUnitTest config = new QuarkusUnitTest()\n            .overrideConfigKey(\"quarkus.mongock.enabled\", \"false\")\n            .withEmptyApplication();\n\n    @Inject\n    Instance<MongockFactory> bean;\n\n    @Test\n    void testNoMongockFactoryInstance() {\n        assertTrue(bean.isUnsatisfied(), \"No mongock factory bean\");\n    }\n}\n"
  },
  {
    "path": "deployment/src/test/resources/application-migrate-at-start.properties",
    "content": "quarkus.mongodb.database=test\n\nquarkus.mongodb.client1.connection-string = mongodb://mongo2:27017/userdb\nquarkus.mongodb.client1.database=test1\n\nquarkus.mongock.migrate-at-start=true"
  },
  {
    "path": "docs/antora.yml",
    "content": "name: quarkus-mongock\ntitle: Mongock\nversion: dev\nnav:\n  - modules/ROOT/nav.adoc\n"
  },
  {
    "path": "docs/modules/ROOT/assets/images/.keepme",
    "content": ""
  },
  {
    "path": "docs/modules/ROOT/nav.adoc",
    "content": "* xref:index.adoc[Quarkus Mongock]\n"
  },
  {
    "path": "docs/modules/ROOT/pages/includes/attributes.adoc",
    "content": ":project-version: 0.6.0\n\n:examples-dir: ./../examples/"
  },
  {
    "path": "docs/modules/ROOT/pages/includes/quarkus-mongock.adoc",
    "content": "\n:summaryTableId: quarkus-mongock\n[.configuration-legend]\nicon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime\n[.configuration-reference.searchable, cols=\"80,.^10,.^10\"]\n|===\n\nh|[[quarkus-mongock_configuration]]link:#quarkus-mongock_configuration[Configuration property]\n\nh|Type\nh|Default\n\na|icon:lock[title=Fixed at build time] [[quarkus-mongock_quarkus-mongock-enabled]]`link:#quarkus-mongock_quarkus-mongock-enabled[quarkus.mongock.enabled]`\n\n\n[.description]\n--\nWhether Mongock is enabled *during the build*.\n\nIf Mongock is disabled, the Mongock beans won't be created and Mongock won't be usable.\n\nifdef::add-copy-button-to-env-var[]\nEnvironment variable: env_var_with_copy_button:+++QUARKUS_MONGOCK_ENABLED+++[]\nendif::add-copy-button-to-env-var[]\nifndef::add-copy-button-to-env-var[]\nEnvironment variable: `+++QUARKUS_MONGOCK_ENABLED+++`\nendif::add-copy-button-to-env-var[]\n--|boolean \n|`true`\n\n\na| [[quarkus-mongock_quarkus-mongock-migrate-at-start]]`link:#quarkus-mongock_quarkus-mongock-migrate-at-start[quarkus.mongock.migrate-at-start]`\n\n\n[.description]\n--\n`true` to execute Mongock automatically when the application starts, `false` otherwise.\n\nifdef::add-copy-button-to-env-var[]\nEnvironment variable: env_var_with_copy_button:+++QUARKUS_MONGOCK_MIGRATE_AT_START+++[]\nendif::add-copy-button-to-env-var[]\nifndef::add-copy-button-to-env-var[]\nEnvironment variable: `+++QUARKUS_MONGOCK_MIGRATE_AT_START+++`\nendif::add-copy-button-to-env-var[]\n--|boolean \n|`false`\n\n\na| [[quarkus-mongock_quarkus-mongock-transaction-enabled]]`link:#quarkus-mongock_quarkus-mongock-transaction-enabled[quarkus.mongock.transaction-enabled]`\n\n\n[.description]\n--\n`true` to enable transaction, `false` otherwise. If the driver does not support transaction, it will be automatically disabled.\n\nifdef::add-copy-button-to-env-var[]\nEnvironment variable: env_var_with_copy_button:+++QUARKUS_MONGOCK_TRANSACTION_ENABLED+++[]\nendif::add-copy-button-to-env-var[]\nifndef::add-copy-button-to-env-var[]\nEnvironment variable: `+++QUARKUS_MONGOCK_TRANSACTION_ENABLED+++`\nendif::add-copy-button-to-env-var[]\n--|boolean \n|`true`\n\n|==="
  },
  {
    "path": "docs/modules/ROOT/pages/index.adoc",
    "content": "= Quarkus Mongock\n\ninclude::./includes/attributes.adoc[]\n\nhttps://mongock.io/[Mongock] is a Java based migration tool as part of your application code for Distributed environments focused in managing changes for your favourite NoSQL databases.\n\n== Usage\n\nTo start using Mongock with your project, you just need to:\n\n- create https://docs.mongock.io/v5/migration/index.html[ChangeUnits] as you usually do with Mongock.\n- activate the `migrate-at-start` option to migrate automatically or inject the `MongockFactory` object and run your migration as you normally do.\n\nAdd the following dependency to your POM file:\n\n[source,xml,subs=attributes+]\n----\n<dependency>\n    <groupId>io.quarkiverse.mongock</groupId>\n    <artifactId>quarkus-mongock</artifactId>\n    <version>{project-version}</version>\n</dependency>\n----\n\nMongock support relies on the https://quarkus.io/guides/mongodb[Quarkus MongoDB client]. First, you need to add the MongoDB client configuration to the `application.properties` file :\n[source,properties]\n----\nquarkus.mongodb.connection-string=mongodb://localhost:27017\nquarkus.mongodb.database=test\n\n# Optional, if you want to migrate automatically at startup\nquarkus.mongock.migrate-at-start=true\n----\n\nAdd https://docs.mongock.io/v5/migration/index.html[ChangeUnits] to the project, in the packages of your choice :\n\n[source,java]\n----\n@ChangeUnit(id=\"myMigrationChangeUnitId\", order = \"001\", author = \"mongock_test\", systemVersion = \"1\")\npublic class MyMigrationChangeUnit {\n    private final MongoDatabase mongoDatabase;\n\n    public MyMigrationChangeUnit(MongoDatabase mongoDatabase) {\n        this.mongoDatabase = mongoDatabase;\n    }\n\n    @Execution\n    public void migrationMethod() {\n        mongoDatabase.getCollection(\"fruits\").createIndex(Indexes.ascending(\"name\"));\n    }\n\n    @RollbackExecution\n    public void rollback() {\n        mongoDatabase.getCollection(\"fruits\").dropIndex(Indexes.ascending(\"name\"));\n    }\n}\n----\n\nAnd finally, you can manually run the migration by injecting the `MongockFactory` bean :\n\n[source,java]\n----\nimport io.quarkiverse.mongock.MongockFactory;\n\npublic class MigrationService {\n\n    @Inject\n    MongockFactory mongockFactory;\n\n    public void migrate() {\n        MongockRunner mongockRunner = mongockFactory.createMongockRunner();\n        mongockRunner.execute();\n    }\n}\n----\n\n== Limitations\n\nFor now, this extension only support the https://docs.mongock.io/v5/driver/mongodb-sync/[MongoDB sync driver] with the default MongoDB client (no support for https://quarkus.io/guides/mongodb#multiple-mongodb-clients[multiple clients] yet).\n\n[[extension-configuration-reference]]\n== Extension Configuration Reference\n\ninclude::includes/quarkus-mongock.adoc[leveloffset=+1, opts=optional]\n"
  },
  {
    "path": "docs/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <parent>\n        <groupId>io.quarkiverse.mongock</groupId>\n        <artifactId>quarkus-mongock-parent</artifactId>\n        <version>0.7.0-SNAPSHOT</version>\n        <relativePath>../pom.xml</relativePath>\n    </parent>\n\n    <artifactId>quarkus-mongock-docs</artifactId>\n    <name>Quarkus Mongock - Documentation</name>\n\n    <dependencies>\n        <!-- Make sure the doc is built after the other artifacts -->\n        <dependency>\n            <groupId>io.quarkiverse.mongock</groupId>\n            <artifactId>quarkus-mongock-integration-tests</artifactId>\n            <version>${project.version}</version>\n            <optional>true</optional>\n        </dependency>\n    </dependencies>\n\n    <build>\n        <sourceDirectory>modules/ROOT/examples</sourceDirectory>\n        <plugins>\n            <plugin>\n                <groupId>io.quarkus</groupId>\n                <artifactId>quarkus-maven-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <goals>\n                            <goal>build</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <groupId>it.ozimov</groupId>\n                <artifactId>yaml-properties-maven-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <phase>initialize</phase>\n                        <goals>\n                            <goal>read-project-properties</goal>\n                        </goals>\n                        <configuration>\n                            <files>\n                                <file>${project.basedir}/../.github/project.yml</file>\n                            </files>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <artifactId>maven-resources-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <id>copy-resources</id>\n                        <phase>generate-resources</phase>\n                        <goals>\n                            <goal>copy-resources</goal>\n                        </goals>\n                        <configuration>\n                            <outputDirectory>${project.basedir}/modules/ROOT/pages/includes/</outputDirectory>\n                            <resources>\n                                <resource>\n                                    <directory>${project.basedir}/../target/asciidoc/generated/config/</directory>\n                                    <include>quarkus-mongock.adoc</include>\n                                    <filtering>false</filtering>\n                                </resource>\n                                <resource>\n                                    <directory>${project.basedir}/templates/includes</directory>\n                                    <include>attributes.adoc</include>\n                                    <filtering>true</filtering>\n                                </resource>\n                            </resources>\n                        </configuration>\n                    </execution>\n                    <execution>\n                        <id>copy-images</id>\n                        <phase>prepare-package</phase>\n                        <goals>\n                            <goal>copy-resources</goal>\n                        </goals>\n                        <configuration>\n                            <outputDirectory>${project.build.directory}/generated-docs/_images/</outputDirectory>\n                            <resources>\n                                <resource>\n                                    <directory>${project.basedir}/modules/ROOT/assets/images/</directory>\n                                    <filtering>false</filtering>\n                                </resource>\n                            </resources>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <groupId>org.asciidoctor</groupId>\n                <artifactId>asciidoctor-maven-plugin</artifactId>\n            </plugin>\n        </plugins>\n    </build>\n\n</project>\n"
  },
  {
    "path": "docs/templates/includes/attributes.adoc",
    "content": ":project-version: ${release.current-version}\n\n:examples-dir: ./../examples/"
  },
  {
    "path": "integration-tests/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <parent>\n        <groupId>io.quarkiverse.mongock</groupId>\n        <artifactId>quarkus-mongock-parent</artifactId>\n        <version>0.7.0-SNAPSHOT</version>\n    </parent>\n\n    <artifactId>quarkus-mongock-integration-tests</artifactId>\n    <name>Quarkus - Mongock - Integration Tests</name>\n\n    <properties>\n        <skipITs>true</skipITs>\n    </properties>\n\n    <dependencies>\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-mongodb-panache</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-rest-jackson</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.quarkiverse.mongock</groupId>\n            <artifactId>quarkus-mongock</artifactId>\n            <version>${project.version}</version>\n        </dependency>\n\n        <!-- test dependencies -->\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-junit5</artifactId>\n            <scope>test</scope>\n        </dependency>\n        <dependency>\n            <groupId>io.rest-assured</groupId>\n            <artifactId>rest-assured</artifactId>\n            <scope>test</scope>\n        </dependency>\n    </dependencies>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>io.quarkus</groupId>\n                <artifactId>quarkus-maven-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <goals>\n                            <goal>build</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <artifactId>maven-failsafe-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <goals>\n                            <goal>integration-test</goal>\n                            <goal>verify</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n\n    <profiles>\n        <profile>\n            <id>native-image</id>\n            <activation>\n                <property>\n                    <name>native</name>\n                </property>\n            </activation>\n            <build>\n                <plugins>\n                    <plugin>\n                        <artifactId>maven-surefire-plugin</artifactId>\n                        <configuration>\n                            <skipTests>${native.surefire.skip}</skipTests>\n                        </configuration>\n                    </plugin>\n                </plugins>\n            </build>\n            <properties>\n                <skipITs>false</skipITs>\n                <quarkus.native.enabled>true</quarkus.native.enabled>\n            </properties>\n        </profile>\n    </profiles>\n\n</project>\n"
  },
  {
    "path": "integration-tests/src/main/java/io/quarkiverse/mongock/it/Fruit.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport io.quarkus.mongodb.panache.PanacheMongoEntity;\nimport io.quarkus.mongodb.panache.common.MongoEntity;\n\n@MongoEntity(collection = \"fruits\")\npublic class Fruit extends PanacheMongoEntity {\n    public String name;\n\n    public Fruit() {\n    }\n\n    public Fruit(String name) {\n        this.name = name;\n    }\n}\n"
  },
  {
    "path": "integration-tests/src/main/java/io/quarkiverse/mongock/it/FruitMigrationChangeUnit.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport io.mongock.api.annotations.ChangeUnit;\nimport io.mongock.api.annotations.Execution;\nimport io.mongock.api.annotations.RollbackExecution;\n\n@ChangeUnit(id = \"fruitMigrationChangeUnit\", order = \"001\", author = \"mongock_test\", systemVersion = \"1\")\npublic class FruitMigrationChangeUnit {\n    @Execution\n    public void migrationMethod() {\n        Fruit.persist(new Fruit(\"apple\"));\n    }\n\n    @RollbackExecution\n    public void rollback() {\n        Fruit.deleteAll();\n    }\n}"
  },
  {
    "path": "integration-tests/src/main/java/io/quarkiverse/mongock/it/FruitResource.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport java.util.List;\n\nimport jakarta.inject.Inject;\nimport jakarta.ws.rs.GET;\nimport jakarta.ws.rs.POST;\nimport jakarta.ws.rs.Path;\nimport jakarta.ws.rs.Produces;\nimport jakarta.ws.rs.core.MediaType;\n\nimport io.mongock.runner.core.executor.MongockRunner;\nimport io.quarkiverse.mongock.MongockFactory;\n\n@Path(\"/\")\n@Produces(MediaType.APPLICATION_JSON)\npublic class FruitResource {\n\n    @Inject\n    MongockFactory mongockFactory;\n\n    @GET\n    @Path(\"fruits\")\n    public List<Fruit> list() {\n        return Fruit.listAll();\n    }\n\n    @POST\n    @Path(\"migrate\")\n    public void migrate() {\n        MongockRunner mongockRunner = mongockFactory.createMongockRunner();\n        mongockRunner.execute();\n    }\n}\n"
  },
  {
    "path": "integration-tests/src/main/resources/application.properties",
    "content": "quarkus.mongodb.database=test"
  },
  {
    "path": "integration-tests/src/test/java/io/quarkiverse/mongock/it/MongockIT.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport io.quarkus.test.junit.QuarkusIntegrationTest;\n\n@QuarkusIntegrationTest\npublic class MongockIT extends MongockTest {\n}\n"
  },
  {
    "path": "integration-tests/src/test/java/io/quarkiverse/mongock/it/MongockMigrateAtStartIT.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport io.quarkus.test.junit.QuarkusIntegrationTest;\n\n@QuarkusIntegrationTest\npublic class MongockMigrateAtStartIT extends MongockMigrateAtStartTest {\n}\n"
  },
  {
    "path": "integration-tests/src/test/java/io/quarkiverse/mongock/it/MongockMigrateAtStartTest.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport java.util.Map;\n\nimport org.junit.jupiter.api.Assertions;\nimport org.junit.jupiter.api.Test;\n\nimport io.quarkus.test.junit.QuarkusTest;\nimport io.quarkus.test.junit.QuarkusTestProfile;\nimport io.quarkus.test.junit.TestProfile;\n\n@TestProfile(value = MongockMigrateAtStartTest.MigrateAtStartTestProfile.class)\n@QuarkusTest\npublic class MongockMigrateAtStartTest {\n\n    @Test\n    public void testMigrateAtStart() {\n        Assertions.assertEquals(1, MongockTestUtils.listFruits().size());\n    }\n\n    public static class MigrateAtStartTestProfile implements QuarkusTestProfile {\n\n        @Override\n        public Map<String, String> getConfigOverrides() {\n            return Map.of(\"quarkus.mongock.migrate-at-start\", \"true\");\n        }\n    }\n}\n"
  },
  {
    "path": "integration-tests/src/test/java/io/quarkiverse/mongock/it/MongockTest.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport static io.restassured.RestAssured.post;\n\nimport org.junit.jupiter.api.Assertions;\nimport org.junit.jupiter.api.Test;\n\nimport io.quarkus.test.junit.QuarkusTest;\n\n@QuarkusTest\npublic class MongockTest {\n\n    @Test\n    public void testMigration() {\n        Assertions.assertEquals(0, MongockTestUtils.listFruits().size());\n        post(\"/migrate\");\n        Assertions.assertEquals(1, MongockTestUtils.listFruits().size());\n    }\n}\n"
  },
  {
    "path": "integration-tests/src/test/java/io/quarkiverse/mongock/it/MongockTestUtils.java",
    "content": "package io.quarkiverse.mongock.it;\n\nimport static io.restassured.RestAssured.get;\n\nimport java.util.List;\n\nimport io.restassured.common.mapper.TypeRef;\n\npublic class MongockTestUtils {\n\n    static List<Fruit> listFruits() {\n        return get(\"/fruits\").as(new TypeRef<>() {\n        });\n    }\n}\n"
  },
  {
    "path": "pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <parent>\n        <groupId>io.quarkiverse</groupId>\n        <artifactId>quarkiverse-parent</artifactId>\n        <version>19</version>\n    </parent>\n\n    <groupId>io.quarkiverse.mongock</groupId>\n    <artifactId>quarkus-mongock-parent</artifactId>\n    <name>Quarkus Mongock - Parent</name>\n    <packaging>pom</packaging>\n    <version>0.7.0-SNAPSHOT</version>\n\n    <modules>\n        <module>deployment</module>\n        <module>runtime</module>\n    </modules>\n\n    <scm>\n        <connection>scm:git:git@github.com:quarkiverse/quarkus-mongock.git</connection>\n        <developerConnection>scm:git:git@github.com:quarkiverse/quarkus-mongock.git</developerConnection>\n        <url>https://github.com/quarkiverse/quarkus-mongock</url>\n      <tag>HEAD</tag>\n  </scm>\n\n    <properties>\n        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n        <maven.compiler.release>17</maven.compiler.release>\n        <quarkus.version>3.19.3</quarkus.version>\n        <mongock.version>5.5.0</mongock.version>\n    </properties>\n\n    <dependencyManagement>\n        <dependencies>\n            <dependency>\n                <groupId>io.quarkus</groupId>\n                <artifactId>quarkus-bom</artifactId>\n                <version>${quarkus.version}</version>\n                <type>pom</type>\n                <scope>import</scope>\n            </dependency>\n            <dependency>\n                <groupId>io.mongock</groupId>\n                <artifactId>mongock-bom</artifactId>\n                <version>${mongock.version}</version>\n                <type>pom</type>\n                <scope>import</scope>\n            </dependency>\n        </dependencies>\n    </dependencyManagement>\n\n    <build>\n        <pluginManagement>\n            <plugins>\n                <plugin>\n                    <groupId>io.quarkus</groupId>\n                    <artifactId>quarkus-maven-plugin</artifactId>\n                    <version>${quarkus.version}</version>\n                </plugin>\n            </plugins>\n        </pluginManagement>\n    </build>\n\n    <profiles>\n        <profile>\n            <id>docs</id>\n            <activation>\n                <property>\n                    <name>performRelease</name>\n                    <value>!true</value>\n                </property>\n            </activation>\n            <modules>\n                <module>docs</module>\n            </modules>\n        </profile>\n        <profile>\n            <id>it</id>\n            <activation>\n                <property>\n                    <name>performRelease</name>\n                    <value>!true</value>\n                </property>\n            </activation>\n            <modules>\n                <module>integration-tests</module>\n            </modules>\n        </profile>\n    </profiles>\n</project>\n"
  },
  {
    "path": "runtime/pom.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n    <modelVersion>4.0.0</modelVersion>\n\n    <parent>\n        <groupId>io.quarkiverse.mongock</groupId>\n        <artifactId>quarkus-mongock-parent</artifactId>\n        <version>0.7.0-SNAPSHOT</version>\n    </parent>\n\n    <artifactId>quarkus-mongock</artifactId>\n    <name>Quarkus Mongock - Runtime</name>\n\n    <dependencies>\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-arc</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.quarkus</groupId>\n            <artifactId>quarkus-mongodb-client</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.mongock</groupId>\n            <artifactId>mongock-standalone</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>io.mongock</groupId>\n            <artifactId>mongodb-sync-v4-driver</artifactId>\n        </dependency>\n        <dependency>\n            <groupId>org.graalvm.sdk</groupId>\n            <artifactId>graal-sdk</artifactId>\n            <scope>provided</scope>\n        </dependency>\n    </dependencies>\n\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>io.quarkus</groupId>\n                <artifactId>quarkus-extension-maven-plugin</artifactId>\n                <version>${quarkus.version}</version>\n                <executions>\n                    <execution>\n                        <phase>compile</phase>\n                        <goals>\n                            <goal>extension-descriptor</goal>\n                        </goals>\n                        <configuration>\n                            <deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>\n                        </configuration>\n                    </execution>\n                </executions>\n            </plugin>\n            <plugin>\n                <artifactId>maven-compiler-plugin</artifactId>\n                <configuration>\n                    <annotationProcessorPaths>\n                        <path>\n                            <groupId>io.quarkus</groupId>\n                            <artifactId>quarkus-extension-processor</artifactId>\n                            <version>${quarkus.version}</version>\n                        </path>\n                    </annotationProcessorPaths>\n                </configuration>\n            </plugin>\n        </plugins>\n    </build>\n</project>\n"
  },
  {
    "path": "runtime/src/main/java/io/quarkiverse/mongock/MongockFactory.java",
    "content": "package io.quarkiverse.mongock;\n\nimport java.util.List;\n\nimport org.eclipse.microprofile.config.ConfigProvider;\n\nimport com.mongodb.client.MongoClient;\n\nimport io.mongock.driver.mongodb.sync.v4.driver.MongoSync4Driver;\nimport io.mongock.runner.core.executor.MongockRunner;\nimport io.mongock.runner.standalone.MongockStandalone;\nimport io.quarkiverse.mongock.runtime.MongockRuntimeConfig;\n\npublic class MongockFactory {\n\n    private final MongoClient mongoClient;\n\n    private final MongockRuntimeConfig mongockRuntimeConfig;\n    private final List<Class<?>> migrationClasses;\n\n    public MongockFactory(\n            MongoClient mongoClient,\n            MongockRuntimeConfig mongockRuntimeConfig,\n            List<Class<?>> migrationClasses) {\n\n        this.mongoClient = mongoClient;\n        this.mongockRuntimeConfig = mongockRuntimeConfig;\n        this.migrationClasses = migrationClasses;\n    }\n\n    public MongockRunner createMongockRunner() {\n\n        String databaseName = ConfigProvider.getConfig().getOptionalValue(\"quarkus.mongodb.database\", String.class)\n                .orElseThrow(() -> new IllegalStateException(\"The database property was not configured for \" +\n                        \"the default Mongo Client (via 'quarkus.mongodb.database')\"));\n\n        return MongockStandalone.builder()\n                .setDriver(\n                        MongoSync4Driver.withDefaultLock(mongoClient, databaseName))\n                .addMigrationClasses(migrationClasses)\n                .setTransactional(mongockRuntimeConfig.transactionEnabled())\n                // See https://github.com/mongock/mongock/issues/661\n                .setLockGuardEnabled(false)\n                .buildRunner();\n    }\n\n}\n"
  },
  {
    "path": "runtime/src/main/java/io/quarkiverse/mongock/runtime/MongockBuildTimeConfig.java",
    "content": "package io.quarkiverse.mongock.runtime;\n\nimport io.quarkus.runtime.annotations.ConfigPhase;\nimport io.quarkus.runtime.annotations.ConfigRoot;\nimport io.smallrye.config.ConfigMapping;\nimport io.smallrye.config.WithDefault;\n\n@ConfigMapping(prefix = \"quarkus.mongock\")\n@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)\npublic interface MongockBuildTimeConfig {\n\n    /**\n     * Whether Mongock is enabled *during the build*.\n     *\n     * If Mongock is disabled, the Mongock beans won't be created and Mongock won't be usable.\n     *\n     * @asciidoclet\n     */\n    @WithDefault(\"true\")\n    boolean enabled();\n}\n"
  },
  {
    "path": "runtime/src/main/java/io/quarkiverse/mongock/runtime/MongockRecorder.java",
    "content": "package io.quarkiverse.mongock.runtime;\n\nimport java.util.List;\nimport java.util.function.Function;\n\nimport org.jboss.logging.Logger;\n\nimport com.mongodb.client.MongoClient;\n\nimport io.mongock.runner.core.executor.MongockRunner;\nimport io.quarkiverse.mongock.MongockFactory;\nimport io.quarkus.arc.Arc;\nimport io.quarkus.arc.InstanceHandle;\nimport io.quarkus.arc.SyntheticCreationalContext;\nimport io.quarkus.runtime.RuntimeValue;\nimport io.quarkus.runtime.annotations.Recorder;\n\n@Recorder\npublic class MongockRecorder {\n\n    private static final Logger log = Logger.getLogger(MongockRecorder.class);\n\n    private final RuntimeValue<MongockRuntimeConfig> config;\n\n    public static volatile List<Class<?>> migrationClasses;\n\n    public MongockRecorder(RuntimeValue<MongockRuntimeConfig> config) {\n        this.config = config;\n    }\n\n    public void setMigrationClasses(List<Class<?>> migrationClasses) {\n        log.debugv(\"Setting the following migration classes: {0}\", migrationClasses);\n        MongockRecorder.migrationClasses = migrationClasses;\n    }\n\n    public Function<SyntheticCreationalContext<MongockFactory>, MongockFactory> mongockFunction() {\n        return (SyntheticCreationalContext<MongockFactory> context) -> {\n            MongoClient mongoClient = context.getInjectedReference(MongoClient.class);\n            return new MongockFactory(mongoClient, config.getValue(), migrationClasses);\n        };\n    }\n\n    public void doStartActions() {\n        InstanceHandle<MongockFactory> mongockFactoryInstanceHandle = Arc.container().instance(MongockFactory.class);\n\n        if (!mongockFactoryInstanceHandle.isAvailable()) {\n            return;\n        }\n\n        MongockFactory mongockFactory = mongockFactoryInstanceHandle.get();\n        MongockRunner mongockRunner = mongockFactory.createMongockRunner();\n\n        if (config.getValue().migrateAtStart()) {\n            mongockRunner.execute();\n        }\n    }\n\n}\n"
  },
  {
    "path": "runtime/src/main/java/io/quarkiverse/mongock/runtime/MongockRuntimeConfig.java",
    "content": "package io.quarkiverse.mongock.runtime;\n\nimport io.quarkus.runtime.annotations.ConfigPhase;\nimport io.quarkus.runtime.annotations.ConfigRoot;\nimport io.smallrye.config.ConfigMapping;\nimport io.smallrye.config.WithDefault;\n\n@ConfigMapping(prefix = \"quarkus.mongock\")\n@ConfigRoot(phase = ConfigPhase.RUN_TIME)\npublic interface MongockRuntimeConfig {\n\n    /**\n     * {@code true} to execute Mongock automatically when the application starts, {@code false} otherwise.\n     */\n    @WithDefault(\"false\")\n    boolean migrateAtStart();\n\n    /**\n     * {@code true} to enable transaction, {@code false} otherwise. If the driver does not support transaction, it will be\n     * automatically disabled.\n     */\n    @WithDefault(\"true\")\n    boolean transactionEnabled();\n\n}\n"
  },
  {
    "path": "runtime/src/main/java/io/quarkiverse/mongock/runtime/graal/OrgReflectionsSubstitutions.java",
    "content": "package io.quarkiverse.mongock.runtime.graal;\n\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.function.BooleanSupplier;\n\nimport org.reflections.Reflections;\n\nimport com.oracle.svm.core.annotate.Substitute;\nimport com.oracle.svm.core.annotate.TargetClass;\n\n/**\n * Get rid of JBoss VFS if it is not present in the classpath.\n */\n@TargetClass(value = Reflections.class, onlyWith = OrgReflectionsSubstitutions.IsJBossVFSAbsent.class)\npublic final class OrgReflectionsSubstitutions {\n\n    // Only necessary for package scanning, not used with Quarkus\n    @Substitute\n    private Map<String, Map<String, Set<String>>> scan() {\n        return new HashMap<>();\n    }\n\n    static final class IsJBossVFSAbsent implements BooleanSupplier {\n\n        @Override\n        public boolean getAsBoolean() {\n            try {\n                Class.forName(\"org.jboss.vfs.VFS\");\n                return false;\n            } catch (ClassNotFoundException e) {\n                return true;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "runtime/src/main/resources/META-INF/quarkus-extension.yaml",
    "content": "name: \"Quarkus Mongock\"\ndescription: \"This Quarkus extension allows you to use Mongock with Quarkus.\"\nmetadata:\n  short-name: \"mongock\"\n  keywords:\n    - \"mongock\"\n    - \"mongodb\"\n  categories:\n    - \"data\"\n  status: \"preview\"\n  guide: \"https://docs.quarkiverse.io/quarkus-mongock/dev/index.html\"\nconfig:\n  - \"quarkus.mongock.\""
  }
]