Skip to content

Commit 388e1a6

Browse files
SONARJAVA-6218 Prepare a basic project in sonar-java to use for running ruling samples (#5540)
1 parent 1f730dd commit 388e1a6

8 files changed

Lines changed: 91 additions & 17 deletions

File tree

its/ruling/pom.xml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,7 @@
108108
<groupId>org.apache.maven.plugins</groupId>
109109
<artifactId>maven-surefire-plugin</artifactId>
110110
<configuration>
111-
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server</test>
112-
</configuration>
113-
</plugin>
114-
</plugins>
115-
</build>
116-
</profile>
117-
<profile>
118-
<id>only-jboss-project</id>
119-
<build>
120-
<plugins>
121-
<plugin>
122-
<groupId>org.apache.maven.plugins</groupId>
123-
<artifactId>maven-surefire-plugin</artifactId>
124-
<configuration>
125-
<test>org.sonar.java.it.JavaRulingTest#jboss_ejb3_tutorial</test>
111+
<test>!org.sonar.java.it.JavaRulingTest#sonarqube_server, !org.sonar.java.it.JavaRulingTest#vibebot</test>
126112
</configuration>
127113
</plugin>
128114
</plugins>

its/ruling/src/test/java/org/sonar/java/it/JavaRulingTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public static void prepare_quality_profiles() throws Exception {
147147
.forEach(ruleKey -> Fail.fail("Specified rule does not exist: " + ruleKey));
148148
149149
prepareDumpOldFolder();
150+
151+
Files.createDirectories(Paths.get("target", "performance"));
150152
}
151153
152154
@AfterClass
@@ -361,6 +363,19 @@ public void regex_examples() throws IOException {
361363
executeBuildWithCommonProperties(build, projectName);
362364
}
363365
366+
/**
367+
* Vibe-bot runs this test when testing samples; so it's excluded from the GitHub Actions workflow.
368+
*/
369+
@Test
370+
public void vibebot() throws IOException {
371+
String projectName = "vibebot";
372+
File pomFile = FileLocation.of("../vibebot/pom.xml").getFile().getCanonicalFile();
373+
prepareProject("org.vibebot:vibebot", projectName);
374+
MavenBuild build = MavenBuild.create().setPom(pomFile).setCleanPackageSonarGoals().addArgument("-DskipTests");
375+
build.setProperty("sonar.projectKey", "org.vibebot:vibebot");
376+
executeBuildWithCommonProperties(build, projectName);
377+
}
378+
364379
private static MavenBuild test_project(String projectKey, String projectName) throws IOException {
365380
return test_project(projectKey, null, projectName);
366381
}
@@ -377,7 +392,6 @@ private static MavenBuild test_project(String projectKey, @Nullable String path,
377392
private static MavenBuild test_existing_project(String projectKey, String projectName) throws IOException {
378393
String pomLocation = "../sources/" + projectName + "/pom.xml";
379394
File pomFile = FileLocation.of(pomLocation).getFile().getCanonicalFile();
380-
//prepareProject(projectKey, projectName);
381395
MavenBuild mavenBuild = MavenBuild.create().setPom(pomFile).setCleanPackageSonarGoals().addArgument("-DskipTests");
382396
mavenBuild.setProperty("sonar.projectKey", projectKey);
383397
return mavenBuild;
@@ -400,7 +414,8 @@ private static void executeBuildWithCommonProperties(Build<?> build, String proj
400414
build.setProperty("sonar.scanner.skipJreProvisioning", "true");
401415
build.setProperty("sonar.cpd.exclusions", "**/*")
402416
.setProperty("sonar.java.performance.measure", "true")
403-
.setProperty("sonar.java.performance.measure.path", "target/performance/sonar.java.performance.measure.json")
417+
.setProperty("sonar.java.performance.measure.path",
418+
Paths.get("target/performance/sonar.java.performance.measure.json").toAbsolutePath().toString())
404419
.setProperty("sonar.import_unknown_files", "true")
405420
.setProperty("sonar.skipPackageDesign", "true")
406421
.setProperty("sonar.lits.dump.old", effectiveDumpOldFolder.resolve(projectName).toString())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"org.vibebot:vibebot:src/main/java/org/vibebot/App.java": [
3+
7,
4+
10
5+
]
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"org.vibebot:vibebot": [
3+
0
4+
]
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"org.vibebot:vibebot:src/main/java/org/vibebot/App.java": [
3+
0
4+
]
5+
}

its/vibebot/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>org.vibebot</groupId>
7+
<artifactId>vibebot</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<name>Vibebot</name>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<maven.compiler.release>21</maven.compiler.release>
14+
</properties>
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.slf4j</groupId>
18+
<artifactId>slf4j-api</artifactId>
19+
<version>1.7.30</version>
20+
</dependency>
21+
</dependencies>
22+
<build>
23+
<pluginManagement>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.apache.maven.plugins</groupId>
27+
<artifactId>maven-compiler-plugin</artifactId>
28+
<version>3.13.0</version>
29+
<configuration>
30+
<source>21</source>
31+
<target>21</target>
32+
<release>21</release>
33+
</configuration>
34+
</plugin>
35+
</plugins>
36+
</pluginManagement>
37+
</build>
38+
39+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sonar.projectKey=org.vibebot:vibebot
2+
sonar.projectName=vibebot
3+
sonar.projectVersion=1.0-SNAPSHOT
4+
5+
sonar.sources=src/main/java
6+
sonar.java.source=21
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.vibebot;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
6+
public class App {
7+
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
8+
9+
public static void main(String[] args) {
10+
LOGGER.info("Hello Nigel!");
11+
}
12+
}

0 commit comments

Comments
 (0)