Skip to content

Commit

Permalink
API plugin recipes conditions and integrationt test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesbusy committed Dec 19, 2024
1 parent a69f9a3 commit 68d7cd2
Show file tree
Hide file tree
Showing 20 changed files with 456 additions and 231 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,35 @@ If you are using a mirror for `central` you should adapt the `reference.repo` pr

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

## How to debug recipes

Update the `rewrite.yml` into the src/test/resources/<plugin>

Example

```yaml
---
type: specs.openrewrite.org/v1beta/recipe
name: io.jenkins.tools.pluginmodernizer.Debug
displayName: Debug recipe
description: Debug recipe
conditions: []
recipeList: []
```
Then run openrewrite with the following command
```shell
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
```

If you want to test with recipes from modernizer core

```
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
```

## References

- [GSoC 2024 Project Proposal](https://docs.google.com/document/d/1e1QkprPN6fLpFXk_QqBUQlJhZrAl9RvXbOXOiJ-gAuY/edit?usp=sharing)
Expand Down
52 changes: 51 additions & 1 deletion plugin-modernizer-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,31 @@
</resource>
</resources>
<plugins>

<!-- Clean test plugin if they are compiled -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-plugin</id>
<goals>
<goal>clean</goal>
</goals>
<phase>clean</phase>
<configuration>
<filesets>
<fileset>
<directory>src/test/resources</directory>
<includes>
<include>**/target/**</include>
</includes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>

<!-- The CLI is distributed via JRelease and published on the GitHub releases page -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -127,7 +152,6 @@
<include>**/*ITCase.java</include>
</includes>
<environmentVariables>
<MAVEN_LOCAL_REPO>${maven.repo.local}</MAVEN_LOCAL_REPO>
<MAVEN_HOME>${project.build.directory}/apache-maven-${maven.version}</MAVEN_HOME>
<GH_TOKEN>fake-token</GH_TOKEN>
<GH_OWNER>fake-owner</GH_OWNER>
Expand Down Expand Up @@ -203,4 +227,30 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>maven-repo-local</id>
<activation>
<property>
<name>maven.repo.local</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemProperties combine.children="append">
<property>
<name>maven.repo.local</name>
<value>${maven.repo.local}</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.jenkins.tools.pluginmodernizer.cli.command;

import io.jenkins.tools.pluginmodernizer.cli.converter.RecipeConverter;
import io.jenkins.tools.pluginmodernizer.cli.options.EnvOptions;
import io.jenkins.tools.pluginmodernizer.cli.options.GitHubOptions;
import io.jenkins.tools.pluginmodernizer.cli.options.GlobalOptions;
import io.jenkins.tools.pluginmodernizer.cli.options.PluginOptions;
import io.jenkins.tools.pluginmodernizer.core.config.Config;
Expand Down Expand Up @@ -38,16 +40,30 @@ public class DryRunCommand implements ICommand {
converter = RecipeConverter.class)
private Recipe recipe;

/**
* Environment options
*/
@CommandLine.Mixin
private EnvOptions envOptions;

/**
* Global options for all commands
*/
@CommandLine.Mixin
private GlobalOptions options;

/**
* GitHub options
*/
@CommandLine.Mixin
private GitHubOptions githubOptions;

@Override
public Config setup(Config.Builder builder) {
options.config(builder);
pluginOptions.config(builder);
githubOptions.config(builder);
envOptions.config(builder);
return builder.withDryRun(true).withRecipe(recipe).build();
}

Expand Down
Loading

0 comments on commit 68d7cd2

Please sign in to comment.