Skip to content
This repository was archived by the owner on May 23, 2025. It is now read-only.

Commit 4510233

Browse files
authored
Merge pull request #22 from cnescatlab/feature/update
Feature/update
2 parents 4febe95 + 747d210 commit 4510233

File tree

16 files changed

+773
-1102
lines changed

16 files changed

+773
-1102
lines changed

.project

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
</projects>
77
<buildSpec>
88
<buildCommand>
9-
<name>org.eclipse.m2e.core.maven2Builder</name>
9+
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
1010
<arguments>
1111
</arguments>
1212
</buildCommand>
1313
<buildCommand>
14-
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
1515
<arguments>
1616
</arguments>
1717
</buildCommand>
1818
<buildCommand>
19-
<name>org.eclipse.pde.ManifestBuilder</name>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
2020
<arguments>
2121
</arguments>
2222
</buildCommand>
2323
<buildCommand>
24-
<name>org.eclipse.pde.SchemaBuilder</name>
24+
<name>org.eclipse.m2e.core.maven2Builder</name>
2525
<arguments>
2626
</arguments>
2727
</buildCommand>
@@ -31,4 +31,15 @@
3131
<nature>org.eclipse.m2e.core.maven2Nature</nature>
3232
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
3333
</natures>
34+
<filteredResources>
35+
<filter>
36+
<id>1719921761317</id>
37+
<name></name>
38+
<type>30</type>
39+
<matcher>
40+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
41+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
42+
</matcher>
43+
</filter>
44+
</filteredResources>
3445
</projectDescription>

pom.xml

Lines changed: 40 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@
55
<groupId>fr.cnes.sonar.plugins.scan</groupId>
66
<artifactId>sonar-cnes-scan-plugin</artifactId>
77
<packaging>sonar-plugin</packaging>
8-
<version>1.5</version>
8+
<version>2.0</version>
99

1010
<name>SonarQube CNES Scan Plugin</name>
1111
<description>CNES plugin for SonarQube that launches analysis directly from the web interface and export reports.</description>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<sonar.apiVersion>7.9</sonar.apiVersion>
16-
<sonar.sslr-squid-bridge.version>2.6.1</sonar.sslr-squid-bridge.version>
17-
<sonar-packaging-maven-plugin.version>1.17</sonar-packaging-maven-plugin.version>
18-
<commons-lang.version>3.7</commons-lang.version>
19-
<gson.version>2.8.2</gson.version>
20-
<junit.version>4.11</junit.version>
21-
<jdk.min.version>1.8</jdk.min.version>
15+
<sonar.api.version>9.14.0.375</sonar.api.version>
16+
<sonar.addons.version>10.6.0.92116</sonar.addons.version>
17+
<commons.lang3.version>3.14.0</commons.lang3.version>
18+
<gson.version>2.11.0</gson.version>
19+
<junit.jupiter.api.version>5.11.0-M2</junit.jupiter.api.version>
20+
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
21+
<jdk.version>17</jdk.version>
2222
<pluginUrl>https://cnes.fr</pluginUrl>
2323
<pluginOrganizationName>CNES</pluginOrganizationName>
24-
<jacoco.version>0.8.4</jacoco.version>
2524
</properties>
2625

2726
<licenses>
@@ -47,71 +46,60 @@
4746
<organization>CNES</organization>
4847
<organizationUrl>https://cnes.fr/</organizationUrl>
4948
</developer>
49+
<developer>
50+
<id>Topin2001</id>
51+
<name>Topin</name>
52+
</developer>
5053
</developers>
5154

