Interface ModelBuilder<T>

  • Type Parameters:
    T - The type of model to build
    All Superinterfaces:
    ConfigurableLauncher<ModelBuilder<T>>, LongRunningOperation

    public interface ModelBuilder<T>
    extends ConfigurableLauncher<ModelBuilder<T>>
    A ModelBuilder allows you to fetch a snapshot of some model for a project or a build. Instances of ModelBuilder are not thread-safe.

    You use a ModelBuilder as follows:

    Example:
     ProjectConnection connection = GradleConnector.newConnector()
        .forProjectDirectory(new File("someFolder"))
        .connect();
    
     try {
        ModelBuilder<GradleProject> builder = connection.model(GradleProject.class);
    
        //if you use a different than usual build file name:
        builder.withArguments("--build-file", "theBuild.gradle");
    
        //configure the standard input in case your build is interactive:
        builder.setStandardInput(new ByteArrayInputStream("consume this!".getBytes()));
    
        //if you want to listen to the progress events:
        ProgressListener listener = null; // use your implementation
        builder.addProgressListener(listener);
    
        //get the model:
        GradleProject project = builder.get();
    
        //query the model for information:
        System.out.println("Available tasks: " + project.getTasks());
     } finally {
        connection.close();
     }
     
    Since:
    1.0-milestone-3