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

Add API plugin and condition for recipes #485

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### Log file ###
logs/
Expand Down
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
59 changes: 58 additions & 1 deletion plugin-modernizer-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,38 @@
</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>
<fileset>
<directory>.</directory>
<includes>
<include>logs/*.log</include>
<include>logs/*.txt</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 +159,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 +234,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
Loading