Skip to content

Commit 986bace

Browse files
committed
API plugin recipes conditions and integrationt test
1 parent a69f9a3 commit 986bace

20 files changed

Lines changed: 460 additions & 241 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,35 @@ If you are using a mirror for `central` you should adapt the `reference.repo` pr
291291

292292
Thanks to all our contributors! Check out our [CONTRIBUTING](docs/CONTRIBUTING.md) file to learn how to get started.
293293

294+
## How to debug recipes
295+
296+
Update the `rewrite.yml` into the src/test/resources/<plugin>
297+
298+
Example
299+
300+
```yaml
301+
---
302+
type: specs.openrewrite.org/v1beta/recipe
303+
name: io.jenkins.tools.pluginmodernizer.Debug
304+
displayName: Debug recipe
305+
description: Debug recipe
306+
conditions: []
307+
recipeList: []
308+
```
309+
310+
Then run openrewrite with the following command
311+
312+
```shell
313+
mvn org.openrewrite.maven:rewrite-maven-plugin:dryRun -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-jenkins:0.19.0 -Drewrite.activeRecipes=io.jenkins.tools.pluginmodernizer.Debug
314+
```
315+
316+
If you want to test with recipes from modernizer core
317+
318+
```
319+
mvn org.openrewrite.maven:rewrite-maven-plugin:dryRun -Drewrite.recipeArtifactCoordinates=io.jenkins.plugin-modernizer:plugin-modernizer-core:999999-SNAPSHOT -Drewrite.activeRecipes=io.jenkins.tools.pluginmodernizer.Debug
320+
321+
```
322+
294323
## References
295324

296325
- [GSoC 2024 Project Proposal](https://docs.google.com/document/d/1e1QkprPN6fLpFXk_QqBUQlJhZrAl9RvXbOXOiJ-gAuY/edit?usp=sharing)

plugin-modernizer-cli/pom.xml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,31 @@
9090
</resource>
9191
</resources>
9292
<plugins>
93+
94+
<!-- Clean test plugin if they are compiled -->
95+
<plugin>
96+
<artifactId>maven-clean-plugin</artifactId>
97+
<executions>
98+
<execution>
99+
<id>clean-plugin</id>
100+
<goals>
101+
<goal>clean</goal>
102+
</goals>
103+
<phase>clean</phase>
104+
<configuration>
105+
<filesets>
106+
<fileset>
107+
<directory>src/test/resources</directory>
108+
<includes>
109+
<include>**/target/**</include>
110+
</includes>
111+
</fileset>
112+
</filesets>
113+
</configuration>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
93118
<!-- The CLI is distributed via JRelease and published on the GitHub releases page -->
94119
<plugin>
95120
<groupId>org.apache.maven.plugins</groupId>
@@ -127,7 +152,6 @@
127152
<include>**/*ITCase.java</include>
128153
</includes>
129154
<environmentVariables>
130-
<MAVEN_LOCAL_REPO>${maven.repo.local}</MAVEN_LOCAL_REPO>
131155
<MAVEN_HOME>${project.build.directory}/apache-maven-${maven.version}</MAVEN_HOME>
132156
<GH_TOKEN>fake-token</GH_TOKEN>
133157
<GH_OWNER>fake-owner</GH_OWNER>
@@ -203,4 +227,30 @@
203227
</plugin>
204228
</plugins>
205229
</build>
230+
231+
<profiles>
232+
<profile>
233+
<id>maven-repo-local</id>
234+
<activation>
235+
<property>
236+
<name>maven.repo.local</name>
237+
</property>
238+
</activation>
239+
<build>
240+
<plugins>
241+
<plugin>
242+
<artifactId>maven-failsafe-plugin</artifactId>
243+
<configuration>
244+
<systemProperties combine.children="append">
245+
<property>
246+
<name>maven.repo.local</name>
247+
<value>${maven.repo.local}</value>
248+
</property>
249+
</systemProperties>
250+
</configuration>
251+
</plugin>
252+
</plugins>
253+
</build>
254+
</profile>
255+
</profiles>
206256
</project>

plugin-modernizer-cli/src/main/java/io/jenkins/tools/pluginmodernizer/cli/command/DryRunCommand.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.jenkins.tools.pluginmodernizer.cli.command;
22

33
import io.jenkins.tools.pluginmodernizer.cli.converter.RecipeConverter;
4+
import io.jenkins.tools.pluginmodernizer.cli.options.EnvOptions;
5+
import io.jenkins.tools.pluginmodernizer.cli.options.GitHubOptions;
46
import io.jenkins.tools.pluginmodernizer.cli.options.GlobalOptions;
57
import io.jenkins.tools.pluginmodernizer.cli.options.PluginOptions;
68
import io.jenkins.tools.pluginmodernizer.core.config.Config;
@@ -38,16 +40,30 @@ public class DryRunCommand implements ICommand {
3840
converter = RecipeConverter.class)
3941
private Recipe recipe;
4042

43+
/**
44+
* Environment options
45+
*/
46+
@CommandLine.Mixin
47+
private EnvOptions envOptions;
48+
4149
/**
4250
* Global options for all commands
4351
*/
4452
@CommandLine.Mixin
4553
private GlobalOptions options;
4654

55+
/**
56+
* GitHub options
57+
*/
58+
@CommandLine.Mixin
59+
private GitHubOptions githubOptions;
60+
4761
@Override
4862
public Config setup(Config.Builder builder) {
4963
options.config(builder);
5064
pluginOptions.config(builder);
65+
githubOptions.config(builder);
66+
envOptions.config(builder);
5167
return builder.withDryRun(true).withRecipe(recipe).build();
5268
}
5369

0 commit comments

Comments
 (0)