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

Running Rewrite on a Gradle Kotlin project without modifying the build #234

Open
ia3andy opened this issue Sep 28, 2023 · 2 comments
Open
Labels
blocked When an issue can't be worked on right now documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed

Comments

@ia3andy
Copy link

ia3andy commented Sep 28, 2023

The current doc only shows the groovy option, it would be nice to also provide the Kotlin one.

@ia3andy ia3andy added the enhancement New feature or request label Sep 28, 2023
@timtebeek timtebeek transferred this issue from openrewrite/rewrite Sep 28, 2023
@timtebeek timtebeek transferred this issue from openrewrite/rewrite-recipe-markdown-generator Sep 28, 2023
@timtebeek timtebeek added the documentation Improvements or additions to documentation label Sep 28, 2023
@timtebeek timtebeek moved this to Backlog in OpenRewrite Sep 28, 2023
@mike-solomon
Copy link
Contributor

mike-solomon commented Oct 4, 2023

I took a look at this, but I'm not that familiar with Gradle or Kotlin 😅 . I was able to resolve some of the issues converting it to Kotlin -- but I'm struggling to figure out the syntax for how to apply the rewrite plugin.

I keep getting an Unresolved reference: rewrite error when I try and run gradle --init-script init.gradle.kts.

Things I've tried include:

rootProject {
    apply<org.openrewrite.gradle.RewritePlugin>()
    
    dependencies {
        rewrite("org.openrewrite:rewrite-java")
    }

    rewrite {
        activeRecipe("org.openrewrite.FindSpringUses")
    }
}
rootProject {
    apply {
        plugin("org.openrewrite.gradle.RewritePlugin")
    }
    
    dependencies {
        rewrite("org.openrewrite:rewrite-java")
    }

    rewrite {
        activeRecipe("org.openrewrite.FindSpringUses")
    }
}
rootProject {
    plugins.apply("org.openrewrite.gradle.RewritePlugin")

    dependencies {
        rewrite("org.openrewrite:rewrite-java")
    }

    rewrite {
        activeRecipe("org.openrewrite.FindSpringUses")
    }
}

If anyone has figured this out please let me know :D

@mike-solomon mike-solomon added the help wanted Extra attention is needed label Oct 4, 2023
@mike-solomon
Copy link
Contributor

Also - for anyone looking at this in the future, Kotlin expects a url like this for the first part of the initscript as far as I can tell:

initscript {
    repositories {
        maven {
            url = uri("https://plugins.gradle.org/m2")
        }
    }

    dependencies {
        classpath("org.openrewrite:plugin:latest.release")
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked When an issue can't be worked on right now documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed
Projects
Status: Backlog
Development

No branches or pull requests

3 participants