Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCANGRADLE-158 Lazily register sonar and sonarqube tasks #264

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/main/java/org/sonarqube/gradle/SonarQubePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.TaskContainer;
import org.gradle.testing.jacoco.plugins.JacocoPlugin;
import org.gradle.testing.jacoco.tasks.JacocoReport;
import org.gradle.util.GradleVersion;
Expand Down Expand Up @@ -76,16 +77,18 @@ public void apply(Project project) {
addExtensions(project, SonarExtension.SONAR_DEPRECATED_EXTENSION_NAME, actionBroadcastMap);
LOGGER.debug("Adding '{}' task to '{}'", SonarExtension.SONAR_TASK_NAME, project);

SonarTask sonarqubeTask = project.getTasks().create(SonarExtension.SONAR_DEPRECATED_TASK_NAME, SonarTask.class);
sonarqubeTask.setDescription("Analyzes " + project + " and its subprojects with Sonar. This task is deprecated. Use 'sonar' instead.");
sonarqubeTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);

SonarTask sonarTask = project.getTasks().create(SonarExtension.SONAR_TASK_NAME, SonarTask.class);
sonarTask.setDescription("Analyzes " + project + " and its subprojects with Sonar.");
sonarTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP);

configureTask(sonarqubeTask, project, actionBroadcastMap);
configureTask(sonarTask, project, actionBroadcastMap);
TaskContainer tasks = project.getTasks();
tasks.register(SonarExtension.SONAR_DEPRECATED_TASK_NAME, SonarTask.class, task -> {
task.setDescription("Analyzes " + project + " and its subprojects with Sonar. This task is deprecated. Use 'sonar' instead.");
task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
configureTask(task, project, actionBroadcastMap);
});

tasks.register(SonarExtension.SONAR_TASK_NAME, SonarTask.class, task -> {
task.setDescription("Analyzes " + project + " and its subprojects with Sonar.");
task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
configureTask(task, project, actionBroadcastMap);
});
}
}

Expand Down