Skip to content

Commit

Permalink
Fixed some Gradle deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Aug 8, 2021
1 parent ccdd168 commit b112439
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test;
Expand All @@ -32,11 +32,10 @@ public class CsaccessTestTask


public CsaccessTestTask() {

super();
final Project project = getProject();
final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
final SourceSet csaccessTestSourceSet = javaConvention.getSourceSets().getByName(CustomSourceSetCreator
final JavaPluginExtension jpc = project.getExtensions().getByType(JavaPluginExtension.class);
final SourceSet csaccessTestSourceSet = jpc.getSourceSets().getByName(CustomSourceSetCreator
.CSACCESSTEST_SOURCESET_NAME);

dependsOn(project.getTasks().getByName(csaccessTestSourceSet.getClassesTaskName()));
Expand All @@ -55,13 +54,13 @@ public void setCheckstyleVersion(final String pCheckstyleVersion, final boolean
csVersion = pCheckstyleVersion;
setDescription("Runs the '" + CustomSourceSetCreator.CSACCESSTEST_SOURCESET_NAME + "' unit tests against a "
+ "Checkstyle " + pCheckstyleVersion + " runtime.");
getReports().getJunitXml().setEnabled(false);
getReports().getJunitXml().getRequired().set(false);
if (isBaseVersion) {
setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
getReports().getHtml().setEnabled(true);
getReports().getHtml().getRequired().set(true);
} else {
setGroup(XTEST_GROUP_NAME);
getReports().getHtml().setEnabled(false);
getReports().getHtml().getRequired().set(false);
}

// Make the Checkstyle version available to the test cases via a system property.
Expand Down Expand Up @@ -90,8 +89,8 @@ public FileCollection getClasspath() {

if (originalClasspath != null) {
final Project project = getProject();
final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
final SourceSetContainer sourceSets = javaConvention.getSourceSets();
final JavaPluginExtension jpc = project.getExtensions().getByType(JavaPluginExtension.class);
final SourceSetContainer sourceSets = jpc.getSourceSets();
final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
final SourceSet csaccessSourceSet = sourceSets.getByName(CustomSourceSetCreator.CSACCESS_SOURCESET_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public void setupCoverageVerification() {
jacocoReportTask.setDescription("Generate exclusive JaCoCo test report on the '"
+ CSACCESS_SOURCESET_NAME + "' classes");
configureJacocoTask(jacocoReportTask);
jacocoReportTask.getReports().getXml().setEnabled(true);
jacocoReportTask.getReports().getCsv().setEnabled(false);
jacocoReportTask.getReports().getHtml().setEnabled(true);
jacocoReportTask.getReports().getXml().getRequired().set(true);
jacocoReportTask.getReports().getCsv().getRequired().set(false);
jacocoReportTask.getReports().getHtml().getRequired().set(true);
});

// Verify minimum line coverage for 'csaccess' source set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
Expand Down Expand Up @@ -86,8 +86,8 @@ private void createCrossCheckTasks(final Project pProject) {
TaskProvider<Task> provider = tasks.register(CsaccessTestTask.XTEST_TASK_NAME);
provider.configure((Task xtestTask) -> {
xtestTask.setGroup(CsaccessTestTask.XTEST_GROUP_NAME);
xtestTask.setDescription("Runs the '" + CustomSourceSetCreator.CSACCESSTEST_SOURCESET_NAME + "' unit " +
"tests against all supported Checkstyle runtimes.");
xtestTask.setDescription("Runs the '" + CustomSourceSetCreator.CSACCESSTEST_SOURCESET_NAME + "' unit "
+ "tests against all supported Checkstyle runtimes.");
tasks.getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(xtestTask);
});

Expand Down Expand Up @@ -124,19 +124,19 @@ private void createCheckstyleArtifactTasks(final Project pProject) {
}


private void createCopyCheckstyleArtifactsToSandboxTask(final Project pProject, final boolean pIsTest) {
final TaskContainer tasks = pProject.getTasks();
final String taskName = pIsTest ? "copyCheckstyleArtifactsToTestSandbox" : "copyCheckstyleArtifactsToSandbox";
private void createCopyCheckstyleArtifactsToSandboxTask(final Project project, final boolean test) {
final TaskContainer tasks = project.getTasks();
final String taskName = test ? "copyCheckstyleArtifactsToTestSandbox" : "copyCheckstyleArtifactsToSandbox";
final TaskProvider<Copy> taskProvider = tasks.register(taskName, Copy.class);
taskProvider.configure((Copy copyTask) -> {
copyTask.setGroup("intellij");
copyTask.setDescription("Adds the gathered Checkstyle artifacts to the prepared "
+ (pIsTest ? "test " : "") + "sandbox");
+ (test ? "test " : "") + "sandbox");

final GatherCheckstyleArtifactsTask gatherTask =
(GatherCheckstyleArtifactsTask) tasks.getByName(GatherCheckstyleArtifactsTask.NAME);
copyTask.dependsOn(gatherTask, "prepareTestingSandbox");
if (pIsTest) {
if (test) {
tasks.getByName(JavaPlugin.TEST_TASK_NAME).dependsOn(copyTask);
tasks.getByName(CsaccessTestTask.NAME).dependsOn(copyTask);
forEachXTest(tasks, xTask -> xTask.dependsOn(copyTask));
Expand All @@ -145,7 +145,7 @@ private void createCopyCheckstyleArtifactsToSandboxTask(final Project pProject,
}

copyTask.from(gatherTask.getBundledJarsDir());
copyTask.into(new File(pProject.getBuildDir(), "idea-sandbox/plugins" + (pIsTest ? "-test" : "")
copyTask.into(new File(project.getBuildDir(), "idea-sandbox/plugins" + (test ? "-test" : "")
+ "/CheckStyle-IDEA/" + CSLIB_TARGET_SUBFOLDER));
});
}
Expand All @@ -172,10 +172,10 @@ private void createCopyClassesToSandboxTask(final Project pProject, final boolea
final TaskProvider<Copy> taskProvider = tasks.register(taskName, Copy.class);
taskProvider.configure((Copy copyTask) -> {
copyTask.setGroup("intellij");
copyTask.setDescription("Copy classes from \'" + CustomSourceSetCreator.CSACCESS_SOURCESET_NAME
+ "\' sourceset into the prepared " + (pIsTest ? "test " : "") + "sandbox");
copyTask.setDescription("Copy classes from '" + CustomSourceSetCreator.CSACCESS_SOURCESET_NAME
+ "' sourceset into the prepared " + (pIsTest ? "test " : "") + "sandbox");

final JavaPluginConvention jpc = pProject.getConvention().getPlugin(JavaPluginConvention.class);
final JavaPluginExtension jpc = pProject.getExtensions().getByType(JavaPluginExtension.class);
SourceSet csaccessSourceSet = jpc.getSourceSets().getByName(CustomSourceSetCreator.CSACCESS_SOURCESET_NAME);
copyTask.dependsOn(tasks.getByName(csaccessSourceSet.getClassesTaskName()));
if (pIsTest) {
Expand Down

0 comments on commit b112439

Please sign in to comment.