Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #149 from novoda/develop
Browse files Browse the repository at this point in the history
Release 0.7
  • Loading branch information
tasomaniac authored Nov 10, 2018
2 parents cd18938 + b0a478c commit 208e818
Show file tree
Hide file tree
Showing 35 changed files with 488 additions and 211 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
Change Log
==========

[Version 0.7](https://github.com/novoda/gradle-static-analysis-plugin/releases/tag/v0.7)
--------------------------

- Fix Detekt RC9.x and RC10 integrations [PR#144](https://github.com/novoda/gradle-static-analysis-plugin/pull/144)
- Fix Ktlint integration [PR#145](https://github.com/novoda/gradle-static-analysis-plugin/pull/145)
- 6.1.0 and 6.2.1 versions are broken for Android projects because of [a bug in Ktlint](https://github.com/JLLeitschuh/ktlint-gradle/issues/153#issuecomment-437176852)
- Make Findbugs Html report generation cacheable [PR#148](https://github.com/novoda/gradle-static-analysis-plugin/pull/148)
- Use Gradle composite builds in sample projects [PR#142](https://github.com/novoda/gradle-static-analysis-plugin/pull/142)
- Improve docs [PR#128](https://github.com/novoda/gradle-static-analysis-plugin/pull/128), [PR#132](https://github.com/novoda/gradle-static-analysis-plugin/pull/132)

[Version 0.6](https://github.com/novoda/gradle-static-analysis-plugin/releases/tag/v0.6)
--------------------------

- Fix release to plugin portal ([PR#82](https://github.com/novoda/gradle-static-analysis-plugin/pull/82),[PR#83](https://github.com/novoda/gradle-static-analysis-plugin/pull/83))
- Fix release to plugin portal ([PR#82](https://github.com/novoda/gradle-static-analysis-plugin/pull/82), [PR#83](https://github.com/novoda/gradle-static-analysis-plugin/pull/83))
- Improve plugin documentation and samples ([PR#85](https://github.com/novoda/gradle-static-analysis-plugin/pull/85),
[PR#97](https://github.com/novoda/gradle-static-analysis-plugin/pull/97),
[PR#99](https://github.com/novoda/gradle-static-analysis-plugin/pull/99),
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.novoda:gradle-static-analysis-plugin:0.6'
classpath 'com.novoda:gradle-static-analysis-plugin:0.7'
}
}
Expand All @@ -52,7 +52,7 @@ or from the [Gradle Plugins Repository](https://plugins.gradle.org/):

```gradle
plugins {
id 'com.novoda.static-analysis' version '0.6'
id 'com.novoda.static-analysis' version '0.7'
}
```
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ subprojects {
repositories {
jcenter()
gradlePluginPortal()
maven {
url 'https://novoda.bintray.com/snapshots'
}
}
dependencies {
classpath gradlePlugins.bintrayRelease
Expand All @@ -27,6 +30,6 @@ subprojects {
}

task wrapper(type: Wrapper) {
gradleVersion = '4.4.1'
gradleVersion = '4.10.2'
distributionType = Wrapper.DistributionType.ALL
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/GradlePlugins.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class GradlePlugins {
final bintrayRelease = 'com.novoda:bintray-release:0.4.0'
final bintrayRelease = 'com.novoda:bintray-release:SNAPSHOT-6' // TODO update when stable release is out
final buildProperties = 'com.novoda:gradle-build-properties-plugin:0.4.1'
final gradleGit = 'org.ajoberstar:gradle-git:1.6.0'
final gradlePublish = 'com.gradle.publish:plugin-publish-plugin:0.9.9'
Expand Down
7 changes: 3 additions & 4 deletions docs/supported-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ staticAnalysis {
```

## Example configurations
If you want, you can use the Novoda [`team-props` scaffolding system](https://github.com/novoda/novoda/tree/master/team-props) as a starting point for setting
up your project. The repository contains a good example of [configuration](https://github.com/novoda/novoda/blob/master/team-props/static-analysis.gradle) for
the plugin, and [rulesets](https://github.com/novoda/novoda/tree/master/team-props/static-analysis) for all supported tools.

If you want, you can use the Novoda [`team-props` scaffolding system](https://github.com/novoda/novoda/tree/master/scaffolding) as a starting point for setting
up your project. The repository contains a good example of [configuration](https://github.com/novoda/novoda/tree/master/scaffolding/team-props/static-analysis.gradle) for
the plugin, and [rulesets](https://github.com/novoda/novoda/tree/master/scaffolding/team-props/static-analysis) for all supported tools.
12 changes: 9 additions & 3 deletions docs/tools/ktlint.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# ktlint
[Ktlint](https://github.com/shyiko/ktlint) is a linter for Kotlin with a built-in formatter. It does not support Java. Adding
this tool only makes sense when you have Kotlin sources in your project. In fact, it will fail to run if you have 0 Kotlin
files.
this tool only makes sense when you have Kotlin sources in your project.

## Table of contents
* [IMPORTANT: setup Ktlint](#important-setup-ktlint)
* [Configure Ktlint](#configure-ktlint)
* [Known Issues](#known-issues)
---

## IMPORTANT: setup Ktlint
Expand All @@ -25,7 +25,7 @@ In most common cases, adding Ktlint to a project boils down to these simple step
1. Add this statement to your root `build.gradle` project (change the version according to your needs):
```gradle
plugins {
id 'org.jlleitschuh.gradle.ktlint' version '5.0.0'
id 'org.jlleitschuh.gradle.ktlint' version '5.1.0'
// ...
}
```
Expand Down Expand Up @@ -56,3 +56,9 @@ For other configuration options and adding custom rules, refer to the

**Note:** Failures and threshold detection is handled by Static Analysis plugin. That is why `ignoreFailures = true` is set by
the plugin. Please do not manually override `ignoreFailures` property.

## Known Issues

6.1.0 and 6.2.1 versions are broken for Android projects because of [a bug in Ktlint](https://github.com/JLLeitschuh/ktlint-gradle/issues/153#issuecomment-437176852)

Because of a behavior change, the `main` sourceSet is not checked. We recommend to use the version 5.1.0 and before.
8 changes: 4 additions & 4 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext {
websiteUrl = 'https://github.com/novoda/gradle-static-analysis-plugin'
}

version = '0.6'
version = '0.7'
String tag = "v$project.version"
groovydoc.docTitle = 'Static Analysis Plugin'

Expand Down Expand Up @@ -56,15 +56,15 @@ apply plugin: 'com.novoda.bintray-release'

publish {
userOrg = 'novoda'
repoName = buildProperties.publish['bintrayRepo'].string
groupId = 'com.novoda'
artifactId = 'gradle-static-analysis-plugin'
desc = 'Easy setup of static analysis tools for Android and Java projects.'

version = project.buildProperties.publish['version'].string
repoName = project.buildProperties.publish['bintrayRepo'].string
publishVersion = project.buildProperties.publish['version'].string
bintrayUser = project.buildProperties.publish['bintrayUser'].string
bintrayKey = project.buildProperties.publish['bintrayKey'].string
website = websiteUrl
website = project.websiteUrl
}

apply plugin: 'org.ajoberstar.grgit'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package com.novoda.staticanalysis.internal
import com.novoda.staticanalysis.Violations
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.TaskAction

import static org.gradle.api.tasks.PathSensitivity.RELATIVE

abstract class CollectViolationsTask extends DefaultTask {

@InputFile
@PathSensitive(RELATIVE)
private File xmlReportFile
private File htmlReportFile
private Violations violations
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.novoda.staticanalysis.internal.detekt
import com.novoda.staticanalysis.StaticAnalysisExtension
import com.novoda.staticanalysis.Violations
import com.novoda.staticanalysis.internal.Configurator
import com.novoda.staticanalysis.internal.checkstyle.CollectCheckstyleViolationsTask
import org.gradle.api.GradleException
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
Expand All @@ -11,15 +12,17 @@ import org.gradle.api.Task
class DetektConfigurator implements Configurator {

private static final String DETEKT_PLUGIN = 'io.gitlab.arturbosch.detekt'
private static final String LAST_COMPATIBLE_DETEKT_VERSION = '1.0.0.RC8'
private static final String LAST_COMPATIBLE_DETEKT_VERSION = '1.0.0-RC10'
private static final String DETEKT_NOT_APPLIED = 'The Detekt plugin is configured but not applied. Please apply the plugin in your build script.\nFor more information see https://github.com/arturbosch/detekt.'
private static final String OUTPUT_NOT_DEFINED = 'Output not defined! To analyze the results, `output` needs to be defined in Detekt profile.'
private static final String DETEKT_CONFIGURATION_ERROR = "A problem occurred while configuring Detekt. Please make sure to use a compatible version (All versions up to $LAST_COMPATIBLE_DETEKT_VERSION)"
private static final String XML_REPORT_NOT_ENABLED = 'XML report must be enabled. Please make sure to enable "reports.xml" in your Detekt configuration'

private final Project project
private final Violations violations
private final Task evaluateViolations


static DetektConfigurator create(Project project,
NamedDomainObjectContainer<Violations> violationsContainer,
Task evaluateViolations) {
Expand All @@ -45,24 +48,51 @@ class DetektConfigurator implements Configurator {
}

def detekt = project.extensions.findByName('detekt')
setDefaultXmlReport(detekt)
config.delegate = detekt
config()
configureToolTask(detekt)

def collectViolations = configureToolTask(detekt)
evaluateViolations.dependsOn collectViolations
}
}

private void configureToolTask(detekt) {
def detektTask = project.tasks['detektCheck']
detektTask.group = 'verification'
private void setDefaultXmlReport(detekt) {
if (detekt.hasProperty('reports')) {
detekt.reports {
xml.enabled = true
xml.destination = new File(project.buildDir, 'reports/detekt/detekt.xml')
}
}
}

// evaluate violations after detekt
private CollectCheckstyleViolationsTask configureToolTask(detekt) {
def detektTask = project.tasks.findByName('detekt')
if (detektTask?.hasProperty('reports')) {
def reports = detektTask.reports
if (!reports.xml.enabled) {
throw new IllegalStateException(XML_REPORT_NOT_ENABLED)
}
return createCollectViolationsTask(
violations,
detektTask,
reports.xml.destination,
reports.html.destination
)
}

// Fallback to old Detekt versions
def output = resolveOutput(detekt)
if (!output) {
throw new IllegalArgumentException(OUTPUT_NOT_DEFINED)
}
def collectViolations = createCollectViolationsTask(violations, project.file(output))
evaluateViolations.dependsOn collectViolations
collectViolations.dependsOn detektTask
def outputFolder = project.file(output)
return createCollectViolationsTask(
violations,
project.tasks['detektCheck'],
new File(outputFolder, 'detekt-checkstyle.xml'),
new File(outputFolder, 'detekt-report.html')
)
}

private static resolveOutput(detekt) {
Expand All @@ -75,20 +105,23 @@ class DetektConfigurator implements Configurator {
}
}

private CollectDetektViolationsTask createCollectViolationsTask(Violations violations, File outputFolder) {
project.tasks.create('collectDetektViolations', CollectDetektViolationsTask) { task ->
task.xmlReportFile = new File(outputFolder, 'detekt-checkstyle.xml')
task.htmlReportFile = new File(outputFolder, 'detekt-report.html')
private CollectCheckstyleViolationsTask createCollectViolationsTask(Violations violations, detektTask, File xmlReportFile, File htmlReportFile) {
project.tasks.create('collectDetektViolations', CollectCheckstyleViolationsTask) { task ->
task.xmlReportFile = xmlReportFile
task.htmlReportFile = htmlReportFile
task.violations = violations

task.dependsOn(detektTask)
}
}

private static boolean isKotlinProject(final Project project) {
final boolean isKotlin = project.plugins.hasPlugin('kotlin')
final boolean isKotlinAndroid = project.plugins.hasPlugin('kotlin-android')
final boolean isKotlinPlatformCommon = project.plugins.hasPlugin('kotlin-platform-common')
final boolean isKotlinMultiplatform = project.plugins.hasPlugin('org.jetbrains.kotlin.multiplatform')
final boolean isKotlinPlatformJvm = project.plugins.hasPlugin('kotlin-platform-jvm')
final boolean isKotlinPlatformJs = project.plugins.hasPlugin('kotlin-platform-js')
return isKotlin || isKotlinAndroid || isKotlinPlatformCommon || isKotlinPlatformJvm || isKotlinPlatformJs
return isKotlin || isKotlinAndroid || isKotlinPlatformCommon || isKotlinMultiplatform || isKotlinPlatformJvm || isKotlinPlatformJs
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package com.novoda.staticanalysis.internal.findbugs

import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive

import static org.gradle.api.tasks.PathSensitivity.RELATIVE

class GenerateFindBugsHtmlReport extends JavaExec {

@InputFile
@PathSensitive(RELATIVE)
File xmlReportFile
@OutputFile
@PathSensitive(RELATIVE)
File htmlReportFile

GenerateFindBugsHtmlReport() {
onlyIf { xmlReportFile?.exists() }
}

@Override
void exec() {
if (xmlReportFile?.exists()) {
main = 'edu.umd.cs.findbugs.PrintingBugReporter'
standardOutput = new FileOutputStream(htmlReportFile)
args '-html', xmlReportFile
super.exec()
}
main = 'edu.umd.cs.findbugs.PrintingBugReporter'
standardOutput = new FileOutputStream(htmlReportFile)
args '-html', xmlReportFile
super.exec()
}
}
Loading

0 comments on commit 208e818

Please sign in to comment.