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

Package OpenRewrite recipes as jar #1060

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ErhardSiegl
Copy link

This is a contribution to https://issues.redhat.com/browse/WINDUPRULE-1046
It enables to use the following plugin configuration in pom.xml

            <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>5.17.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.jboss.windup.rules</groupId>
                        <artifactId>windup-rulesets</artifactId>
                        <classifier>rewrite</classifier>
                        <version>6.4.0-SNAPSHOT</version>
                    </dependency>
                </dependencies>
            </plugin>

and then e.g:

mvn rewrite:discover | grep windup
[INFO]     org.jboss.windup.eap8.FacesWebXml
[INFO]     org.jboss.windup.jakarta.javax.BootstrappingFiles
[INFO]     org.jboss.windup.jakarta.javax.PersistenceXml
[INFO]     org.jboss.windup.JavaxActivationToJakartaActivation
[INFO]     org.jboss.windup.JavaxAnnotationToJakartaAnnotation
[INFO]     org.jboss.windup.JavaxBatchToJakartaBatch
[INFO]     org.jboss.windup.JavaxDecoratorToJakartaDecorator
[INFO]     org.jboss.windup.JavaxEjbToJakartaEjb
[INFO]     org.jboss.windup.JavaxElToJakartaEl

The code is taken from https://github.com/quarkusio/quarkus-updates/blob/main/recipes/pom.xml and https://github.com/quarkusio/quarkus-updates/blob/main/recipes/src/main/assembly/core.xml

This is meant as proof of concept and does not fix WINDUPRULE-1046
One problem is, that windup-cli --openrewrite uses -Drewrite.recipeArtifactCoordinates but this option apparently doesn't understand maven classifiers.
Also it might not be the best solution to generate a separate artifact instead of just moving the rewrite.yml files to META-INF/rewrite. However that would have more impact, while this change is compatible with older versions.

@m-brophy
Copy link
Contributor

m-brophy commented Jan 23, 2024

Thanks for this @ErhardSiegl - this is a really good idea and I'll have a think about whether it's best to create the jar or just move the recipes to META-INF/rewrite. Does openrewrite automatically parse any yaml files under there? Or do they have to be named rewrite.yml? I'm just thinking of the logistics of moving several files with the same name to the same folder.

Ah, I think I get it - Does what you suggest here do it by maintaining the existing directory structure under META-INF/rewrite and openrewrite picks up all rewrite.yml files under that top folder?

@ErhardSiegl
Copy link
Author

The files don't have to be named rewrite.yml. Many projects use different names (see e.g. Quarkus) and have it directly under META-INF/rewrite.
Indeed, in my example the directory structure is maintained to avoid conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants