Skip to content

Commit c8377c9

Browse files
authored
Merge pull request #485 from jonesbusy/feature/api-conditions
Add API plugin and condition for recipes
2 parents 9901384 + 8cff607 commit c8377c9

23 files changed

Lines changed: 557 additions & 209 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
target/
22
!.mvn/wrapper/maven-wrapper.jar
3-
!**/src/main/**/target/
4-
!**/src/test/**/target/
53

64
### Log file ###
75
logs/

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: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,38 @@
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+
<fileset>
113+
<directory>.</directory>
114+
<includes>
115+
<include>logs/*.log</include>
116+
<include>logs/*.txt</include>
117+
</includes>
118+
</fileset>
119+
</filesets>
120+
</configuration>
121+
</execution>
122+
</executions>
123+
</plugin>
124+
93125
<!-- The CLI is distributed via JRelease and published on the GitHub releases page -->
94126
<plugin>
95127
<groupId>org.apache.maven.plugins</groupId>
@@ -127,7 +159,6 @@
127159
<include>**/*ITCase.java</include>
128160
</includes>
129161
<environmentVariables>
130-
<MAVEN_LOCAL_REPO>${maven.repo.local}</MAVEN_LOCAL_REPO>
131162
<MAVEN_HOME>${project.build.directory}/apache-maven-${maven.version}</MAVEN_HOME>
132163
<GH_TOKEN>fake-token</GH_TOKEN>
133164
<GH_OWNER>fake-owner</GH_OWNER>
@@ -203,4 +234,30 @@
203234
</plugin>
204235
</plugins>
205236
</build>
237+
238+
<profiles>
239+
<profile>
240+
<id>maven-repo-local</id>
241+
<activation>
242+
<property>
243+
<name>maven.repo.local</name>
244+
</property>
245+
</activation>
246+
<build>
247+
<plugins>
248+
<plugin>
249+
<artifactId>maven-failsafe-plugin</artifactId>
250+
<configuration>
251+
<systemProperties combine.children="append">
252+
<property>
253+
<name>maven.repo.local</name>
254+
<value>${maven.repo.local}</value>
255+
</property>
256+
</systemProperties>
257+
</configuration>
258+
</plugin>
259+
</plugins>
260+
</build>
261+
</profile>
262+
</profiles>
206263
</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)