How to configure (sub-)projects without groovy?

We have a scenario here with ~2000 (gradle)projects. 95% of that are plain java builds. To assure that they are all standard, I’m trying to set up the projects without the build.gradle file, because the groovy script allows absolute flexibility while being hard to check if it obeys to our (build) standards.

So what I’m trying to do is to have a (gradle)project set up from a xml or json file and add some logic to the build that reads the xml and configures the project from that - and avoid having a build.gradle file at all.

As I can see it, this splits up in two tasks: 1. In the settings.gradle, find a way to add a project with a different file than build.gradle (that seems to be possible) 2. Add my own ScriptPluginFactory as a service to the buildscript classpath and decide by the script file extension if it has to delegate to the DefaultScriptPluginFactory or analyze the xml on its own.

Actually, I’m failing with adding the ScriptPluginFactory, it just won’t be called at all. Am I missing something here?

Thx in advance,

Armin

OK, think I found another way on my own now:

In the master build.gradle, have a:

subprojects {
    projectEvaluator = new MyProjectEvaluator();
}
  class MyProjectEvaluator implements org.gradle.configuration.project.ProjectEvaluator {
    public void evaluate(ProjectInternal project, ProjectStateInternal state){
        if (state.getExecuted() || state.getExecuting()) {
            return;
        }
        ProjectEvaluationListener listener = project.getProjectEvaluationBroadcaster();
            try {
            listener.beforeEvaluate(project);
        } catch (Exception e) {
            // not clean here
            e.printStackTrace();
            return;
        }
        state.setExecuting(true);
        try {
     println 'Evaluate '+project;
     // here comes what the build.gradle file would do
     project.apply plugin:'my-very-own-java-base'
            // read dependencies from txt file or whatever
        } catch (Exception e) {
            // not clean here
            e.printStackTrace();
        } finally {
            state.setExecuting(false);
            state.executed();
            // important, otherwise the afterEvaluate actions would not be executed
            listener.afterEvaluate(project, state);
        }
    }
}

Most of this code is stolen from org.gradle.configuration.project.LifecycleProjectEvaluator, which seems to be a good template for a real implementation.