Skip to content

Commit

Permalink
try fix report settings in extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas3oo committed Aug 16, 2024
1 parent 4366228 commit a6a1561
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 13 deletions.
15 changes: 8 additions & 7 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin.nosync/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin.nosync/main" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
Expand All @@ -12,14 +19,8 @@
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin.nosync/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="con" path="GROOVY_DSL_SUPPORT"/>
<classpathentry kind="output" path="bin.nosync/main"/>
</classpath>
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1714584187385</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=javax.annotation.ParametersAreNonnullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
Expand All @@ -10,6 +12,7 @@ org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
org.eclipse.jdt.core.compiler.source=11
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ dependencies {
sonarlintPlugins("org.sonarsource.kotlin:sonar-kotlin-plugin:2.20.0.4382")
}

// configure the tasks directly since the overloaded "extensions" like sonarlintMain will not work in Kotlin DSL
tasks.sonarlintMain {
sonarlint {
maxIssues.set(1)
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
repositories {
mavenCentral()
}
// latest core ? 8.11.0.56591

dependencies {
implementation('io.github.furstenheim:copy_down:1.1')
implementation('org.apache.commons:commons-text:1.10.0')
Expand All @@ -26,7 +26,7 @@ dependencies {
}

group = 'se.solrike.sonarlint'
version = '2.0.0'
version = '2.0.1-beta1'

sourceSets {
main {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/se/solrike/sonarlint/SonarlintPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.gradle.api.plugins.JavaBasePlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.plugins.ReportingBasePlugin;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.api.reporting.ReportingExtension;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
Expand Down Expand Up @@ -123,8 +125,8 @@ protected TaskProvider<Sonarlint> createTask(Project project, SonarlintExtension
task.getRuleParameters().set(extension.getRuleParameters());
task.getShowIssues().set(extension.getShowIssues());
task.getReportsDir().set(extension.getReportsDir());
// below doesn't seesm to work
task.getReports().addAll(extension.getReports().getAsMap().values());

});

// let "check" task depend on sonarlint so it gets run automatically
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/se/solrike/sonarlint/SonarlintReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* <ul>
* <li>html
* <li>text
* <li>sarif
* <li>xml
* </ul>
* <p>
* The reporting aspects of a {@link Sonarlint} task can be configured as such:
Expand All @@ -26,8 +28,8 @@
* // override default report file location for text report
* outputLocation = layout.buildDirectory.file('my_sonarlint.txt')
* }
* xml.enabled = true // default false
* sarif.enabled = true // default false
* xml.enabled = true // default false
* }
* }
* </pre>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/se/solrike/sonarlint/impl/ReportAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public ReportAction(Sonarlint task, Logger logger, ProjectLayout layout, Provide
public void report(List<IssueEx> issues) {
Map<String, SonarlintReport> reports = mTask.getReports().getAsMap();

mLogger.error("Reports configured: {}", reports);

// generate reports
reports.forEach((name, report) -> {
if (report.getEnabled().getOrElse(Boolean.FALSE)) {
Expand Down

0 comments on commit a6a1561

Please sign in to comment.