Class OpenRewriteModelBuilder

java.lang.Object
org.openrewrite.gradle.toolingapi.OpenRewriteModelBuilder

public class OpenRewriteModelBuilder extends Object
  • Constructor Details

    • OpenRewriteModelBuilder

      public OpenRewriteModelBuilder()
  • Method Details

    • forProjectDirectory

      public static OpenRewriteModel forProjectDirectory(File projectDir, @Nullable File buildFile) throws IOException
      Warning: This API is likely to change over time without notice Build an OpenRewriteModel for a project directory, using the default Gradle init script bundled within this jar. The included init script accesses public artifact repositories (Maven Central, Nexus Snapshots) to be able to download rewrite dependencies, so public repositories must be accessible for this to work.
      Throws:
      IOException
    • forProjectDirectory

      public static OpenRewriteModel forProjectDirectory(File projectDir, @Nullable File buildFile, @Nullable String initScript) throws IOException
      Warning: This API is likely to change over time without notice Build an OpenRewriteModel for a project directory, using the init script contents passed to this function. When Maven Central / Nexus Snapshots are inaccessible this overload can be used with an alternate Groovy init script which applies the ToolingApiOpenRewriteModelPlugin to all projects. Example init script:
       initscript {
           repositories {
               mavenLocal()
               maven{ url = uri("https://central.sonatype.com/repository/maven-snapshots") }
               mavenCentral()
           }
      
           configurations.all {
               resolutionStrategy{
                   cacheChangingModulesFor 0, 'seconds'
                   cacheDynamicVersionsFor 0, 'seconds'
               }
           }
      
           dependencies {
               classpath 'org.openrewrite.gradle.tooling:plugin:latest.integration'
               classpath 'org.openrewrite:rewrite-maven:latest.integration'
           }
       }
      
       allprojects {
           apply plugin: org.openrewrite.gradle.toolingapi.ToolingApiOpenRewriteModelPlugin
       }
       
      Throws:
      IOException