Skip to content

Commit 9cdeb50

Browse files
committed
Issue #384: update to sonarqube 8.9 LTS
1 parent d6cd50f commit 9cdeb50

File tree

9 files changed

+56
-25
lines changed

9 files changed

+56
-25
lines changed

.ci/ci.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ install)
99
;;
1010

1111
integration-tests)
12-
SONAR_APP_VERSION="7.9.2"
12+
SONAR_APP_VERSION="8.9.3.48735"
1313
if [[ ! -f ~/.m2/sonar-application-$SONAR_APP_VERSION.zip ]]; then
1414
URL="https://repox.jfrog.io/repox/sonarsource/org/sonarsource/sonarqube/"
1515
URL=$URL"sonar-application/$SONAR_APP_VERSION/sonar-application-$SONAR_APP_VERSION.zip"
1616
wget $URL -O ~/.m2/sonar-application-$SONAR_APP_VERSION.zip
1717
fi
18-
mkdir -p target/temp-downloads && cp ~/.m2/sonar-application-$SONAR_APP_VERSION.zip target/temp-downloads/
18+
mkdir -p target/temp-downloads
19+
cp ~/.m2/sonar-application-$SONAR_APP_VERSION.zip target/temp-downloads/
1920
mvn -e integration-test -DskipITs=false
2021
;;
2122

pom.xml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494

9595
<properties>
9696
<checkstyle.version>8.45.1</checkstyle.version>
97-
<sonar.version>7.9</sonar.version>
98-
<sonar-java.version>6.0.0.20538</sonar-java.version>
97+
<sonar.version>8.9.3.48735</sonar.version>
98+
<sonar-java.version>7.2.0.26923</sonar-java.version>
9999
<maven.checkstyle.plugin.version>3.1.2</maven.checkstyle.plugin.version>
100100
<maven.sevntu.checkstyle.plugin.version>1.40.0</maven.sevntu.checkstyle.plugin.version>
101101
<!-- it should be a version of checkstyle that is compatible/compiled with sevntu -->
@@ -168,6 +168,12 @@
168168
<version>${sonar.version}</version>
169169
<scope>provided</scope>
170170
</dependency>
171+
<dependency>
172+
<groupId>org.sonarsource.sonarqube</groupId>
173+
<artifactId>sonar-plugin-api-impl</artifactId>
174+
<version>${sonar.version}</version>
175+
<scope>test</scope>
176+
</dependency>
171177
<dependency>
172178
<groupId>xmlunit</groupId>
173179
<artifactId>xmlunit</artifactId>
@@ -250,6 +256,12 @@
250256
<scope>test</scope>
251257
<version>1.4</version>
252258
</dependency>
259+
<dependency>
260+
<groupId>org.assertj</groupId>
261+
<artifactId>assertj-core</artifactId>
262+
<version>3.19.0</version>
263+
<scope>test</scope>
264+
</dependency>
253265
<dependency>
254266
<groupId>org.apache.ant</groupId>
255267
<artifactId>ant</artifactId>
@@ -833,7 +845,7 @@
833845
<plugin>
834846
<groupId>org.codehaus.mojo</groupId>
835847
<artifactId>sonar-maven-plugin</artifactId>
836-
<version>3.7.0.1746</version>
848+
<version>3.9.0.2155</version>
837849
</plugin>
838850
</plugins>
839851
</build>

src/it/java/org/checkstyle/plugins/sonar/CheckJarTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
import org.junit.Test;
3434

3535
public class CheckJarTest {
36-
private static final String MATCHER = ".*checkstyle-sonar-plugin-\\d+\\.\\d+(-SNAPSHOT)?\\.jar";
36+
private static final String MATCHER = ".*checkstyle-sonar-plugin-"
37+
+ "\\d+\\.\\d+(.\\d+)?(-SNAPSHOT)?\\.jar";
3738

3839
@Test
3940
public void testJarPresence() throws IOException {

src/it/java/org/checkstyle/plugins/sonar/RunPluginTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
*/
6262
public class RunPluginTest {
6363
private static final Logger LOG = LoggerFactory.getLogger(RunPluginTest.class);
64-
private static final String SONAR_APP_VERSION = "7.9.2";
64+
private static final String SONAR_APP_VERSION = "8.9.3.48735";
6565
private static final int LOGS_NUMBER_LINES = 200;
6666
private static final String TRUE = "true";
6767
private static final String PROJECT_KEY = "com.puppycrows.tools:checkstyle";
@@ -91,9 +91,6 @@ public static void beforeAll() {
9191
.addPlugin(MavenLocation.of("org.sonarsource.sonar-lits-plugin",
9292
"sonar-lits-plugin",
9393
"0.8.0.1209"))
94-
.addPlugin(MavenLocation.of("org.sonarsource.java",
95-
"sonar-java-plugin",
96-
"6.0.0.20538"))
9794
.setServerProperty("sonar.web.javaOpts", "-Xmx1G")
9895
.build();
9996

src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
import java.util.Arrays;
2323
import java.util.List;
2424

25-
import org.sonar.api.CoreProperties;
25+
import org.sonar.api.Plugin;
2626
import org.sonar.api.PropertyType;
27-
import org.sonar.api.SonarPlugin;
2827
import org.sonar.api.config.PropertyDefinition;
2928
import org.sonar.api.resources.Qualifiers;
3029

31-
public final class CheckstylePlugin extends SonarPlugin {
32-
30+
public final class CheckstylePlugin implements Plugin {
31+
private static final String CHECKSTYLE_CATEGORY_NAME = "java";
3332
private static final String CHECKSTYLE_SUB_CATEGORY_NAME = "Checkstyle";
3433

3534
private static final String DESCRIPTION_HEADER = "Checkstyle supports";
@@ -68,35 +67,34 @@ public final class CheckstylePlugin extends SonarPlugin {
6867
+ "configuration for more information.";
6968

7069
@SuppressWarnings("rawtypes")
71-
@Override
7270
public List getExtensions() {
7371
return Arrays
7472
.asList(PropertyDefinition.builder(CheckstyleConstants.CHECKER_FILTERS_KEY)
7573
.defaultValue(CheckstyleConstants.CHECKER_FILTERS_DEFAULT_VALUE)
76-
.category(CoreProperties.CATEGORY_JAVA)
74+
.category(CHECKSTYLE_CATEGORY_NAME)
7775
.subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
7876
.name("Checker Filters")
7977
.description(CHECKER_FILTERS_DESCRIPTION)
8078
.type(PropertyType.TEXT)
8179
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
8280
PropertyDefinition.builder(CheckstyleConstants.TREEWALKER_FILTERS_KEY)
8381
.defaultValue(CheckstyleConstants.TREEWALKER_FILTERS_DEFAULT_VALUE)
84-
.category(CoreProperties.CATEGORY_JAVA)
82+
.category(CHECKSTYLE_CATEGORY_NAME)
8583
.subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
8684
.name("Treewalker Filters")
8785
.description(TREEWALKER_FILTERS_DESCRIPTION)
8886
.type(PropertyType.TEXT)
8987
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(),
9088
PropertyDefinition.builder(CheckstyleConstants.CHECKER_TAB_WIDTH)
91-
.category(CoreProperties.CATEGORY_JAVA)
89+
.category(CHECKSTYLE_CATEGORY_NAME)
9290
.subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
9391
.name("Tab Width")
9492
.description(CHECKER_TAB_WIDTH_DESCRIPTION)
9593
.type(PropertyType.INTEGER)
9694
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
9795
.build(),
9896
PropertyDefinition.builder(CheckstyleConfiguration.PROPERTY_GENERATE_XML)
99-
.defaultValue("false").category(CoreProperties.CATEGORY_JAVA)
97+
.defaultValue("false").category(CHECKSTYLE_CATEGORY_NAME)
10098
.subCategory(CHECKSTYLE_SUB_CATEGORY_NAME)
10199
.name("Generate XML Report").type(PropertyType.BOOLEAN).hidden()
102100
.build(),
@@ -107,4 +105,8 @@ public List getExtensions() {
107105
CheckstyleRulesDefinition.class);
108106
}
109107

108+
@Override
109+
public void define(final Context context) {
110+
context.addExtensions(getExtensions());
111+
}
110112
}

src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.sonar.api.config.internal.MapSettings;
4444
import org.sonar.api.profiles.RulesProfile;
4545
import org.sonar.api.rules.Rule;
46+
import org.sonar.api.utils.System2;
4647

4748
import com.puppycrawl.tools.checkstyle.api.Configuration;
4849

@@ -123,7 +124,7 @@ public void writeConfigurationToWorkingDir() throws IOException {
123124
public void getCheckstyleConfiguration() throws Exception {
124125
fileSystem.setEncoding(StandardCharsets.UTF_8);
125126
final MapSettings mapSettings = new MapSettings(new PropertyDefinitions(
126-
new CheckstylePlugin().getExtensions()));
127+
System2.INSTANCE, new CheckstylePlugin().getExtensions()));
127128
mapSettings.setProperty(CheckstyleConstants.CHECKER_FILTERS_KEY,
128129
CheckstyleConstants.CHECKER_FILTERS_DEFAULT_VALUE);
129130
final org.sonar.api.config.Configuration settings = new ConfigurationBridge(mapSettings);

src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020
package org.sonar.plugins.checkstyle;
2121

2222
import static org.fest.assertions.Assertions.assertThat;
23+
import static org.mockito.ArgumentMatchers.anyList;
24+
import static org.mockito.Mockito.mock;
25+
import static org.mockito.Mockito.times;
26+
import static org.mockito.Mockito.verify;
2327

2428
import org.junit.Test;
29+
import org.sonar.api.Plugin;
2530

2631
public class CheckstylePluginTest {
2732

@@ -31,4 +36,13 @@ public void testGetExtensions() {
3136
assertThat(plugin.getExtensions().size()).isGreaterThan(1);
3237
}
3338

39+
@Test
40+
public void testDefine() {
41+
final Plugin.Context context = mock(Plugin.Context.class);
42+
43+
final CheckstylePlugin plugin = new CheckstylePlugin();
44+
plugin.define(context);
45+
verify(context, times(1)).addExtensions(anyList());
46+
}
47+
3448
}

src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.sonar.api.rule.RuleKey;
4949
import org.sonar.api.rules.Rule;
5050
import org.sonar.api.rules.RulePriority;
51+
import org.sonar.api.utils.System2;
5152

5253
public class CheckstyleProfileExporterTest {
5354

@@ -253,7 +254,7 @@ public void addTabWidthProperty() {
253254
@SuppressWarnings("unchecked")
254255
private void initSettings(@Nullable String key, @Nullable String property) {
255256
final MapSettings mapSettings = new MapSettings(
256-
new PropertyDefinitions(new CheckstylePlugin().getExtensions()));
257+
new PropertyDefinitions(System2.INSTANCE, new CheckstylePlugin().getExtensions()));
257258
if (Objects.nonNull(key)) {
258259
mapSettings.setProperty(key, property);
259260
}

test-resources/docker-compose.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ version: "3"
33

44
services:
55
sonarqube:
6-
image: sonarqube:7.9-community
6+
image: sonarqube:8.9.3-community
77
# next line is for arm64 devices when testing since SQ does not officially release multi-arch images
8-
#image: mwizner/sonarqube:8.7.1-community
8+
#image: stevefan1999/sonarqube:9.0.1-community
99
restart: unless-stopped
1010
depends_on:
1111
- db
@@ -16,10 +16,11 @@ services:
1616
SONAR_JDBC_USERNAME: sonar
1717
SONAR_JDBC_PASSWORD: sonar
1818
volumes:
19+
- sonarqube_conf:/opt/sonarqube/conf
1920
- sonarqube_data:/opt/sonarqube/data
2021
- ./tmp/extensions/:/opt/sonarqube/extensions
22+
- sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
2123
- sonarqube_logs:/opt/sonarqube/logs
22-
- sonarqube_temp:/opt/sonarqube/temp
2324
db:
2425
image: postgres
2526
restart: unless-stopped
@@ -31,8 +32,9 @@ services:
3132
- postgresql_data:/var/lib/postgresql/data
3233

3334
volumes:
35+
sonarqube_conf:
3436
sonarqube_data:
3537
sonarqube_logs:
36-
sonarqube_temp:
38+
sonarqube_bundled-plugins:
3739
postgresql:
3840
postgresql_data:

0 commit comments

Comments
 (0)