-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure second execution work and fix 2.479.1 migration
- Loading branch information
Showing
19 changed files
with
927 additions
and
45 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
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
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
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
...dernizer-core/src/main/java/io/jenkins/tools/pluginmodernizer/core/recipes/UpdateBom.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,26 @@ | ||
package io.jenkins.tools.pluginmodernizer.core.recipes; | ||
|
||
import io.jenkins.tools.pluginmodernizer.core.visitors.UpdateBomVersionVisitor; | ||
import org.openrewrite.*; | ||
import org.openrewrite.maven.table.MavenMetadataFailures; | ||
|
||
/** | ||
* A recipe that update the bom version to latest available. | ||
*/ | ||
public class UpdateBom extends Recipe { | ||
|
||
@Override | ||
public @NlsRewrite.DisplayName String getDisplayName() { | ||
return "Update bom recipe"; | ||
} | ||
|
||
@Override | ||
public @NlsRewrite.Description String getDescription() { | ||
return "Update bom recipe."; | ||
} | ||
|
||
@Override | ||
public TreeVisitor<?, ExecutionContext> getVisitor() { | ||
return Preconditions.check(new IsUsingBom(), new UpdateBomVersionVisitor(new MavenMetadataFailures(this))); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...e/src/main/java/io/jenkins/tools/pluginmodernizer/core/recipes/UpgradeJenkinsVersion.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,61 @@ | ||
package io.jenkins.tools.pluginmodernizer.core.recipes; | ||
|
||
import org.openrewrite.*; | ||
import org.openrewrite.jenkins.UpgradeVersionProperty; | ||
import org.openrewrite.maven.MavenIsoVisitor; | ||
import org.openrewrite.xml.tree.Xml; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* A recipe to upgrade the Jenkins version in the pom.xml. | ||
* Take care of updating the bom or adding the bom if it's not present. | ||
* Not changing anything if the version is already higher than the minimum version. | ||
*/ | ||
public class UpgradeJenkinsVersion extends Recipe { | ||
|
||
/** | ||
* LOGGER. | ||
*/ | ||
private static final Logger LOG = LoggerFactory.getLogger(UpgradeJenkinsVersion.class); | ||
|
||
/** | ||
* The minimum version. | ||
*/ | ||
@Option(displayName = "Version", description = "The version.", example = "2.452.4") | ||
String minimumVersion; | ||
|
||
/** | ||
* Constructor. | ||
* @param minimumVersion The minimum version. | ||
*/ | ||
public UpgradeJenkinsVersion(String minimumVersion) { | ||
this.minimumVersion = minimumVersion; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return "Upgrade Jenkins version"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Upgrade Jenkins version."; | ||
} | ||
|
||
@Override | ||
public TreeVisitor<?, ExecutionContext> getVisitor() { | ||
return new MavenIsoVisitor<>() { | ||
|
||
@Override | ||
public Xml.Document visitDocument(Xml.Document document, ExecutionContext ctx) { | ||
|
||
// Return another tree with jenkins version updated | ||
document = (Xml.Document) new UpgradeVersionProperty("jenkins.version", minimumVersion) | ||
.getVisitor() | ||
.visitNonNull(document, ctx); | ||
return (Xml.Document) new UpdateBom().getVisitor().visitNonNull(document, ctx); | ||
} | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.