Skip to content

Commit

Permalink
Issue sevntu-checkstyle#113: new sonar-checkstyle-extension-plugin pr…
Browse files Browse the repository at this point in the history
…oject was created; checks were integrated; deploy script was updated
  • Loading branch information
rdiachenko committed Oct 31, 2013
1 parent 1ff51ab commit 05e2089
Show file tree
Hide file tree
Showing 7 changed files with 704 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deploy-maven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ cd ../sevntu-checks/
mvn deploy
cd ../sevntu-checkstyle-maven-plugin/
mvn deploy
cd ../sevntu-checkstyle-sonar-plugin/
mvn install wagon:upload-single
cd ../gh-pages

#git add .
Expand Down
31 changes: 31 additions & 0 deletions sevntu-checkstyle-sonar-plugin/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
29 changes: 29 additions & 0 deletions sevntu-checkstyle-sonar-plugin/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sevntu-checkstyle-sonar-plugin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
51 changes: 51 additions & 0 deletions sevntu-checkstyle-sonar-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.github.sevntu.checkstyle</groupId>
<artifactId>sevntu-checkstyle-sonar-plugin</artifactId>
<version>1.9.0</version>
<packaging>sonar-plugin</packaging>

<name>SevNTU Checkstyle Sonar Extension Plugin</name>
<description>SevNTU Checkstyle extension plugin for Sonar</description>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>2.8</version>
</dependency>

<dependency>
<groupId>com.github.sevntu.checkstyle</groupId>
<artifactId>sevntu-checks</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.7</version>
<extensions>true</extensions>
<configuration>
<pluginClass>com.github.sevntu.checkstyle.sonar.CheckstyleExtensionPlugin</pluginClass>
<basePlugin>checkstyle</basePlugin>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<configuration>
<fromFile>${project.build.directory}/${project.build.finalName}.jar</fromFile>
<url>file://${basedir}/../gh-pages/sonar/</url>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.sevntu.checkstyle.sonar;

import java.util.Arrays;
import java.util.List;

import org.sonar.api.SonarPlugin;

public final class CheckstyleExtensionPlugin extends SonarPlugin {

@Override
public List<?> getExtensions() {
return Arrays.asList(CheckstyleExtensionRepository.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.sevntu.checkstyle.sonar;

import java.io.InputStream;
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleRepository;
import org.sonar.api.rules.XMLRuleParser;

public final class CheckstyleExtensionRepository extends RuleRepository {

private static final String REPOSITORY_KEY = "checkstyle";

private static final String REPOSITORY_NAME = "Checkstyle";

private static final String REPOSITORY_LANGUAGE = "java";

private static final String RULES_RELATIVE_FILE_PATH = "/com/github/sevntu/checkstyle/sonar/checkstyle-extensions.xml";

private XMLRuleParser xmlRuleParser;

public CheckstyleExtensionRepository(XMLRuleParser xmlRuleParser) {
super(REPOSITORY_KEY, REPOSITORY_LANGUAGE);
setName(REPOSITORY_NAME);
this.xmlRuleParser = xmlRuleParser;
}

@Override
public List<Rule> createRules() {
InputStream input = getClass().getResourceAsStream(RULES_RELATIVE_FILE_PATH);
try {
return xmlRuleParser.parse(input);

} finally {
IOUtils.closeQuietly(input);
}
}
}
Loading

0 comments on commit 05e2089

Please sign in to comment.