
dev.lajoscseppento.ruthless.plugin.impl.RuthlessBasePlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ruthless-plugin Show documentation
Show all versions of ruthless-plugin Show documentation
Ruthless conventions for Gradle projects to keep them DRY
package dev.lajoscseppento.ruthless.plugin.impl;
import dev.lajoscseppento.gradle.plugin.common.impl.Utils;
import dev.lajoscseppento.ruthless.plugin.extension.RuthlessExtension;
import dev.lajoscseppento.ruthless.plugin.extension.impl.RuthlessExtensionImpl;
import org.gradle.api.GradleException;
public class RuthlessBasePlugin extends AbstractProjectPlugin {
@Override
public void apply() {
if (!gradle.getPlugins().hasPlugin(RuthlessGradlePlugin.class)) {
throw new GradleException(
"Please apply ruthless in settings.gradle[.kts] for the full experience");
}
logger.info("Adding extension to {}", project);
configureExtension();
if (project.equals(project.getRootProject())) {
logger.info("Configuring sonar on {}", project);
configureSonar();
}
project.afterEvaluate(proj -> afterEvaluate());
}
private void configureExtension() {
RuthlessExtension ruthless = new RuthlessExtensionImpl(project);
extensions.add(RuthlessExtension.class, "ruthless", ruthless);
}
private void configureSonar() {
// TODO
}
private void afterEvaluate() {
if (Utils.isUnspecified(project.getGroup())) {
String msg =
String.format(
"Group of %s is unspecified - you might want to put it in gradle.properties",
project);
throw new GradleException(msg);
} else if (Utils.isUnspecified(project.getVersion())) {
String msg =
String.format(
"Version of %s is unspecified - you might want to put it in gradle.properties",
project);
throw new GradleException(msg);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy