Skip to content

Commit

Permalink
Support Checkstyle 8.0 (major breaking change),
Browse files Browse the repository at this point in the history
drop support for Checkstyle <= 6.15
drop support for Java 6
Source code is now Java7 (up from Java6)
  • Loading branch information
tsjensen committed Jul 7, 2017
1 parent 0778fcd commit 61f5b5f
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 89 deletions.
12 changes: 8 additions & 4 deletions .travis.yml
Expand Up @@ -11,17 +11,21 @@ before_install:
# - sudo update-alternatives --config java
- ./gradlew clean

# Update JDK8 to latest version available for Travis
addons:
apt:
packages:
- oracle-java8-installer

env:
global:
- checkstyleaddons_jdk6_java=/usr/lib/jvm/java-6-openjdk-amd64/bin/java
- checkstyleaddons_jdk6_javac=/usr/lib/jvm/java-6-openjdk-amd64/bin/javac
- checkstyleaddons_jdk6_javadoc=/usr/lib/jvm/java-6-openjdk-amd64/bin/javadoc
- checkstyleaddons_jdk7_java=/usr/lib/jvm/java-7-openjdk-amd64/bin/java
- checkstyleaddons_jdk7_javac=/usr/lib/jvm/java-7-openjdk-amd64/bin/javac
- checkstyleaddons_jdk7_javadoc=/usr/lib/jvm/java-7-openjdk-amd64/bin/javadoc

install: true
script:
- ./gradlew check xtest site
- ./gradlew build site

after_success:
- ./gradlew jacocoTestReport coveralls
Expand Down
10 changes: 6 additions & 4 deletions build.gradle
Expand Up @@ -48,6 +48,7 @@ import com.thomasjensen.checkstyle.addons.build.tasks.JavadocTask;
import com.thomasjensen.checkstyle.addons.build.tasks.SiteTask;
import org.ajoberstar.grgit.Grgit;
import org.apache.tools.ant.filters.ReplaceTokens;
import org.gradle.internal.jvm.Jvm;


// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand All @@ -59,7 +60,7 @@ description = 'Additional Checkstyle Checks';
version = new VersionWrapper(project).toString();
ClasspathBuilder.clearConfigCache();
new JavaLevelUtil(project).analyzeJavaLevels();
sourceCompatibility = JavaVersion.VERSION_1_6;
sourceCompatibility = JavaVersion.VERSION_1_7;

ext {
// keep these in sync with the ExtProp enum
Expand Down Expand Up @@ -91,7 +92,7 @@ taskCreator.establishSonarQubeSourceSet();
dependencies {
compileOnly group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1';
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1';
compile group: 'com.puppycrawl.tools', name: 'checkstyle', version: '7.0';
compile group: 'com.puppycrawl.tools', name: 'checkstyle', version: '8.0';
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.3';

sonarqubeCompileOnly group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1';
Expand Down Expand Up @@ -124,8 +125,9 @@ ext {
exceptionFormat 'full';
}
onOutput { final TestDescriptor descriptor, final TestOutputEvent event ->
if (descriptor.className != 'com.thomasjensen.checkstyle.addons.checks.misc.MdlJsonConfigValidatorTest' ||
event.getDestination() == TestOutputEvent.Destination.StdErr) {
if ((Jvm.current().getJavaVersion() != JavaVersion.VERSION_1_6) &&
(descriptor.className != 'com.thomasjensen.checkstyle.addons.checks.misc.MdlJsonConfigValidatorTest' ||
event.getDestination() == TestOutputEvent.Destination.StdErr)) {
logger.lifecycle(event.message);
}
}
Expand Down
Expand Up @@ -77,9 +77,6 @@ public void configureFor(@Nonnull final DependencyConfig pDepConfig, @Nonnull fi
dependsOn(TaskNames.testClasses.getName(pDepConfig));

configure(buildUtil.getExtraPropertyValue(ExtProp.TestConfigClosure));
if (JavaVersion.VERSION_1_6.equals(pDepConfig.getJavaLevel())) {
getTestLogging().setShowStandardStreams(false);
}
setTestClassesDir(((JavaCompile) buildUtil.getTask(TaskNames.compileTestJava, pDepConfig)).getDestinationDir());

if (baseCsVersion.equals(pCsVersion)) {
Expand Down
6 changes: 3 additions & 3 deletions project/dependencyConfigs/default.properties
Expand Up @@ -21,7 +21,7 @@
# Keep in mind that the base version must not be present in the list of compatible versions below.

# Checkstyle versions which we expect to be compatible with the base version above
CompatibleWithCheckstyle = 7.1, 7.1.1, 7.1.2, 7.2, 7.3, 7.4, 7.5, 7.5.1, 7.6, 7.6.1, 7.7, 7.8, 7.8.1, 7.8.2
CompatibleWithCheckstyle = 7.0, 7.1, 7.1.1, 7.1.2, 7.2, 7.3, 7.4, 7.5, 7.5.1, 7.6, 7.6.1, 7.7, 7.8, 7.8.1, 7.8.2

JavaLevel = 1.8
JavadocLinks = http://checkstyle-addons.github.io/jsr305-javadoc/3.0.1/, \
Expand All @@ -33,6 +33,6 @@ JavadocLinks = http://checkstyle-addons.github.io/jsr305-javadoc/3.0.1/, \
# The default dependency configuration must support SonarQube.
SonarQubeSupport = true

SonarQubeMinPlatformVersion = 4.5.1
SonarQubeMinPlatformVersion = 4.5.2
SonarQubeMinJavaPlugin = 2.2
SonarQubeMinCheckstylePlugin = 2.3
SonarQubeMinCheckstylePlugin = 3.1
46 changes: 0 additions & 46 deletions project/dependencyConfigs/java6.properties

This file was deleted.

11 changes: 3 additions & 8 deletions project/dependencyConfigs/java7.properties
Expand Up @@ -20,11 +20,10 @@
# (see Checkstyle issue #2997 - https://github.com/checkstyle/checkstyle/issues/2997). Checkstyle 6.16.1 is OK.

# the Checkstyle base version
dependencyVersion.com.puppycrawl.tools = 6.4.1
dependencyVersion.com.puppycrawl.tools = 6.16.1

# Checkstyle versions which we expect to be compatible with the base version above
CompatibleWithCheckstyle = 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.8.1, 6.8.2, 6.9, 6.10, 6.10.1, 6.11, 6.11.1, 6.11.2, \
6.12, 6.12.1, 6.13, 6.14, 6.14.1, 6.15, 6.16.1, 6.17, 6.18, 6.19
CompatibleWithCheckstyle = 6.17, 6.18, 6.19

JavaLevel = 1.7
JavadocLinks = http://checkstyle-addons.github.io/jsr305-javadoc/3.0.1/, \
Expand All @@ -34,13 +33,9 @@ JavadocLinks = http://checkstyle-addons.github.io/jsr305-javadoc/3.0.1/, \
http://checkstyle.sourceforge.net/apidocs/
dependencyVersion.com.google.code.findbugs = 3.0.0

SonarQubeSupport = true
SonarQubeSupport = false

# the SonarQube API version (for compiling the SonarQube plugin)
dependencyVersion.org.codehaus.sonar = 3.0
# the SLF4J NOP binding required for the SonarQube API version
dependencyVersion.org.slf4j = 1.6.2

SonarQubeMinPlatformVersion = 4.5.1
SonarQubeMinJavaPlugin = 2.2
SonarQubeMinCheckstylePlugin = 2.3
6 changes: 3 additions & 3 deletions project/version.properties
@@ -1,9 +1,9 @@
# Checkstyle Addons Version number
# Versioning scheme: Semantic - http://semver.org/

major = 4
minor = 2
patch = 1
major = 5
minor = 0
patch = 0

# release or snapshot
release = false
Expand Up @@ -30,7 +30,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.puppycrawl.tools.checkstyle.api.Check;
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import com.thomasjensen.checkstyle.addons.util.CheckstyleApiFixer;
Expand All @@ -43,11 +43,11 @@
*/
@SuppressFBWarnings("ACEM_ABSTRACT_CLASS_EMPTY_METHODS")
public abstract class AbstractAddonsCheck
extends Check
extends AbstractCheck
{
private static final Set<Integer> TOKENS = Collections.unmodifiableSet(new HashSet<Integer>(Arrays.asList(
TokenTypes.PACKAGE_DEF, TokenTypes.ENUM_DEF, TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF,
TokenTypes.ANNOTATION_DEF)));
private static final Set<Integer> TOKENS = Collections.unmodifiableSet(new HashSet<Integer>(Arrays
.asList(TokenTypes.PACKAGE_DEF, TokenTypes.ENUM_DEF, TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF,
TokenTypes.ANNOTATION_DEF)));

/** binary name of the outer (or only) class */
private BinaryName iOuterClassName = null;
Expand Down Expand Up @@ -83,8 +83,17 @@ protected AbstractAddonsCheck(@Nullable final String pMockfile)



/**
* The tokens which this check is interested in. Will be added to the tokens of the base class.
*
* @return the relevant tokens
*/
public abstract Set<Integer> getRelevantTokens();



@Override
public final int[] getDefaultTokens()
public final int[] getRequiredTokens()
{
final Set<Integer> tokens = new TreeSet<Integer>();
tokens.addAll(TOKENS);
Expand All @@ -100,19 +109,18 @@ public final int[] getDefaultTokens()



/**
* The tokens which this check is interested in. Will be added to the tokens of the base class.
*
* @return the relevant tokens
*/
public abstract Set<Integer> getRelevantTokens();
@Override
public final int[] getAcceptableTokens()
{
return getRequiredTokens();
}



@Override
public int[] getRequiredTokens()
public final int[] getDefaultTokens()
{
return getDefaultTokens();
return getRequiredTokens();
}


Expand Down
Expand Up @@ -22,7 +22,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.puppycrawl.tools.checkstyle.api.Check;
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.FileContents;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

Expand All @@ -34,7 +34,7 @@
*/
public class CheckstyleApiFixer
{
private final Check check;
private final AbstractCheck check;

private final File currentFileNameMockFile;

Expand All @@ -45,7 +45,7 @@ public class CheckstyleApiFixer
*
* @param pCheck the check for which this instance of the API fixer shall run
*/
public CheckstyleApiFixer(@Nonnull final Check pCheck)
public CheckstyleApiFixer(@Nonnull final AbstractCheck pCheck)
{
this(pCheck, null);
}
Expand All @@ -58,7 +58,7 @@ public CheckstyleApiFixer(@Nonnull final Check pCheck)
* @param pCheck the check for which this instance of the API fixer shall run
* @param pCurrentFileNameMockFile file to use as result of {@link #getCurrentFileName()} in unit tests
*/
public CheckstyleApiFixer(@Nonnull final Check pCheck, @Nullable final String pCurrentFileNameMockFile)
public CheckstyleApiFixer(@Nonnull final AbstractCheck pCheck, @Nullable final String pCurrentFileNameMockFile)
{
check = pCheck;
currentFileNameMockFile = pCurrentFileNameMockFile != null ? new File(pCurrentFileNameMockFile) : null;
Expand Down

0 comments on commit 61f5b5f

Please sign in to comment.