-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KOGITO-9061] Quarkus 3: Update to Quarkus 3.0.0.Final (#2917)
* Quarkus 3: Update to Quarkus 3.0.0.Final * removed temp patch as https://github.com/kiegroup/kogito-runtimes/pull/2951 is merged * corrected standalone rewrite pipeline * [Quarkus 3 migration] Update Openrewrite recipe * [Quarkus 3 migration] Updated Openrewrite patch * corrected jenkins jobs * [Quarkus 3 migration] Update Openrewrite recipe * [Quarkus 3 migration] Updated Openrewrite patch --------- Co-authored-by: radtriste <[email protected]> Co-authored-by: Jenkins CI <[email protected]>
- Loading branch information
1 parent
b7e16b8
commit 09bbdcd
Showing
33 changed files
with
19,976 additions
and
930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# quarkus-3 environment scripts | ||
|
||
This folder contains specific script(s)/patch(es) for the Quarkus 3 migration. | ||
|
||
**Here is the command:** | ||
|
||
```bash | ||
.ci/environments/update.sh quarkus-3 | ||
``` | ||
|
||
Steps of the basic execution: | ||
|
||
- Execute `before.sh` script | ||
In the basic execution, this script will skip the rewrite commands, which is taking a lot of time to perform. | ||
If you want to perform the rewrite or update the "before.sh" patch, please see next sections. | ||
- Apply all patches from `patches` folder | ||
|
||
## Full execution | ||
|
||
**Command:** | ||
|
||
```bash | ||
.ci/environments/update.sh quarkus-3 rewrite | ||
``` | ||
|
||
Steps of the full execution: | ||
|
||
- Execute the rewrite execution | ||
- Synchronize the libraries' version with Quarkus BOM | ||
- Store the changes from previous steps into the `patches/001_before_sh.patch` file | ||
- Apply patches from `patches` folder | ||
|
||
## Patches information | ||
|
||
1. the `0001_before_sh.patch` is generated executing the `before.sh` script; it then contains all the `openrewrite` migration and the synchronization of libraries with quarkus ones (see next section) | ||
2. all other patches have been made manually | ||
3. if some other modifications are needed, they should be created as `patch`, following numerations | ||
4. if some patch does not apply anymore, it has to be recreated manually; in case of the first one, it means to execute the `before.sh` script again | ||
|
||
## How to recreate the `001_before_sh.patch` file ? | ||
|
||
The `001_before_sh.patch` file contains all changes from a rewrite execution. | ||
In case of a full execution, this file will be overriden with the new changes. | ||
|
||
You can also regenerate that file without having to run the full quarkus-3 environment migration. | ||
To do so, just run: | ||
|
||
```bash | ||
.ci/environments/quarkus-3/before.sh rewrite | ||
``` | ||
|
||
## Recipe files | ||
|
||
There are 3 recipe files: | ||
|
||
- `project-recipe.yml` is the recipe file to update in case you need a new recipe | ||
- `quarkus3-base-recipe.yml` is the base recipe setup by Quarkus team in https://github.com/quarkusio/quarkus-updates. You should not modify it ! | ||
- `quarkus3.yml` is the final recipe file and is a compute of the previous 2 files, plus some processing. | ||
See also comments in [Jbang script](jbang/CreateQuarkusDroolsMigrationRecipe.java) for more details on the generation. | ||
|
||
### How to reset the quarkus3.yaml recipe file ? | ||
|
||
The `before.sh` script should handle the reset of the `quarkus3.yml` recipe file when executed with `rewrite` command. | ||
|
||
In case you want to do manually, just run: | ||
|
||
```bash | ||
cd .ci/environments/quarkus-3 && curl -Ls https://sh.jbang.dev | bash -s - jbang/CreateQuarkusDroolsMigrationRecipe.java; cd - | ||
``` | ||
|
||
### How to update the Quarkus version ? | ||
|
||
If you are setting a new Quarkus version: | ||
|
||
1. Update `quarkus-devtools-common` version in `jbang/CreateQuarkusDroolsMigrationRecipe.java` file | ||
2. Update `QUARKUS_VERSION` in `jbang/CreateQuarkusDroolsMigrationRecipe.java` file | ||
3. Update `QUARKUS_UPDATES_BASE_URL` with the corresponding released version of https://github.com/quarkusio/quarkus-updates recipe file | ||
4. Run the jbang script to update the `quarkus3.yml` file | ||
```bash | ||
cd .ci/environments/quarkus-3 && curl -Ls https://sh.jbang.dev | bash -s - jbang/CreateQuarkusDroolsMigrationRecipe.java true; cd - | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
.ci/environments/quarkus-3/jbang/CreateQuarkusDroolsMigrationRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import java.net.URL; | ||
import java.nio.charset.Charset; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
|
||
import io.quarkus.devtools.project.BuildTool; | ||
import io.quarkus.devtools.project.update.QuarkusUpdateRecipe; | ||
import io.quarkus.devtools.project.update.QuarkusUpdateRecipeIO; | ||
import io.quarkus.devtools.project.update.operations.UpdatePropertyOperation; | ||
|
||
///usr/bin/env jbang "$0" "$@" ; exit $? | ||
// Version to be changed when needed | ||
//DEPS io.quarkus:quarkus-devtools-common:3.0.0.Final | ||
|
||
/* | ||
* This script will generate the final `quarkus3.yml` file based on: | ||
* - quarkus recipe file (see `QUARKUS_UPDATES_BASE_URL` constant) | ||
* - local project-recipe.yaml => Specific project repository rules | ||
* | ||
* We use a lot of managed dependencies, it concatenates both files but it also add some new rules: | ||
* In the Quarkus recipe, the dependencies rules are modified only for direct dependencies but not for managed dependencies. | ||
* So the script adds a new step: | ||
* - Reads all modified direct dependencies from the Quarkus recipe | ||
* - Generates one managed dependency rule for each of them | ||
*/ | ||
class CreateQuarkusProjectMigrationRecipe { | ||
|
||
static final String QUARKUS_VERSION = "3.0.0.Final"; | ||
static final String QUARKUS_UPDATES_BASE_URL = "https://raw.githubusercontent.com/quarkusio/quarkus-updates/1.0.0/recipes/src/main/resources/quarkus-updates/core/3alpha.yaml"; | ||
|
||
static final Path quarkus3DownloadedRecipePath = Paths.get("quarkus3-base-recipe.yml"); | ||
static final Path quarkus3GeneratedRecipePath = Paths.get("quarkus3.yml"); | ||
static final Path projectBaseRecipePath = Paths.get("project-recipe.yml"); | ||
|
||
public static void main(String... args) throws Exception { | ||
boolean downloadQuarkusRecipe = false; | ||
if (args.length > 0) { | ||
downloadQuarkusRecipe = Boolean.parseBoolean(args[0]); | ||
} | ||
|
||
if (downloadQuarkusRecipe) { | ||
Files.write(quarkus3DownloadedRecipePath, new URL(QUARKUS_UPDATES_BASE_URL).openStream().readAllBytes()); | ||
} | ||
|
||
if (!Files.exists(quarkus3DownloadedRecipePath)) { | ||
System.out.println("The Quarkus base recipe (" + quarkus3DownloadedRecipePath.getFileName() | ||
+ ") does not exist into the folder. Please download it manually or add the `true` parameter to the script call !"); | ||
System.exit(1); | ||
} | ||
|
||
List<Object> quarkusRecipes = QuarkusUpdateRecipeIO | ||
.readRecipesYaml(Files.readString(quarkus3DownloadedRecipePath)); | ||
QuarkusUpdateRecipe mainRecipe = new QuarkusUpdateRecipe() | ||
.buildTool(BuildTool.MAVEN) | ||
.addOperation(new UpdatePropertyOperation("version.io.quarkus", QUARKUS_VERSION)); | ||
|
||
if (Files.exists(projectBaseRecipePath)) { | ||
System.out.println("Adding Project base recipe(s)"); | ||
mainRecipe.addRecipes(QuarkusUpdateRecipeIO.readRecipesYaml(Files.readString(projectBaseRecipePath))); | ||
} else { | ||
System.out.println("No Project base recipe(s) available. Nothing done here ..."); | ||
} | ||
|
||
System.out.println("Adding Managed dependency recipe(s)"); | ||
Map<String, Object> managedDependencyMainRecipe = Map.of( | ||
"type", "specs.openrewrite.org/v1beta/recipe", | ||
"name", "org.kie.ManagedDependencies", | ||
"displayName", "Update Managed Dependencies", | ||
"description", "Update all managed dependencies based on dependency updates from Quarkus.", | ||
"recipeList", retrieveAllChangeDependencyRecipesToManagedDependency(quarkusRecipes)); | ||
mainRecipe.addRecipe(managedDependencyMainRecipe); | ||
|
||
System.out.println("Adding Quarkus base recipe(s)"); | ||
mainRecipe.addRecipes(quarkusRecipes); | ||
|
||
System.out.println("Writing main recipe"); | ||
QuarkusUpdateRecipeIO.write(quarkus3GeneratedRecipePath, mainRecipe); | ||
} | ||
|
||
private static List<Object> retrieveAllChangeDependencyRecipesToManagedDependency(List<Object> recipes) { | ||
List<Object> changeDependencyRecipeList = new ArrayList<>(); | ||
recipes.forEach(r -> { | ||
if (r instanceof Map) { | ||
List<Object> recipeList = (List<Object>) ((Map<String, Object>) r).get("recipeList"); | ||
recipeList.forEach(recipeMap -> { | ||
if (recipeMap instanceof Map) { | ||
((Map<String, Map<String, Object>>) recipeMap).forEach((recipeName, args) -> { | ||
if (recipeName.equals("org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId")) { | ||
args.remove("overrideManagedVersion"); | ||
if (!args.containsKey("newArtifactId")) { | ||
args.put("newArtifactId", args.get("oldArtifactId")); | ||
} | ||
changeDependencyRecipeList.add(Map | ||
.of("org.openrewrite.maven.ChangeManagedDependencyGroupIdAndArtifactId", args)); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
return changeDependencyRecipeList; | ||
} | ||
} |
Oops, something went wrong.