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