5255
<dependencies>
56+
<!-- https://mvnrepository.com/artifact/org.sonarsource.api.plugin/sonar-plugin-api -->
5357
<dependency>
54-
<groupId>org.sonarsource.sonarqube</groupId>
58+
<groupId>org.sonarsource.api.plugin</groupId>
5559
<artifactId>sonar-plugin-api</artifactId>
56-
<version>${sonar.apiVersion}</version>
60+
<version>${sonar.api.version}</version>
5761
<scope>provided</scope>
5862
</dependency>
63+
<!-- https://mvnrepository.com/artifact/org.sonarsource.sonarqube/sonar-ws -->
5964
<dependency>
6065
<groupId>org.sonarsource.sonarqube</groupId>
6166
<artifactId>sonar-ws</artifactId>
62-
<version>${sonar.apiVersion}</version>
63-
<scope>compile</scope>
67+
<version>${sonar.addons.version}</version>
68+
</dependency>
69+
<!-- https://mvnrepository.com/artifact/org.sonarsource.sonarqube/sonar-plugin-api-impl -->
70+
<dependency>
71+
<groupId>org.sonarsource.sonarqube</groupId>
72+
<artifactId>sonar-plugin-api-impl</artifactId>
73+
<version>${sonar.addons.version}</version>
74+
<scope>test</scope>
6475
</dependency>
76+
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
6577
<dependency>
66-
<!-- packaged with the plugin -->
6778
<groupId>org.apache.commons</groupId>
6879
<artifactId>commons-lang3</artifactId>
69-
<version>${commons-lang.version}</version>
80+
<version>${commons.lang3.version}</version>
7081
</dependency>
82+
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
7183
<dependency>
72-
<!-- json parsing -->
7384
<groupId>com.google.code.gson</groupId>
7485
<artifactId>gson</artifactId>
7586
<version>${gson.version}</version>
7687
</dependency>
7788

7889

7990
<!-- unit tests -->
91+
<!-- https://mvnrepository.com/artifact/org.sonarsource.sonarqube/sonar-testing-harness -->
8092
<dependency>
8193
<groupId>org.sonarsource.sonarqube</groupId>
8294
<artifactId>sonar-testing-harness</artifactId>
83-
<version>${sonar.apiVersion}</version>
95+
<version>${sonar.addons.version}</version>
8496
<scope>test</scope>
8597
</dependency>
98+
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
8699
<dependency>
87-
<groupId>org.sonarsource.sslr-squid-bridge</groupId>
88-
<artifactId>sslr-squid-bridge</artifactId>
89-
<version>${sonar.sslr-squid-bridge.version}</version>
90-
<exclusions>
91-
<exclusion>
92-
<groupId>org.codehaus.sonar</groupId>
93-
<artifactId>sonar-plugin-api</artifactId>
94-
</exclusion>
95-
<exclusion>
96-
<groupId>org.codehaus.sonar.sslr</groupId>
97-
<artifactId>sslr-core</artifactId>
98-
</exclusion>
99-
<exclusion>
100-
<groupId>org.picocontainer</groupId>
101-
<artifactId>picocontainer</artifactId>
102-
</exclusion>
103-
</exclusions>
104-
</dependency>
105-
<dependency>
106-
<groupId>junit</groupId>
107-
<artifactId>junit</artifactId>
108-
<version>${junit.version}</version>
109-
<scope>test</scope>
110-
</dependency>
111-
<dependency>
112-
<groupId>org.codehaus.sonar</groupId>
113-
<artifactId>sonar-testing-harness</artifactId>
114-
<version>4.2</version>
100+
<groupId>org.junit.jupiter</groupId>
101+
<artifactId>junit-jupiter-api</artifactId>
102+
<version>${junit.jupiter.api.version}</version>
115103
<scope>test</scope>
116104
</dependency>
117105
</dependencies>
@@ -121,7 +109,7 @@
121109
<plugin>
122110
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
123111
<artifactId>sonar-packaging-maven-plugin</artifactId>
124-
<version>${sonar-packaging-maven-plugin.version}</version>
112+
<version>1.23.0.740</version>
125113
<extensions>true</extensions>
126114
<configuration>
127115
<jarName>sonar-cnes-scan-plugin</jarName>
@@ -132,39 +120,27 @@
132120
<plugin>
133121
<groupId>org.apache.maven.plugins</groupId>
134122
<artifactId>maven-compiler-plugin</artifactId>
135-
<version>3.5.1</version>
123+
<version>3.13.0</version>
136124
<configuration>
137-
<source>${jdk.min.version}</source>
138-
<target>${jdk.min.version}</target>
125+
<source>${jdk.version}</source>
126+
<target>${jdk.version}</target>
139127
</configuration>
140128
</plugin>
141129
<plugin>
142130
<!-- UTF-8 bundles are not supported by Java, so they must be converted during build -->
143131
<groupId>org.codehaus.mojo</groupId>
144132
<artifactId>native2ascii-maven-plugin</artifactId>
145-
<version>1.0-beta-1</version>
146-
<executions>
147-
<execution>
148-
<goals>
149-
<goal>native2ascii</goal>
150-
</goals>
151-
</execution>
152-
</executions>
133+
<version>2.1.0</version>
153134
</plugin>
154-
155135
<plugin>
156136
<groupId>org.apache.maven.plugins</groupId>
157137
<artifactId>maven-project-info-reports-plugin</artifactId>
158-
<version>2.9</version>
159-
<configuration>
160-
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
161-
</configuration>
138+
<version>3.6.0</version>
162139
</plugin>
163-
164140
<plugin>
165141
<groupId>org.jacoco</groupId>
166142
<artifactId>jacoco-maven-plugin</artifactId>
167-
<version>${jacoco.version}</version>
143+
<version>${jacoco-maven-plugin.version}</version>
168144
<executions>
169145
<execution>
170146
<id>prepare-agent</id>

src/main/java/fr/cnes/sonar/plugins/scan/tasks/AbstractTask.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919

2020
import fr.cnes.sonar.plugins.scan.utils.StringManager;
2121
import org.sonar.api.server.ws.RequestHandler;
22-
import org.sonar.api.utils.log.Logger;
23-
import org.sonar.api.utils.log.Loggers;
2422

2523
import java.io.BufferedReader;
2624
import java.io.IOException;
2725
import java.io.InputStreamReader;
26+
import java.util.logging.Logger;
2827

2928
/**
3029
* Execute the scan of a project
@@ -35,7 +34,7 @@ public abstract class AbstractTask implements RequestHandler {
3534
/**
3635
* logger for all tasks
3736
*/
38-
protected static final Logger LOGGER = Loggers.get(AbstractTask.class);
37+
protected static final Logger LOGGER = Logger.getLogger(AbstractTask.class.getName());
3938

4039
/**
4140
* contain all the task's logs

src/main/java/fr/cnes/sonar/plugins/scan/tasks/AnalysisTask.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ private String analyze(final String projectName, final String projectFolder, fin
102102
projectFolder,
103103
config.get(StringManager.string(StringManager.WORKSPACE_PROP_DEF_KEY)).orElse(StringManager.string(StringManager.DEFAULT_STRING)),
104104
projectFolder);
105-
// create the temporary script to run cxx tools
106-
LOGGER.debug(analysisCommand);
107-
final File script = createScript(projectFolder, analysisCommand);
105+
final File script = createScript(projectFolder, analysisCommand);
108106

109107
// string formatted date as string
110108
final String date = new SimpleDateFormat(
@@ -129,14 +127,14 @@ private String analyze(final String projectName, final String projectFolder, fin
129127

130128
// delete temporary script
131129
if (!script.delete()) {
132-
LOGGER.error(String.format(FILE_DELETION_ERROR, script.getName()));
130+
LOGGER.severe(String.format(FILE_DELETION_ERROR, script.getName()));
133131
}
134132

135133
} catch (IOException | InterruptedException e) {
136134
// the spp file or the log file could not be written
137135
// so we log the problem and return logs
138136
log(e.getMessage());
139-
LOGGER.error(e.getMessage(), e);
137+
LOGGER.severe(e.getMessage());
140138
}
141139

142140

@@ -147,10 +145,10 @@ private String analyze(final String projectName, final String projectFolder, fin
147145
execution.get(timeout, TimeUnit.MINUTES);
148146
} catch (ExecutionException e) {
149147
log(e.getMessage());
150-
LOGGER.error(e.getMessage(), e);
148+
LOGGER.severe(e.getMessage());
151149
} catch (TimeoutException e) {
152150
log(StringManager.string(StringManager.CNES_ANALYSIS_TIMEOUT_ERROR));
153-
LOGGER.error(StringManager.string(StringManager.CNES_ANALYSIS_TIMEOUT_ERROR), e);
151+
LOGGER.severe(e.getMessage());
154152
} finally {
155153
service.shutdown();
156154
}
@@ -231,14 +229,14 @@ private File createScript(final String project, final String commandLine) {
231229
script.write("#!/bin/bash -e");
232230
script.write("\ncd "+workspace);
233231
script.write(StringManager.string(StringManager.CNES_LOG_SEPARATOR)+commandLine);
234-
LOGGER.info(commandLine);
232+
LOGGER.info("commandLine : " + commandLine);
235233
} catch (IOException e) {
236-
LOGGER.error(e.getMessage(), e);
234+
LOGGER.severe(e.getMessage());
237235
}
238236

239237
// give execution rights on the script
240238
if(!scriptOutput.setExecutable(true)) {
241-
LOGGER.error(String.format(FILE_PERMISSIONS_ERROR, scriptOutput.getName()));
239+
LOGGER.severe(String.format(FILE_PERMISSIONS_ERROR, scriptOutput.getName()));
242240
}
243241

244242
return scriptOutput;

src/main/java/fr/cnes/sonar/plugins/scan/tasks/project/ProjectTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ private Status setQualityGate(final WsClient wsClient, final String key,
348348
for (final QualityGate q : modelQGList) {
349349
// build and add a new quality gate from model
350350
qualityGateBuilder = Qualitygates.QualityGate.newBuilder();
351-
qualityGateBuilder.setId(Long.parseLong(q.getId()));
351+
qualityGateBuilder.setId(String.valueOf(Long.parseLong(q.getId())));
352352
qualityGateBuilder.setName(q.getName());
353353
qualityGates.add(qualityGateBuilder.build());
354354
}
@@ -360,7 +360,7 @@ private Status setQualityGate(final WsClient wsClient, final String key,
360360
if(qg != null) {
361361
// if we found the quality gate we link it to the project
362362
final SelectRequest selectWsRequest = new SelectRequest()
363-
.setGateId(String.valueOf(qg.getId())).setProjectKey(key);
363+
.setGateName(String.valueOf(qg.getId())).setProjectKey(key);
364364
wsClient.qualitygates().select(selectWsRequest);
365365
// setting is a success
366366
status.setSuccess(true);

src/main/java/fr/cnes/sonar/plugins/scan/web/CnesPluginPageDefinition.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,24 @@
2222
import org.sonar.api.web.page.Page.Scope;
2323
import org.sonar.api.web.page.PageDefinition;
2424

25+
import java.util.logging.Logger;
26+
2527
/**
2628
* Define web pages of the plugin
2729
* @author lequal
2830
*/
2931
public class CnesPluginPageDefinition implements PageDefinition {
3032

33+
protected static final Logger LOGGER = Logger.getLogger(CnesPluginPageDefinition.class.getName());
3134
/**
3235
* Define concretely the pages to add through the plugin
3336
* @param context Execution context of the plugin
3437
*/
3538
@Override
3639
public void define(final Context context) {
3740

41+
LOGGER.warning("Defining CNES plugin pages");
42+
3843
// create a page
3944
Page.Builder page = Page.builder(
4045
StringManager.string(StringManager.CNES_PAGE_ANALYSIS_KEY));
@@ -45,15 +50,5 @@ public void define(final Context context) {
4550
// add a new page for scan + reporting
4651
context.addPage(page.build());
4752

48-
49-
// create a page
50-
page = Page.builder(StringManager.string(StringManager.CNES_PAGE_HELP_KEY));
51-
// set its name
52-
page.setName(StringManager.string(StringManager.CNES_PAGE_HELP_NAME));
53-
// set its scope (where it is displayed)
54-
page.setScope(Scope.GLOBAL);
55-
// add a new page for help
56-
context.addPage(page.build());
57-
5853
}
5954
}

0 commit comments

Comments
 (0)