Skip to content

Commit dfdcead

Browse files
authored
SLOMNI-25 Use path to analyzer JAR provided through analyzer property (#241)
* SLOMNI-25 Use path to analyzer JAR provided through analyzer property * SLOMNI-25 Load rule descriptions from the C# analyzer * SLOMNI-25 Set output directory at another place to try to fix ITs * SLOMNI-25 Use updated core and C# analyzers, get a few ITs back * SLOMNI-25 Use latest C# analyzer with default rule enablement, get more ITs back * SLOMNI-25 Use path provided by SLCORE to extract analyzer * SLOMNI-25 Fix cycle in plugin classes * SLOMNI-25 Use master builds of C# analyzer and SLCORE 10.10 * SLOMNI-25 Only extract analyzer ZIP from plugin JAR
1 parent 7d44c49 commit dfdcead

19 files changed

+827
-1118
lines changed

its/pom.xml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,25 @@
4747
</dependency>
4848
<dependency>
4949
<groupId>org.sonarsource.sonarlint.core</groupId>
50-
<artifactId>sonarlint-core</artifactId>
50+
<artifactId>sonarlint-java-client-utils</artifactId>
51+
<version>${sonarlint-core.version}</version>
52+
<scope>test</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.sonarsource.sonarlint.core</groupId>
56+
<artifactId>sonarlint-rpc-protocol</artifactId>
57+
<version>${sonarlint-core.version}</version>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.sonarsource.sonarlint.core</groupId>
62+
<artifactId>sonarlint-rpc-impl</artifactId>
63+
<version>${sonarlint-core.version}</version>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.sonarsource.sonarlint.core</groupId>
68+
<artifactId>sonarlint-rpc-java-client</artifactId>
5169
<version>${sonarlint-core.version}</version>
5270
<scope>test</scope>
5371
</dependency>
@@ -145,6 +163,26 @@
145163
</artifactItems>
146164
</configuration>
147165
</execution>
166+
<execution>
167+
<id>download-analyzer-for-its</id>
168+
<phase>generate-test-resources</phase>
169+
<goals>
170+
<goal>copy</goal>
171+
</goals>
172+
<configuration>
173+
<artifactItems>
174+
<artifactItem>
175+
<groupId>org.sonarsource.dotnet</groupId>
176+
<artifactId>sonar-csharp-plugin</artifactId>
177+
<version>${analyzer.version}</version>
178+
<overWrite>true</overWrite>
179+
<outputDirectory>${project.build.directory}/analyzer</outputDirectory>
180+
<!-- Use a static file name to simplify access from tests -->
181+
<destFileName>sonarcsharp.jar</destFileName>
182+
</artifactItem>
183+
</artifactItems>
184+
</configuration>
185+
</execution>
148186
</executions>
149187
</plugin>
150188
</plugins>

its/src/test/java/org/sonarsource/sonarlint/omnisharp/its/OmnisharpIntegrationTests.java

Lines changed: 590 additions & 526 deletions
Large diffs are not rendered by default.

omnisharp-plugin/pom.xml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<description>Code Analyzer based on Omnisharp</description>
1717

1818
<properties>
19-
<analyzer.version>9.32.0.97167</analyzer.version>
2019
<!-- The following properties should match https://github.com/SonarSource/sonar-dotnet/blob/master/pom.xml#L58 for the given analyzer version -->
2120
<sonar.analyzer.commons>2.12.0.2964</sonar.analyzer.commons>
2221
<sonar.version>10.10.0.2391</sonar.version>
@@ -170,9 +169,6 @@
170169
<exclude>analyzer-version.txt</exclude>
171170
</excludes>
172171
</resource>
173-
<resource>
174-
<directory>${sonarAnalyzer.directory}</directory>
175-
</resource>
176172
<resource>
177173
<directory>${servicesDll.directory}</directory>
178174
</resource>
@@ -184,7 +180,7 @@
184180
<artifactId>sonar-packaging-maven-plugin</artifactId>
185181
<configuration>
186182
<pluginName>C# Code Quality and Security (Omnisharp)</pluginName>
187-
<pluginKey>csharp</pluginKey>
183+
<pluginKey>omnisharp</pluginKey>
188184
<pluginClass>org.sonarsource.sonarlint.omnisharp.OmnisharpPlugin</pluginClass>
189185
<skipDependenciesPackaging>true</skipDependenciesPackaging>
190186
<sonarLintSupported>true</sonarLintSupported>
@@ -225,9 +221,9 @@
225221
<executions>
226222
<execution>
227223
<id>download-analyzer</id>
228-
<phase>generate-resources</phase>
224+
<phase>generate-test-resources</phase>
229225
<goals>
230-
<goal>unpack</goal>
226+
<goal>copy</goal>
231227
</goals>
232228
<configuration>
233229
<artifactItems>
@@ -236,9 +232,10 @@
236232
<artifactId>sonar-csharp-plugin</artifactId>
237233
<version>${analyzer.version}</version>
238234
<overWrite>true</overWrite>
235+
<!-- Use a static file name to simplify access from tests -->
236+
<destFileName>sonarcsharp.jar</destFileName>
239237
</artifactItem>
240238
</artifactItems>
241-
<includes>**/static/SonarAnalyzer-*.zip,**/org/sonar/plugins/csharp/*.json,**/org/sonar/plugins/csharp/*.html</includes>
242239
<outputDirectory>${sonarAnalyzer.directory}</outputDirectory>
243240
</configuration>
244241
</execution>
@@ -255,13 +252,13 @@
255252
</goals>
256253
<configuration>
257254
<outputDirectory>${servicesDll.directory}</outputDirectory>
258-
<resources>
255+
<resources>
259256
<resource>
260257
<directory>../omnisharp-dotnet/JarContentFiles</directory>
261258
<filtering>false</filtering>
262259
</resource>
263-
</resources>
264-
</configuration>
260+
</resources>
261+
</configuration>
265262
</execution>
266263
</executions>
267264
</plugin>

omnisharp-plugin/src/main/java/org/sonarsource/sonarlint/omnisharp/CSharpLanguage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ public class CSharpLanguage extends AbstractLanguage {
2828
private final Configuration configuration;
2929

3030
public CSharpLanguage(Configuration configuration) {
31-
super(OmnisharpPlugin.LANGUAGE_KEY, OmnisharpPlugin.LANGUAGE_NAME);
31+
super(OmnisharpPluginConstants.LANGUAGE_KEY, OmnisharpPluginConstants.LANGUAGE_NAME);
3232
this.configuration = configuration;
3333
}
3434

3535
@Override
3636
public String[] getFileSuffixes() {
37-
return configuration.getStringArray(OmnisharpPlugin.FILE_SUFFIXES_KEY);
37+
return configuration.getStringArray(CSharpPropertyDefinitions.FILE_SUFFIXES_KEY);
3838
}
3939

4040
@Override

omnisharp-plugin/src/main/java/org/sonarsource/sonarlint/omnisharp/CSharpPropertyDefinitions.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
import org.sonar.api.config.PropertyDefinition;
2626
import org.sonar.api.resources.Qualifiers;
2727

28-
import static org.sonarsource.sonarlint.omnisharp.OmnisharpPlugin.LANGUAGE_KEY;
28+
import static org.sonarsource.sonarlint.omnisharp.OmnisharpPluginConstants.LANGUAGE_KEY;
2929

3030
public class CSharpPropertyDefinitions {
3131

3232
private static final String PROP_PREFIX = "sonar.";
3333

34+
static final String FILE_SUFFIXES_KEY = PROP_PREFIX + OmnisharpPluginConstants.LANGUAGE_KEY + ".file.suffixes";
35+
static final String FILE_SUFFIXES_DEFVALUE = ".cs";
36+
3437
public List<PropertyDefinition> create() {
3538
List<PropertyDefinition> result = new ArrayList<>();
3639
result.add(
@@ -86,13 +89,18 @@ public List<PropertyDefinition> create() {
8689
.build());
8790
result.add(
8891
PropertyDefinition.builder(getFileSuffixProperty())
89-
.category(OmnisharpPlugin.LANGUAGE_NAME)
90-
.defaultValue(OmnisharpPlugin.FILE_SUFFIXES_DEFVALUE)
92+
.category(OmnisharpPluginConstants.LANGUAGE_NAME)
93+
.defaultValue(FILE_SUFFIXES_DEFVALUE)
9194
.name("File suffixes")
9295
.description("Comma-separated list of suffixes of files to analyze.")
9396
.multiValues(true)
9497
.onQualifiers(Qualifiers.PROJECT)
9598
.build());
99+
result.add(
100+
PropertyDefinition.builder(getAnalyzerPath())
101+
.hidden()
102+
.build()
103+
);
96104
return result;
97105
}
98106

@@ -143,4 +151,8 @@ public static String getLoadProjectsTimeout() {
143151
public static String getStartupTimeout() {
144152
return PROP_PREFIX + LANGUAGE_KEY + ".internal.startupTimeout";
145153
}
154+
155+
public static String getAnalyzerPath() {
156+
return PROP_PREFIX + LANGUAGE_KEY + ".internal.analyzerPath";
157+
}
146158
}

0 commit comments

Comments
 (0)