All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.gradle_plugins.toolkit.GradleUtils Maven / Gradle / Ivy

There is a newer version: 0.68.0
Show newest version
package name.remal.gradle_plugins.toolkit;

import static lombok.AccessLevel.PRIVATE;
import static name.remal.gradle_plugins.toolkit.reflection.MembersFinder.findMethod;
import static name.remal.gradle_plugins.toolkit.reflection.MembersFinder.getMethod;

import lombok.NoArgsConstructor;
import lombok.val;
import org.gradle.api.Action;
import org.gradle.api.invocation.Gradle;

@NoArgsConstructor(access = PRIVATE)
public abstract class GradleUtils {

    private static final boolean ARE_SHARED_SERVICES_ENABLED = findMethod(Gradle.class, "getSharedServices") != null;

    public static void onGradleBuildFinished(Gradle gradle, Action action) {
        if (ARE_SHARED_SERVICES_ENABLED) {
            GradleUtilsBuildFinishedService.registerAction(gradle, action);

        } else {
            val buildFinishedMethod = getMethod(Gradle.class, "buildFinished", Action.class);
            buildFinishedMethod.invoke(gradle, __ -> action.execute(gradle));
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy