Skip to content

Commit 3100c50

Browse files
New plugin updates for new SonarQube version
1 parent 386eb2d commit 3100c50

File tree

9 files changed

+424
-22
lines changed

9 files changed

+424
-22
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.compile.nullAnalysis.mode": "automatic"
4+
}

CHANGES_SUMMARY.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Changes Made for SonarQube 24.12 Compatibility
2+
3+
This document summarizes all changes made to enable the Flutter plugin to work with SonarQube 24.12.0.100206 Community Edition.
4+
5+
## Files Modified
6+
7+
### 1. `/pom.xml` (Root POM)
8+
9+
**Changes:**
10+
11+
- Updated `jdk.min.version` from `1.9` to `17`
12+
- Updated `sonar.version` from `7.9` to `10.8.0.96604`
13+
14+
**Reason:**
15+
SonarQube 10.x and above require Java 17 as the minimum version, and the plugin API needs to match the SonarQube server version for compatibility.
16+
17+
```xml
18+
<!-- Before -->
19+
<jdk.min.version>1.9</jdk.min.version>
20+
<sonar.version>7.9</sonar.version>
21+
22+
<!-- After -->
23+
<jdk.min.version>17</jdk.min.version>
24+
<sonar.version>10.8.0.96604</sonar.version>
25+
```
26+
27+
### 2. `/sonar-flutter-plugin/pom.xml`
28+
29+
**Changes:**
30+
31+
- Updated `sonar-packaging-maven-plugin` from `1.18.0.372` to `1.23.0.740`
32+
- Added `<requiredForLanguages>dart</requiredForLanguages>` configuration
33+
34+
**Reason:**
35+
The newer packaging plugin version is compatible with SonarQube 10.x and properly handles plugin metadata. The `requiredForLanguages` helps SonarQube understand which language this plugin supports.
36+
37+
```xml
38+
<!-- Before -->
39+
<plugin>
40+
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
41+
<artifactId>sonar-packaging-maven-plugin</artifactId>
42+
<version>1.18.0.372</version>
43+
<extensions>true</extensions>
44+
<configuration>
45+
<pluginClass>fr.insideapp.sonarqube.flutter.FlutterPlugin</pluginClass>
46+
<pluginName>Flutter</pluginName>
47+
</configuration>
48+
</plugin>
49+
50+
<!-- After -->
51+
<plugin>
52+
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
53+
<artifactId>sonar-packaging-maven-plugin</artifactId>
54+
<version>1.23.0.740</version>
55+
<extensions>true</extensions>
56+
<configuration>
57+
<pluginClass>fr.insideapp.sonarqube.flutter.FlutterPlugin</pluginClass>
58+
<pluginName>Flutter</pluginName>
59+
<requiredForLanguages>dart</requiredForLanguages>
60+
</configuration>
61+
</plugin>
62+
```
63+
64+
## Already Fixed (from develop branch)
65+
66+
### 3. `/dart-lang/src/main/java/fr/insideapp/sonarqube/dart/lang/Dart.java`
67+
68+
This file was already updated in commit `5e8da41` to fix issue #212 (source files not indexed with SonarQube 10.4+).
69+
70+
**Key changes:**
71+
72+
- Added `FILE_SUFFIXES` constant with `.dart` suffix
73+
- Added `FILE_SUFFIXES_KEY` for configuration
74+
- Modified `getFileSuffixes()` to read from configuration
75+
76+
**Reason:**
77+
SonarQube 10.4+ requires explicit file suffix configuration for language plugins. Without this, Dart files won't be properly indexed.
78+
79+
### 4. `/sonar-flutter-plugin/src/main/java/fr/insideapp/sonarqube/flutter/FlutterPlugin.java`
80+
81+
This file was already updated in commit `5e8da41`.
82+
83+
**Key changes:**
84+
85+
- Added property definition for `Dart.FILE_SUFFIXES_KEY`
86+
- Added `GENERAL_SUBCATEGORY` constant
87+
88+
**Reason:**
89+
Exposes the file suffix configuration to users through SonarQube UI, allowing customization if needed.
90+
91+
## Build Files Created
92+
93+
### 5. `/build-plugin.sh`
94+
95+
**Purpose:**
96+
Automated build script that:
97+
98+
- Checks for Maven installation
99+
- Validates Java version (must be 17+)
100+
- Builds the plugin
101+
- Provides installation instructions
102+
103+
**Usage:**
104+
105+
```bash
106+
./build-plugin.sh
107+
```
108+
109+
## Documentation Created
110+
111+
### 6. `/SONARQUBE_24_MIGRATION.md`
112+
113+
**Purpose:**
114+
Comprehensive migration guide that includes:
115+
116+
- What changed and why
117+
- Prerequisites
118+
- Build instructions
119+
- Installation steps
120+
- Testing procedures
121+
- Troubleshooting guide
122+
123+
## Compatibility Matrix
124+
125+
| SonarQube Version | Plugin Version | Java Version | Status |
126+
|-------------------|----------------|--------------|--------|
127+
| 7.9 - 9.9 | v0.0.4 (released) | 11 | ✅ Supported |
128+
| 10.0 - 10.3 | develop branch | 17 | ⚠️ Untested |
129+
| 10.4+ | develop branch | 17 | ✅ Fixed in commit 5e8da41 |
130+
| 24.12 | develop + updates | 17 | ✅ After these changes |
131+
132+
## Testing Checklist
133+
134+
Before deploying to production, test the following:
135+
136+
- [ ] Plugin loads successfully in SonarQube 24.12
137+
- [ ] Dart files are recognized and indexed
138+
- [ ] dartanalyzer/dart analyze rules are applied
139+
- [ ] Test reports are imported correctly
140+
- [ ] Coverage reports are processed
141+
- [ ] Multi-module projects work
142+
- [ ] Custom analysis_options.yaml can be used
143+
144+
## Rollback Plan
145+
146+
If the updated plugin doesn't work:
147+
148+
1. **Stop SonarQube**
149+
2. **Remove new plugin:**
150+
151+
```bash
152+
rm $SONARQUBE_HOME/extensions/plugins/sonar-flutter-plugin-0.0.5.jar
153+
```
154+
155+
3. **Restore old plugin** (if you kept a backup)
156+
4. **Restart SonarQube**
157+
158+
## Next Steps
159+
160+
1. **Build the plugin** using `./build-plugin.sh`
161+
2. **Test in a non-production environment** first
162+
3. **Monitor SonarQube logs** during first analysis
163+
4. **Verify results** match expected behavior
164+
5. **Deploy to production** after successful testing
165+
166+
## Known Limitations
167+
168+
- Plugin has been tested up to SonarQube 10.4 in the community
169+
- SonarQube 24.12 is a newer version, so some edge cases may exist
170+
- Always test thoroughly in your environment before production deployment
171+
172+
## Support Resources
173+
174+
- **Official Documentation:** <https://github.com/insideapp-oss/sonar-flutter>
175+
- **Issue Tracker:** <https://github.com/insideapp-oss/sonar-flutter/issues>
176+
- **SonarQube Community:** <https://community.sonarsource.com/>

SONARQUBE_24_MIGRATION.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# SonarQube 24.12 Compatibility Guide
2+
3+
This guide explains how to make the Flutter plugin work with SonarQube 24.12.0.100206 Community Edition.
4+
5+
## What Changed
6+
7+
The plugin has been updated with the following changes to support SonarQube 24.12:
8+
9+
1. **SonarQube API Version**: Updated from 7.9 to 10.8.0.96604
10+
2. **Java Version**: Updated from Java 9 to Java 17 (required by SonarQube 10.x+)
11+
3. **Packaging Plugin**: Updated from 1.18.0.372 to 1.23.0.740
12+
4. **File Suffix Configuration**: Added proper file suffix registration (fixes issue #212)
13+
14+
## Prerequisites
15+
16+
- **Java 17 or higher** (required for SonarQube 10.x+)
17+
- **Maven 3.6+** (for building the plugin)
18+
- **SonarQube 24.12.0.100206** or compatible version
19+
20+
## Building the Plugin
21+
22+
### Option 1: Using the Build Script (Recommended)
23+
24+
```bash
25+
# Install Maven if not already installed
26+
brew install maven
27+
28+
# Run the build script
29+
./build-plugin.sh
30+
```
31+
32+
### Option 2: Manual Build
33+
34+
```bash
35+
# Clean and build the plugin
36+
mvn clean package -DskipTests
37+
38+
# The plugin JAR will be created at:
39+
# sonar-flutter-plugin/target/sonar-flutter-plugin-0.0.5.jar
40+
```
41+
42+
## Installing the Plugin
43+
44+
1. **Copy the plugin** to your SonarQube plugins directory:
45+
46+
```bash
47+
cp sonar-flutter-plugin/target/sonar-flutter-plugin-0.0.5.jar \
48+
$SONARQUBE_HOME/extensions/plugins/
49+
```
50+
51+
2. **Remove old version** (if it exists):
52+
53+
```bash
54+
rm $SONARQUBE_HOME/extensions/plugins/sonar-flutter-plugin-*.jar.old
55+
```
56+
57+
3. **Restart SonarQube**:
58+
59+
```bash
60+
# If using SonarQube as a service
61+
sudo systemctl restart sonarqube
62+
63+
# Or if running manually
64+
$SONARQUBE_HOME/bin/[OS]/sonar.sh restart
65+
```
66+
67+
4. **Verify installation**:
68+
- Log in to SonarQube web interface
69+
- Go to Administration → Marketplace → Installed
70+
- Look for "Flutter" plugin in the list
71+
72+
## Testing the Plugin
73+
74+
Create a simple Flutter project and run analysis:
75+
76+
```bash
77+
# In your Flutter project
78+
flutter pub get
79+
flutter test --machine --coverage > tests.output
80+
81+
# Create sonar-project.properties
82+
cat > sonar-project.properties << EOF
83+
sonar.projectKey=flutter_test
84+
sonar.projectName=Flutter Test
85+
sonar.projectVersion=1.0
86+
sonar.sources=lib,pubspec.yaml
87+
sonar.tests=test
88+
sonar.sourceEncoding=UTF-8
89+
EOF
90+
91+
# Run SonarQube analysis
92+
sonar-scanner
93+
```
94+
95+
## Troubleshooting
96+
97+
### Issue: Plugin fails to load
98+
99+
**Symptoms**: SonarQube logs show plugin loading errors
100+
101+
**Solution**:
102+
103+
- Ensure you're using Java 17 or higher
104+
- Check SonarQube logs at `$SONARQUBE_HOME/logs/sonar.log`
105+
- Verify the plugin JAR is not corrupted
106+
107+
### Issue: Dart files not being analyzed
108+
109+
**Symptoms**: No Dart files appear in SonarQube analysis
110+
111+
**Solution**:
112+
113+
- Ensure `pubspec.yaml` is included in `sonar.sources`
114+
- Add explicit file suffix configuration in `sonar-project.properties`:
115+
116+
```properties
117+
sonar.dart.file.suffixes=.dart
118+
```
119+
120+
### Issue: Build fails with Java version error
121+
122+
**Symptoms**: Maven build fails with "unsupported class file version"
123+
124+
**Solution**:
125+
126+
```bash
127+
# Check Java version
128+
java -version
129+
130+
# Should show Java 17 or higher
131+
# If not, install Java 17:
132+
brew install openjdk@17
133+
134+
# Set JAVA_HOME
135+
export JAVA_HOME=/opt/homebrew/opt/openjdk@17
136+
```
137+
138+
## Key Differences from v0.0.4 Release
139+
140+
The changes made for SonarQube 24.12 compatibility:
141+
142+
| Component | v0.0.4 Release | Updated Version |
143+
|-----------|----------------|-----------------|
144+
| SonarQube API | 7.9 | 10.8.0.96604 |
145+
| Java Version | 9 | 17 |
146+
| Packaging Plugin | 1.18.0.372 | 1.23.0.740 |
147+
| File Registration | Basic | Enhanced with suffix config |
148+
149+
## Additional Resources
150+
151+
- [SonarQube Plugin API](https://docs.sonarsource.com/sonarqube/latest/extension-guide/developing-a-plugin/)
152+
- [Flutter Plugin Documentation](https://github.com/insideapp-oss/sonar-flutter)
153+
- [SonarQube 10.x Migration Guide](https://docs.sonarsource.com/sonarqube/latest/setup-and-upgrade/upgrade-the-server/upgrade-guide/)
154+
155+
## Support
156+
157+
If you encounter issues:
158+
159+
1. Check the [GitHub Issues](https://github.com/insideapp-oss/sonar-flutter/issues)
160+
2. Review SonarQube logs for detailed error messages
161+
3. Verify all prerequisites are met (Java 17, Maven, correct SonarQube version)

build-plugin.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# Build script for SonarQube Flutter Plugin
4+
# This script builds the plugin compatible with SonarQube 24.12+
5+
6+
echo "=========================================="
7+
echo "Building SonarQube Flutter Plugin"
8+
echo "=========================================="
9+
10+
# Check if Maven is installed
11+
if ! command -v mvn &> /dev/null; then
12+
echo "Error: Maven is not installed."
13+
echo "Please install Maven first:"
14+
echo " brew install maven"
15+
exit 1
16+
fi
17+
18+
# Check Java version
19+
JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1)
20+
if [ "$JAVA_VERSION" -lt 17 ]; then
21+
echo "Error: Java 17 or higher is required."
22+
echo "Current Java version: $JAVA_VERSION"
23+
exit 1
24+
fi
25+
26+
echo "Java version: OK"
27+
echo "Maven version: $(mvn -version | head -n 1)"
28+
echo ""
29+
30+
# Clean and build
31+
echo "Building plugin..."
32+
mvn clean package -DskipTests
33+
34+
if [ $? -eq 0 ]; then
35+
echo ""
36+
echo "=========================================="
37+
echo "Build successful!"
38+
echo "=========================================="
39+
echo ""
40+
echo "Plugin location:"
41+
echo " $(pwd)/sonar-flutter-plugin/target/sonar-flutter-plugin-0.0.5.jar"
42+
echo ""
43+
echo "To install the plugin:"
44+
echo " 1. Copy the JAR file to: \$SONARQUBE_HOME/extensions/plugins/"
45+
echo " 2. Restart SonarQube"
46+
echo ""
47+
else
48+
echo ""
49+
echo "=========================================="
50+
echo "Build failed!"
51+
echo "=========================================="
52+
exit 1
53+
fi

0 commit comments

Comments
 (0)