Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(recipes): Add the FixJellyIssues recipe. #355

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

gounthar
Copy link
Collaborator

@gounthar gounthar commented Oct 23, 2024

Adds XML declaration to Jelly files and create index.jelly if it doesn't exist thanks to the addjellyxmldeclaration and createindexjelly recipes.

This is an attempt to solve #349.

Walkthrough

The changes introduce a new recipe in the recipes.yml file for the Jenkins plugin modernizer, specifically io.jenkins.tools.pluginmodernizer.FixJellyIssues. This recipe ensures that the XML declaration <?jelly escape-by-default='true'?> is included in all .jelly files and creates an index.jelly file if it is absent. The recipe is categorized under 'chore' and includes references to two existing recipes for handling these tasks.

Changes

File Path Change Summary
plugin-modernizer-core/src/main/resources/META-INF/rewrite/recipes.yml Added a new recipe io.jenkins.tools.pluginmodernizer.FixJellyIssues to enforce XML declarations in .jelly files and create index.jelly files.

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

gounthar and others added 30 commits October 18, 2024 20:25
Fixes #51

Add a new recipe to ensure the XML declaration is present in all Jelly files.

* Add `AddJellyXmlDeclaration` recipe to `plugin-modernizer-core/src/main/resources/META-INF/rewrite/recipes.yml`.
* Create `AddJellyXmlDeclaration` class in `plugin-modernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/recipe/AddJellyXmlDeclaration.java`.
* Implement logic to add XML declaration to existing `.jelly` files using `PlainTextVisitor`.
* Create `AddJellyXmlDeclarationTest` class in `plugin-modernizer-core/src/test/java/io/jenkins/tools/pluginmodernizer/core/recipe/AddJellyXmlDeclarationTest.java`.
* Write unit tests to verify the `AddJellyXmlDeclaration` recipe.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/gounthar/plugin-modernizer-tool/issues/51?shareId=XXXX-XXXX-XXXX-XXXX).
Bumps [s4u/setup-maven-action](https://github.com/s4u/setup-maven-action) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/s4u/setup-maven-action/releases)
- [Commits](s4u/setup-maven-action@v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: s4u/setup-maven-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from d31acd50653ded455ab8972a1eb9a656b0aef94a to 0de3687b53cd804b63dd87819f7bda043569ce4a.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@d31acd5...0de3687)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.openrewrite.maven:rewrite-maven-plugin](https://github.com/openrewrite/rewrite-maven-plugin) from 5.43.1 to 5.43.4.
- [Release notes](https://github.com/openrewrite/rewrite-maven-plugin/releases)
- [Commits](openrewrite/rewrite-maven-plugin@v5.43.1...v5.43.4)

---
updated-dependencies:
- dependency-name: org.openrewrite.maven:rewrite-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps `bouncycastle.version` from 1.78.1 to 1.79.

Updates `org.bouncycastle:bcpkix-jdk18on` from 1.78.1 to 1.79
- [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html)
- [Commits](https://github.com/bcgit/bc-java/commits)

Updates `org.bouncycastle:bcprov-jdk18on` from 1.78.1 to 1.79
- [Changelog](https://github.com/bcgit/bc-java/blob/main/docs/releasenotes.html)
- [Commits](https://github.com/bcgit/bc-java/commits)

---
updated-dependencies:
- dependency-name: org.bouncycastle:bcpkix-jdk18on
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.bouncycastle:bcprov-jdk18on
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps `byte-buddy.version` from 1.15.7 to 1.15.9.

Updates `net.bytebuddy:byte-buddy` from 1.15.7 to 1.15.9
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.15.7...byte-buddy-1.15.9)

Updates `net.bytebuddy:byte-buddy-agent` from 1.15.7 to 1.15.9
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.15.7...byte-buddy-1.15.9)

---
updated-dependencies:
- dependency-name: net.bytebuddy:byte-buddy
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: net.bytebuddy:byte-buddy-agent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [com.fasterxml.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 2.18.0 to 2.18.1.
- [Commits](FasterXML/jackson-bom@jackson-bom-2.18.0...jackson-bom-2.18.1)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson:jackson-bom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.checkerframework:checker-qual](https://github.com/typetools/checker-framework) from 3.48.1 to 3.48.2.
- [Release notes](https://github.com/typetools/checker-framework/releases)
- [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md)
- [Commits](typetools/checker-framework@checker-framework-3.48.1...checker-framework-3.48.2)

---
updated-dependencies:
- dependency-name: org.checkerframework:checker-qual
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.jenkins-ci:jenkins](https://github.com/jenkinsci/pom) from 1.125 to 1.126.
- [Release notes](https://github.com/jenkinsci/pom/releases)
- [Changelog](https://github.com/jenkinsci/pom/blob/master/CHANGELOG-old.md)
- [Commits](jenkinsci/pom@jenkins-1.125...jenkins-1.126)

---
updated-dependencies:
- dependency-name: org.jenkins-ci:jenkins
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps `byte-buddy.version` from 1.15.9 to 1.15.10.

Updates `net.bytebuddy:byte-buddy` from 1.15.9 to 1.15.10
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.15.9...byte-buddy-1.15.10)

Updates `net.bytebuddy:byte-buddy-agent` from 1.15.9 to 1.15.10
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.15.9...byte-buddy-1.15.10)

---
updated-dependencies:
- dependency-name: net.bytebuddy:byte-buddy
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: net.bytebuddy:byte-buddy-agent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.openrewrite.maven:rewrite-maven-plugin](https://github.com/openrewrite/rewrite-maven-plugin) from 5.43.4 to 5.44.0.
- [Release notes](https://github.com/openrewrite/rewrite-maven-plugin/releases)
- [Commits](openrewrite/rewrite-maven-plugin@v5.43.4...v5.44.0)

---
updated-dependencies:
- dependency-name: org.openrewrite.maven:rewrite-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps `jte.version` from 3.1.13 to 3.1.14.

Updates `gg.jte:jte` from 3.1.13 to 3.1.14
- [Release notes](https://github.com/casid/jte/releases)
- [Commits](casid/jte@3.1.13...3.1.14)

Updates `gg.jte:jte-maven-plugin` from 3.1.13 to 3.1.14
- [Release notes](https://github.com/casid/jte/releases)
- [Commits](casid/jte@3.1.13...3.1.14)

---
updated-dependencies:
- dependency-name: gg.jte:jte
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: gg.jte:jte-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [updatecli/updatecli-action](https://github.com/updatecli/updatecli-action) from 2.68.0 to 2.70.0.
- [Release notes](https://github.com/updatecli/updatecli-action/releases)
- [Commits](updatecli/updatecli-action@v2.68.0...v2.70.0)

---
updated-dependencies:
- dependency-name: updatecli/updatecli-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 0de3687b53cd804b63dd87819f7bda043569ce4a to bd26c982ee2b6c0f9744591c74c527e8a669f72f.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@0de3687...bd26c98)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [io.micrometer:micrometer-bom](https://github.com/micrometer-metrics/micrometer) from 1.13.6 to 1.14.0.
- [Release notes](https://github.com/micrometer-metrics/micrometer/releases)
- [Commits](micrometer-metrics/micrometer@v1.13.6...v1.14.0)

---
updated-dependencies:
- dependency-name: io.micrometer:micrometer-bom
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
dependabot bot and others added 7 commits November 14, 2024 14:25
Bumps [org.openrewrite.recipe:rewrite-jenkins](https://github.com/openrewrite/rewrite-jenkins) from 0.15.0 to 0.17.0.
- [Release notes](https://github.com/openrewrite/rewrite-jenkins/releases)
- [Commits](openrewrite/rewrite-jenkins@v0.15.0...v0.17.0)

---
updated-dependencies:
- dependency-name: org.openrewrite.recipe:rewrite-jenkins
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [org.openrewrite.maven:rewrite-maven-plugin](https://github.com/openrewrite/rewrite-maven-plugin) from 5.44.0 to 5.45.0.
- [Release notes](https://github.com/openrewrite/rewrite-maven-plugin/releases)
- [Commits](openrewrite/rewrite-maven-plugin@v5.44.0...v5.45.0)

---
updated-dependencies:
- dependency-name: org.openrewrite.maven:rewrite-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…dernizer/core/recipe/AddJellyXmlDeclaration.java
…dernizer/core/recipe/AddJellyXmlDeclarationTest.java
@gounthar gounthar changed the title feat(recipes): Add jelly xml declaration feat(recipes): Add XML declaration to Jelly files and create index.jelly if it doesn't exist Nov 15, 2024
@gounthar gounthar changed the title feat(recipes): Add XML declaration to Jelly files and create index.jelly if it doesn't exist feat(recipes): Add the FixJellyIssues recipe. Nov 15, 2024
@gounthar
Copy link
Collaborator Author

The recipe supposed to fix the missing XML declaration has been released, but it looks like it's doing nothing. 😢

java -jar plugin-modernizer-cli/target/jenkins-plugin-modernizer-999999-SNAPSHOT.jar --plugins BlazeMeterJenkinsPlugin --recipes FixJellyIssues --skip-pull-request --skip-build
Starting Plugin Modernizer
Forking plugin BlazeMeterJenkinsPlugin locally from repo blazemeter-plugin...
Synced the forked repository for plugin BlazeMeterJenkinsPlugin
Fetching plugin code locally BlazeMeterJenkinsPlugin...
Fetched repository from https://github.com/gounthar/blazemeter-plugin.git to branch refs/heads/master
Collecting metadata for plugin BlazeMeterJenkinsPlugin... Please be patient
Done
Running recipes io.jenkins.tools.pluginmodernizer.FixJellyIssues for plugin BlazeMeterJenkinsPlugin... Please be patient
Done
No JDKs found in metadata for plugin BlazeMeterJenkinsPlugin. Using same JDK as rewrite for verification
Skipping formatting for plugin BlazeMeterJenkinsPlugin as it is not using Spotless
Skipping verification for plugin BlazeMeterJenkinsPlugin
Plugin BlazeMeterJenkinsPlugin verified successfully with JDK 17
Collecting metadata for plugin BlazeMeterJenkinsPlugin... Please be patient
Done
No commits to push for plugin BlazeMeterJenkinsPlugin
Skipping pull request for plugin BlazeMeterJenkinsPlugin
*************
Plugin: BlazeMeterJenkinsPlugin
Skip pull request mode. Changes were pushed on https://github.com/gounthar/blazemeter-plugin but no pull request was open on https://github.com/jenkinsci/blazemeter-plugin
*************
Plugin Modernizer finished.

and

~/.cache/jenkins-plugin-modernizer-cli/BlazeMeterJenkinsPlugin/sources (plugin-modernizer-tool)$ head ./src/main/resources/hudson/plugins/blazemeter/PerformanceBuilder/global.jelly
<j:jelly xmlns:j="jelly:core"
         xmlns:st="jelly:stapler"
         xmlns:d="jelly:define"
         xmlns:l="/lib/layout"
         xmlns:t="/lib/hudson"
         xmlns:f="/lib/form">
    <!--
 Copyright 2018 BlazeMeter Inc.

 Licensed under the Apache License, Version 2.0 (the "License");

Even the recipe itself outside of plugin-modernizer does nothing:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-jenkins:RELEASE -Drewrite.activeRecipes=org.openrewrite.jenkins.AddJellyXmlDeclaration -Drewrite.exportDatatables=true
and

~/.cache/jenkins-plugin-modernizer-cli/BlazeMeterJenkinsPlugin/sources (plugin-modernizer-tool)$ head ./src/main/resources/hudson/plugins/blazemeter/PerformanceBuilder/global.jelly
<j:jelly xmlns:j="jelly:core"
         xmlns:st="jelly:stapler"
         xmlns:d="jelly:define"
         xmlns:l="/lib/layout"
         xmlns:t="/lib/hudson"
         xmlns:f="/lib/form">
    <!--
 Copyright 2018 BlazeMeter Inc.

 Licensed under the Apache License, Version 2.0 (the "License");

Still no <?jelly escape-by-default...

@jonesbusy
Copy link
Collaborator

jonesbusy commented Nov 19, 2024

@gounthar I think it's because of the *.jelly files are quarks (not idenfied as files)

We need to threat them as text file I think

https://github.com/openrewrite/rewrite-maven-plugin/blob/3dcec7f65e46c6740ca32f4dfd24e2d8d511a914/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java#L118

Can you try via maven plugin directly using -Drewrite.additionalPlainTextMasks=**/*.jelly ?

If yes we can add this CLI argument on plugin modernizer

@gounthar
Copy link
Collaborator Author

Thanks, Valentin, let me try that. 👍

@jonesbusy
Copy link
Collaborator

Or perhaps even added on https://github.com/openrewrite/rewrite-maven-plugin/blob/3dcec7f65e46c6740ca32f4dfd24e2d8d511a914/src/main/java/org/openrewrite/maven/ConfigurableRewriteMojo.java#L127

I see svg files are also added as text file. Not XML. So would make sense to have *.jelly files as text by default

@gounthar
Copy link
Collaborator Author

Okay, the new command line parameter did the trick with the recipe:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-jenkins:RELEASE -Drewrite.activeRecipes=org.openrewrite.jenkins.AddJellyXmlDeclaration -Drewrite.exportDatatables=true -Drewrite.additionalPlainTextMasks=**/*.jelly
gave

@@ -1,3 +1,4 @@
+<?jelly escape-by-default='true'?>
 <j:jelly xmlns:j="jelly:core"
          xmlns:st="jelly:stapler"
          xmlns:d="jelly:define"
diff --git a/src/main/resources/hudson/plugins/blazemeter/PerformanceReportMap/index.jelly b/src/main/resources/hudson/plugins/blazemeter/PerformanceReportMap/index.jelly
index e9c3040..29b598c 100644
--- a/src/main/resources/hudson/plugins/blazemeter/PerformanceReportMap/index.jelly
+++ b/src/main/resources/hudson/plugins/blazemeter/PerformanceReportMap/index.jelly
@@ -1,3 +1,4 @@
+<?jelly escape-by-default='true'?>
 <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
          xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
     <!--
diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly
index 5c942f0..d127448 100644
--- a/src/main/resources/index.jelly
+++ b/src/main/resources/index.jelly
@@ -1,3 +1,4 @@
+<?jelly escape-by-default='true'?>
 <!--
  Copyright 2018 BlazeMeter Inc.

I will create a new PR on OpenRewrite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants