Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Oct 19, 2021
0 parents commit 8ac694a
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 0 deletions.
3 changes: 3 additions & 0 deletions project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/sonarqube-maven-example.iml
/.idea
/target
87 changes: 87 additions & 0 deletions project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.sonarqube.example</groupId>
<artifactId>sonarqube-maven-example</artifactId>
<version>1.0-SNAPSHOT</version>

<name>Example of basic Maven project to integrate with SonarQube</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://https://3.109.200.13:9000
</sonar.host.url>
</properties>
</profile>
<profile>
<id>coverage</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
11 changes: 11 additions & 0 deletions project/sonar-analysis
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sonar.login=admin
D sonar.password=admin
sonar.projectBaseDir=/var/lib/jenkins/workspace/jenkins-sonar/
sonar.projectKey=sonarqubetest1
sonar.projectName=project
sonar.sourceEncoding=UTF-8
sonar.language=java
sonar.sources=/var/lib/jenkins/workspace/jenkins-sonar/project/src/main
sonar.tests=/var/lib/jenkins/workspace/jenkins-sonar/project/src/test
sonar.exclusions=vendor/**,resources/**,**/*.java
sonar.host.url=http://18.117.11.83:9000/
22 changes: 22 additions & 0 deletions project/src/main/java/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Project Name : sonarqube-example
* Developer : Osanda Deshan
* Version : 1.0.0
* Date : 8/8/2019
* Time : 4:28 PM
* Description :
**/


public class HelloWorld {

public void sayHello() {
System.out.println("Hello World!");
}

public void notCovered() {
System.out.println("This method is not covered by unit tests");
}


}
21 changes: 21 additions & 0 deletions project/src/test/java/HelloWorldTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import org.junit.Test;

/**
* Project Name : sonarqube-example
* Developer : Osanda Deshan
* Version : 1.0.0
* Date : 8/9/2019
* Time : 8:59 AM
* Description :
**/


public class HelloWorldTest {

@Test
public void sayHello() {
new HelloWorld().sayHello();
}


}

0 comments on commit 8ac694a

Please sign in to comment.