aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElena Vilchik2018-06-12 13:34:33 +0200
committerGitHub2018-06-12 13:34:33 +0200
commitfb56fdc0dc18d277ccfae2cdb948e9da367377ea (patch)
treeabf9f112d0249d97bac25123f30bdb6188164401
parent6cebcca87c5d276627fe22b9c53ddeb4844894b6 (diff)
downloadsonar-css-fb56fdc0dc18d277ccfae2cdb948e9da367377ea.tar.bz2
Create CSS language and set up trivial ITs (#39)
-rw-r--r--Jenkinsfile127
-rw-r--r--its/plugin/pom.xml88
-rw-r--r--its/plugin/projects/css-plugin-test-project/src/file1.css7
-rw-r--r--its/plugin/projects/css-plugin-test-project/src/file2.less8
-rw-r--r--its/plugin/projects/css-plugin-test-project/src/file3.scss9
-rw-r--r--its/plugin/projects/css-plugin-test-project/src/file4.html10
-rw-r--r--its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java47
-rw-r--r--its/plugin/src/test/java/org/sonar/css/its/Tests.java91
-rw-r--r--its/pom.xml20
-rw-r--r--pom.xml19
-rw-r--r--sonar-css-plugin/pom.xml4
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssLanguage.java41
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssPlugin.java20
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/SonarWayProfile.java35
-rw-r--r--sonar-css-plugin/src/main/java/org/sonar/css/plugin/package-info.java21
-rw-r--r--sonar-css-plugin/src/test/java/org/sonar/css/plugin/CssPluginTest.java42
16 files changed, 567 insertions, 22 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..0503600
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,127 @@
+@Library('SonarSource@1.11') _
+
+pipeline {
+ agent {
+ label 'linux'
+ }
+ parameters {
+ string(name: 'GIT_SHA1', description: 'Git SHA1 (provided by travisci hook job)')
+ string(name: 'CI_BUILD_NAME', defaultValue: 'sonar-css', description: 'Build Name (provided by travisci hook job)')
+ string(name: 'CI_BUILD_NUMBER', description: 'Build Number (provided by travisci hook job)')
+ string(name: 'GITHUB_BRANCH', defaultValue: 'master', description: 'Git branch (provided by travisci hook job)')
+ string(name: 'GITHUB_REPOSITORY_OWNER', defaultValue: 'SonarSource', description: 'Github repository owner(provided by travisci hook job)')
+ }
+ environment {
+ SONARSOURCE_QA = 'true'
+ MAVEN_TOOL = 'Maven 3.3.x'
+ }
+ stages {
+ stage('Notify') {
+ steps {
+ sendAllNotificationQaStarted()
+ }
+ }
+ stage('QA') {
+ parallel {
+ stage('ITs-lts') {
+ agent {
+ label 'linux'
+ }
+ steps {
+ runITs "LATEST_RELEASE[6.7]"
+ }
+ }
+
+ stage('ITs-latest') {
+ agent {
+ label 'linux'
+ }
+ steps {
+ runITs "LATEST_RELEASE"
+ }
+ }
+
+ stage('ITs-windows') {
+ agent {
+ label 'windows'
+ }
+ steps {
+ runITsWindows "LATEST_RELEASE"
+ }
+ }
+
+ stage('ITs-dev') {
+ agent {
+ label 'linux'
+ }
+ steps {
+ runITs "DEV"
+ }
+ }
+
+ stage('CI-windows') {
+ agent {
+ label 'windows'
+ }
+ steps {
+ withMaven(maven: MAVEN_TOOL) {
+ sh 'mvn.cmd clean test'
+ }
+ }
+ }
+ }
+ post {
+ always {
+ sendAllNotificationQaResult()
+ }
+ }
+ }
+ stage('Promote') {
+ steps {
+ repoxPromoteBuild()
+ }
+ post {
+ always {
+ sendAllNotificationPromote()
+ }
+ }
+ }
+ }
+}
+
+def runITs(String sqRuntimeVersion) {
+ withQAEnv {
+ withMaven(maven: MAVEN_TOOL) {
+ mavenSetBuildVersion()
+ dir('its') {
+ sh "mvn ${itBuildArguments sqRuntimeVersion}"
+ }
+ }
+ }
+}
+
+def runITsWindows(String sqRuntimeVersion) {
+ withQAEnv {
+ withMaven(maven: MAVEN_TOOL) {
+ mavenSetBuildVersion()
+ dir('its') {
+ sh "mvn.cmd ${itBuildArguments sqRuntimeVersion}"
+ }
+ }
+ }
+}
+
+def withQAEnv(def body) {
+ checkout scm
+ withCredentials([string(credentialsId: 'ARTIFACTORY_PRIVATE_API_KEY', variable: 'ARTIFACTORY_PRIVATE_API_KEY'),
+ usernamePassword(credentialsId: 'ARTIFACTORY_PRIVATE_USER', passwordVariable: 'ARTIFACTORY_PRIVATE_PASSWORD', usernameVariable: 'ARTIFACTORY_PRIVATE_USERNAME')]) {
+ wrap([$class: 'Xvfb']) {
+ body.call()
+ }
+ }
+}
+
+String itBuildArguments(String sqRuntimeVersion) {
+ "-Pits -Dsonar.runtimeVersion=${sqRuntimeVersion} -Dorchestrator.artifactory.apiKey=${env.ARTIFACTORY_PRIVATE_API_KEY} " +
+ "-Dorchestrator.configUrl=http://infra.internal.sonarsource.com/jenkins/orch-h2.properties -Dmaven.test.redirectTestOutputToFile=false clean verify -e -V"
+}
diff --git a/its/plugin/pom.xml b/its/plugin/pom.xml
new file mode 100644
index 0000000..24aa42c
--- /dev/null
+++ b/its/plugin/pom.xml
@@ -0,0 +1,88 @@
+<?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">
+ <parent>
+ <artifactId>its</artifactId>
+ <groupId>org.sonarsource.css</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>plugin</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.orchestrator</groupId>
+ <artifactId>sonar-orchestrator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-ws</artifactId>
+ <version>${sonar.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/Tests.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>qa</id>
+ <activation>
+ <property>
+ <name>env.SONARSOURCE_QA</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.10</version>
+ <executions>
+ <execution>
+ <id>copy-plugin</id>
+ <phase>generate-test-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sonar-css-plugin</artifactId>
+ <version>${project.version}</version>
+ <type>sonar-plugin</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>../../sonar-css-plugin/target</outputDirectory>
+ <overWriteReleases>true</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/its/plugin/projects/css-plugin-test-project/src/file1.css b/its/plugin/projects/css-plugin-test-project/src/file1.css
new file mode 100644
index 0000000..41bf526
--- /dev/null
+++ b/its/plugin/projects/css-plugin-test-project/src/file1.css
@@ -0,0 +1,7 @@
+.class1 {
+ background-color: #2d5e8b;
+}
+.class1 .class2 {
+ background-color: #fff;
+ color: #2d5e8b;
+}
diff --git a/its/plugin/projects/css-plugin-test-project/src/file2.less b/its/plugin/projects/css-plugin-test-project/src/file2.less
new file mode 100644
index 0000000..e7396a3
--- /dev/null
+++ b/its/plugin/projects/css-plugin-test-project/src/file2.less
@@ -0,0 +1,8 @@
+@color-base: #2d5e8b;
+.class1 {
+ background-color: @color-base;
+ .class2 {
+ background-color: #fff;
+ color: @color-base;
+ }
+}
diff --git a/its/plugin/projects/css-plugin-test-project/src/file3.scss b/its/plugin/projects/css-plugin-test-project/src/file3.scss
new file mode 100644
index 0000000..c53e600
--- /dev/null
+++ b/its/plugin/projects/css-plugin-test-project/src/file3.scss
@@ -0,0 +1,9 @@
+$firstValue: 62.5%;
+
+$firstValue: 24px !default;
+
+body {
+ font-size: $firstValue;
+}
+
+// body font size = 62.5%
diff --git a/its/plugin/projects/css-plugin-test-project/src/file4.html b/its/plugin/projects/css-plugin-test-project/src/file4.html
new file mode 100644
index 0000000..499a20b
--- /dev/null
+++ b/its/plugin/projects/css-plugin-test-project/src/file4.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>Example</title>
+<style>
+p {
+ font-size: 5vw;
+ padding: 0 5vw;
+ line-height: 1.8em;
+ }
+</style>
+<p>Hello World!</p>
diff --git a/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java b/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java
new file mode 100644
index 0000000..232e955
--- /dev/null
+++ b/its/plugin/src/test/java/org/sonar/css/its/MetricsTest.java
@@ -0,0 +1,47 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.css.its;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.css.its.Tests.getProjectMeasureAsDouble;
+
+public class MetricsTest {
+
+ private static String PROJECT_KEY = "css-plugin-test-project";
+
+ @ClassRule
+ public static Orchestrator orchestrator = Tests.ORCHESTRATOR;
+
+ @BeforeClass
+ public static void prepare() {
+ orchestrator.executeBuild(Tests.createScanner(PROJECT_KEY));
+ }
+
+ @Test
+ public void test() {
+ assertThat(getProjectMeasureAsDouble("lines", PROJECT_KEY)).isEqualTo(27);
+ }
+
+}
diff --git a/its/plugin/src/test/java/org/sonar/css/its/Tests.java b/its/plugin/src/test/java/org/sonar/css/its/Tests.java
new file mode 100644
index 0000000..4e38073
--- /dev/null
+++ b/its/plugin/src/test/java/org/sonar/css/its/Tests.java
@@ -0,0 +1,91 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.css.its;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.OrchestratorBuilder;
+import com.sonar.orchestrator.build.SonarScanner;
+import com.sonar.orchestrator.locator.FileLocation;
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.sonarqube.ws.Measures.ComponentWsResponse;
+import org.sonarqube.ws.Measures.Measure;
+import org.sonarqube.ws.client.HttpConnector;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.WsClientFactories;
+import org.sonarqube.ws.client.measures.ComponentRequest;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ MetricsTest.class
+})
+public class Tests {
+
+ private static final FileLocation PLUGIN_LOCATION = FileLocation.byWildcardMavenFilename(
+ new File("../../sonar-css-plugin/target"), "sonar-css-plugin-*.jar");
+
+ @ClassRule
+ public static final Orchestrator ORCHESTRATOR;
+
+ static {
+ String defaultRuntimeVersion = "true".equals(System.getenv("SONARSOURCE_QA")) ? null : "7.2.0.13185"; // TODO LATEST_RELEASE[7.2]
+ String sqVersion = System.getProperty("sonar.runtimeVersion", defaultRuntimeVersion);
+ OrchestratorBuilder orchestratorBuilder = Orchestrator.builderEnv()
+ .addPlugin(PLUGIN_LOCATION)
+ .setSonarVersion(sqVersion);
+ ORCHESTRATOR = orchestratorBuilder.build();
+ }
+
+ public static WsClient newWsClient() {
+ return WsClientFactories.getDefault().newClient(HttpConnector.newBuilder()
+ .url(ORCHESTRATOR.getServer().getUrl())
+ .build());
+ }
+
+ public static Double getProjectMeasureAsDouble(String metricKey, String projectKey) {
+ Measure measure = getMeasure(metricKey, projectKey);
+ return (measure == null) ? null : Double.parseDouble(measure.getValue());
+ }
+
+ private static Measure getMeasure(String metricKey, String projectKey) {
+ ComponentWsResponse response = newWsClient().measures().component(new ComponentRequest()
+ .setComponent(projectKey)
+ .setMetricKeys(Collections.singletonList(metricKey)));
+ List<Measure> measures = response.getComponent().getMeasuresList();
+ return measures.size() == 1 ? measures.get(0) : null;
+ }
+
+ public static SonarScanner createScanner(String projectKey) {
+ File projectDir = FileLocation.of("projects" + File.separator + projectKey).getFile();
+
+ return SonarScanner.create()
+ .setSourceEncoding("UTF-8")
+ .setProjectDir(projectDir)
+ .setProjectKey(projectKey)
+ .setProjectName(projectKey)
+ .setProjectVersion("1.0")
+ .setSourceDirs("src");
+ }
+
+}
diff --git a/its/pom.xml b/its/pom.xml
new file mode 100644
index 0000000..f99378c
--- /dev/null
+++ b/its/pom.xml
@@ -0,0 +1,20 @@
+<?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">
+ <parent>
+ <artifactId>css</artifactId>
+ <groupId>org.sonarsource.css</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>its</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>plugin</module>
+ </modules>
+
+</project>
diff --git a/pom.xml b/pom.xml
index a5e5901..fd3b478 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
<slf4j.version>1.7.25</slf4j.version>
<assertj.version>3.10.0</assertj.version>
<junit.version>4.12</junit.version>
- <sonar.version>7.2.0.11647</sonar.version>
+ <sonar.version>7.2.0.13185</sonar.version>
<sonar.min.version>6.7</sonar.min.version>
<sonar-orchestrator.version>3.17.0.1491</sonar-orchestrator.version>
<sonarlint.version>3.1.0.1376</sonarlint.version>
@@ -101,12 +101,6 @@
<!-- Test dependencies -->
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guava.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
@@ -119,12 +113,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>sonar-testing-harness</artifactId>
- <version>${sonar.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
<version>${sonar-orchestrator.version}</version>
@@ -166,9 +154,6 @@
</dependencies>
</dependencyManagement>
- <!--
- TODO: enable when ITs are added
-
<profiles>
<profile>
<id>its</id>
@@ -177,6 +162,4 @@
</modules>
</profile>
</profiles>
- -->
-
</project>
diff --git a/sonar-css-plugin/pom.xml b/sonar-css-plugin/pom.xml
index 26e8477..0ceb4b0 100644
--- a/sonar-css-plugin/pom.xml
+++ b/sonar-css-plugin/pom.xml
@@ -37,10 +37,6 @@
<artifactId>sonar-analyzer-commons</artifactId>
</dependency>
<dependency>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>sonar-testing-harness</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssLanguage.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssLanguage.java
new file mode 100644
index 0000000..be5e431
--- /dev/null
+++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssLanguage.java
@@ -0,0 +1,41 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.css.plugin;
+
+import org.sonar.api.config.Configuration;
+import org.sonar.api.resources.AbstractLanguage;
+
+public class CssLanguage extends AbstractLanguage {
+
+ public static final String KEY = "css";
+
+ private Configuration configuration;
+
+ public CssLanguage(Configuration configuration) {
+ super(KEY, "CSS");
+ this.configuration = configuration;
+ }
+
+ @Override
+ public String[] getFileSuffixes() {
+ return configuration.getStringArray(CssPlugin.FILE_SUFFIXES_KEY);
+ }
+
+}
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssPlugin.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssPlugin.java
index 8d2a12b..07b4feb 100644
--- a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssPlugin.java
+++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/CssPlugin.java
@@ -20,12 +20,32 @@
package org.sonar.css.plugin;
import org.sonar.api.Plugin;
+import org.sonar.api.config.PropertyDefinition;
+import org.sonar.api.resources.Qualifiers;
public class CssPlugin implements Plugin {
+ static final String FILE_SUFFIXES_KEY = "sonar.css.file.suffixes";
+ public static final String FILE_SUFFIXES_DEFVALUE = ".css,.less,.scss";
+
+ private static final String CSS_CATEGORY = "CSS";
+ private static final String GENERAL_SUBCATEGORY = "General";
@Override
public void define(Context context) {
+ context.addExtensions(
+ CssLanguage.class,
+ SonarWayProfile.class,
+ PropertyDefinition.builder(FILE_SUFFIXES_KEY)
+ .defaultValue(FILE_SUFFIXES_DEFVALUE)
+ .name("File Suffixes")
+ .description("List of suffixes for files to analyze.")
+ .subCategory(GENERAL_SUBCATEGORY)
+ .category(CSS_CATEGORY)
+ .onQualifiers(Qualifiers.PROJECT)
+ .multiValues(true)
+ .build()
+ );
}
}
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/SonarWayProfile.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/SonarWayProfile.java
new file mode 100644
index 0000000..a54de22
--- /dev/null
+++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/SonarWayProfile.java
@@ -0,0 +1,35 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.css.plugin;
+
+import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
+
+public class SonarWayProfile implements BuiltInQualityProfilesDefinition {
+
+ public static final String PROFILE_NAME = "Sonar way";
+// private static final String PROFILE_PATH = "org/sonar/l10n/css/rules/css/Sonar_way_profile.json";
+
+ @Override
+ public void define(Context context) {
+
+ NewBuiltInQualityProfile profile = context.createBuiltInQualityProfile(PROFILE_NAME, CssLanguage.KEY);
+ profile.done();
+ }
+}
diff --git a/sonar-css-plugin/src/main/java/org/sonar/css/plugin/package-info.java b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/package-info.java
new file mode 100644
index 0000000..a7efac0
--- /dev/null
+++ b/sonar-css-plugin/src/main/java/org/sonar/css/plugin/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@javax.annotation.ParametersAreNonnullByDefault
+package org.sonar.css.plugin;
diff --git a/sonar-css-plugin/src/test/java/org/sonar/css/plugin/CssPluginTest.java b/sonar-css-plugin/src/test/java/org/sonar/css/plugin/CssPluginTest.java
new file mode 100644
index 0000000..3da86ca
--- /dev/null
+++ b/sonar-css-plugin/src/test/java/org/sonar/css/plugin/CssPluginTest.java
@@ -0,0 +1,42 @@
+/*
+ * SonarCSS
+ * Copyright (C) 2018-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.css.plugin;
+
+import org.junit.Test;
+import org.sonar.api.Plugin;
+import org.sonar.api.SonarQubeSide;
+import org.sonar.api.SonarRuntime;
+import org.sonar.api.internal.SonarRuntimeImpl;
+import org.sonar.api.utils.Version;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class CssPluginTest {
+
+ @Test
+ public void count_extensions() throws Exception {
+ SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 7), SonarQubeSide.SCANNER);
+ Plugin.Context context = new Plugin.Context(runtime);
+ Plugin underTest = new CssPlugin();
+ underTest.define(context);
+ assertThat(context.getExtensions()).hasSize(3);
+ }
+}