Skip to content

Commit

Permalink
#140 Set this tasks as Not Compatible with configuration cache
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermo-varela committed Aug 18, 2023
1 parent 8b2e19f commit 41ad419
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main/java/org/sonatype/gradle/plugins/scan/ScanPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,51 @@

public class ScanPlugin implements Plugin<Project>
{
private static final boolean IS_GRADLE_MIN_49 = GradleVersion.current().compareTo(GradleVersion.version("4.9-rc-1"))>=0;
private static final boolean IS_GRADLE_MIN_4_9 =
GradleVersion.current().compareTo(GradleVersion.version("4.9-rc-1")) >= 0;

private static final boolean IS_GRADLE_MIN_7_4 =
GradleVersion.current().compareTo(GradleVersion.version("7.4")) >= 0;

private static final String SONATYPE_GROUP = "Sonatype";

private static final String TASK_NOT_COMPATIBLE_WITH_CONFIG_CACHE_REASON =
"Task needs to access the project configuration";

@Override
@SuppressWarnings("deprecation")
public void apply(Project project) {
project.getExtensions().create("nexusIQScan", NexusIqPluginScanExtension.class, project);
createTask(project, "nexusIQScan", NexusIqScanTask.class, task -> {
task.setGroup(SONATYPE_GROUP);
task.setDescription("Scan and evaluate the dependencies of the project using Nexus IQ Server.");
if (IS_GRADLE_MIN_7_4) {
task.notCompatibleWithConfigurationCache(TASK_NOT_COMPATIBLE_WITH_CONFIG_CACHE_REASON);
}
});

project.getExtensions().create("nexusIQIndex", NexusIqPluginIndexExtension.class, project);
createTask(project, "nexusIQIndex", NexusIqIndexTask.class, task -> {
task.setGroup(SONATYPE_GROUP);
task.setDescription("Saves information about the dependencies of a project into module information "
+ "(module.xml) files that Sonatype CI tools can use to include these dependencies in a scan.");
if (IS_GRADLE_MIN_7_4) {
task.notCompatibleWithConfigurationCache(TASK_NOT_COMPATIBLE_WITH_CONFIG_CACHE_REASON);
}
});

project.getExtensions().create("ossIndexAudit", OssIndexPluginExtension.class, project);
createTask(project, "ossIndexAudit", OssIndexAuditTask.class, task -> {
task.setGroup(SONATYPE_GROUP);
task.setDescription("Audit the dependencies of the project using OSS Index.");
if (IS_GRADLE_MIN_7_4) {
task.notCompatibleWithConfigurationCache(TASK_NOT_COMPATIBLE_WITH_CONFIG_CACHE_REASON);
}
});
}

private static <T extends Task> void createTask(Project project, String name, Class<T> type, Action<? super T> configuration) {
if (IS_GRADLE_MIN_49) {
if (IS_GRADLE_MIN_4_9) {
project.getTasks().register(name, type, configuration);
} else {
project.getTasks().create(name, type, configuration);
Expand Down

0 comments on commit 41ad419

Please sign in to comment.