not finding codenarc ruleset using build.gradle - gradle

Trying to apply codenarc to a spring boot project, however the gradle build is producing :codenarcMain NO-SOURCE. Please advise on what I am doing wrong.
1) Added plugins to build.gradle
apply plugin: 'groovy'
apply plugin: 'codenarc'
2) Then added the following to the build.gradle
codenarc {
ignoreFailures = true
}
codenarcMain {
reports {
html.enabled = true
}
configFile = file("$rootDir/config/codenarc/rules.groovy")
}
3) created rules definition in the file rules.groovy
$rootDir/config/codenarc/rules.groovy

Related

CorDapp JaCoCo Code Coverage

I have a Corda based project with several CorDapp sub projects. I've been looking to add JaCoCo code coverage to this project. I'm looking to have a single code coverage report draw in an aggregate report of all the subproject JaCoCo reports.
To add JaCoCo to a maven project with several maven sub projects, I followed this blog entry https://lkrnac.net/blog/2016/10/aggregate-test-coverage-report/. After we ran the build ./gradlew clean test and got our reports, one of our team members noted that the whitelists weren't being created properly anymore when we ran ./gradlew clean deployNodes.
I've gone back to the base Kotlin CorDapp template found here https://github.com/corda/cordapp-template-kotlin to rule out if it's something we've done wrong with our project structure/gradle. Without JaCoCo added, I see all the whitelist entries I would expect. Once I add the JaCoCo code, I only see the 5 default Corda whitelist entries, and none of my added contract entries.
I'm using JaCoCo version 0.8.1 and coveralls version 2.6.3. The changes I've made are all within the build.gradle file for the root directory cordapp-template-kotlin:
subprojects {
repositories {
mavenCentral()
}
apply plugin: 'jacoco'
apply plugin: 'java'
group = 'net.lkrnac.blog'
version = '1.0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
testCompile("junit:junit:4.12")
}
jacoco {
toolVersion = jacoco_version
}
//command for generating subproject coverage reports
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
}
def publishedProjects = subprojects.findAll()
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn(publishedProjects.test)
additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(publishedProjects.sourceSets.main.output)
executionData = files(publishedProjects.jacocoTestReport.executionData)
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
coveralls {
sourceDirs = publishedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
dependsOn jacocoRootReport
}
I believe that the problem is coming from simply adding a task where JacocoReport as a parameter. Any thoughts how I could proceed to have both code coverage, along with building my whitelists correctly?
I have managed to find how to fix the coverage/whitelisting issue. I started stripping away what seemed to be unnecessary code within the subprojects spec, and found that removing everything except the apply plugin:, jacoco, and jacocoTestReport commands yielded both the root Jacoco code coverage, along with the necessary whitelisting. I didn't need to change any of the other code above to get the whitelisting to work.
For reference, subprojects now looks like this:
subprojects {
apply plugin: 'jacoco'
apply plugin: 'kotlin'
jacoco {
toolVersion = jacoco_version
}
//command for generating subproject coverage reports
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
}

jUnit 5 HTML Report using Gradle 4.6 [duplicate]

This question already has an answer here:
Configuration for Gradle 4.7 to generate the HTML report for JUnit 5 tests
(1 answer)
Closed 4 years ago.
I am trying to generate HTML report of JUnit 5 test case.
Here is my Gradle.build file
buildscript {
ext {
springBootVersion = '2.0.0.M3'
}
repositories {
maven { url 'https://zz-artifactory.zzzz.com/artifactory/maven' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.2.0-M1'
classpath "io.spring.gradle:dependency-management-plugin:1.0.0.RC1"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: "io.spring.dependency-management"
apply from: "CodeCoverage.gradle"
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
dependencies {
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
compile('org.mybatis.spring.boot:mybatis-spring-boot:1.3.2')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter-test:1.3.2')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-aop')
compile("org.junit.jupiter:junit-jupiter-api:5.2.0-M1")
compile('org.junit.jupiter:junit-jupiter-migrationsupport:5.0.2')
compile("org.junit.jupiter:junit-jupiter-engine:5.2.0-M1")
compile("junit:junit:4.12")
compile("org.junit.vintage:junit-vintage-engine:5.2.0-M1")
compile(group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.2.0-M1')
compile(group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.2.0-M1')
testCompile('com.h2database:h2:1.4.196')
testCompile('org.mockito:mockito-all:2.0.2-beta')
testCompile('org.mockito:mockito-core:2.8.9')
}
test {
useJUnitPlatform()
}
junitPlatform {
// platformVersion '1.2.0-M1'
filters {
engines {
// include 'junit-jupiter', 'junit-vintage'
// exclude 'custom-engine'
}
tags {
include 'Smoke'
//exclude 'slow'
}
}
}
subprojects {
apply plugin: 'java'
test {
reports.html.enabled = false
}
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports123/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}
I have used testReport as per
Gradle docs Links
When i run the Gradle task, It runs all the test case, generate XML reprts, but doesnot generate HTML report
In the build log, i see
:testReport NO-SOURCE
any suggestion why it says NO-SOURCE ??
Thanks
You are doing one thing too many. You should either use 'org.junit.platform.gradle.plugin' or test { useJUnitPlatform } but not both.
The standard gradle (html) test reporting will only work with the latter.

Integrating findsecbugs plugin with Gradle's findbugs plugin

I am planning to use findsecbugs plugin to scan java code for vulnerabilities using findbugs plugin. I am looking for configuration parameters to include in my build.gradle file. Something like this.
P.S.: I am able to use FindBugs plugin with Gradle.
I tried and found the working configuration. Posting the working configuration below:
apply plugin: 'java'
apply plugin: 'findbugs'
apply plugin: 'maven'
apply plugin: 'signing'
sourceCompatibility = 1.7
dependencies {
findbugs 'com.google.code.findbugs:findbugs:3.0.0'
findbugs configurations.findbugsPlugins.dependencies
// Here we specify the findbugsPlugins
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.2.0'
}
task findbugs(type: FindBugs) {
classes = fileTree(project.rootDir.absolutePath).include("**/*.class");
source = fileTree(project.rootDir.absolutePath).include("**/*.java");
classpath = files()
pluginClasspath = project.configurations.findbugsPlugins
findbugs {
toolVersion = "3.0.0"
sourceSets = [sourceSets.main]
ignoreFailures = true
reportsDir = file("$project.buildDir/findbugsReports")
effort = "max"
reportLevel = "high"
includeFilter = file("$rootProject.projectDir/include.xml")
excludeFilter = file("$rootProject.projectDir/exclude.xml")
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
}

Spring Boot Tutorial doesn't work with multi project gradle setup

i get a strange behaviour (at least for me :D) when I switch from the gradle file located in https://spring.io/guides/gs/serving-web-content/ to a multi project gradle file setup.
build.gradle in root directory
//Applied to all projects.
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
group = 'de.test.platform'
version = '0.1'
}
subprojects {
//Currently all subprojects are also java projects. If this changes we
//need to move it into the corresponding projects
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
idea {
module {
downloadSources = true
downloadJavadoc = false
}
}
}
idea {
project {
jdkName = '1.8'
languageLevel = '1.8'
}
}
build.gradle in sub directory frontend (thus sub project called :frontend)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
apply plugin: 'war'
apply plugin: 'spring-boot'
jar {
baseName = 'crowdio-frontend'
version = '0.1.0'
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("junit:junit")
}
when I run gradle bootRun and navigate to http://localhost:8080/greeting as in the tutorial i get a infinite loop error. If i change the template from greeting.html to hello.html and return hello instead of greeting in the controller greeting() action i get an 404 Error.
The template is stored in project_root/frontend/src/main/resources/templates/greeting.html
It seems like that for whatever Reason spring boot can decide on thymeleaf with the exact structure of the gradle build file like in the tutorial. However if you switch to a multi project setup you need to add
compile("org.thymeleaf:thymeleaf-spring4")
as a dependency.

Unable to run more than one plugins in gradle

I have configured pmd, checkstyle and findbugs plugins in gradle.build file as i want to maintain the quality the codeline.
Part of my build.gradle property is:
task wrapper(type: Wrapper) {
description = "Generates gradlew (for internal use only)"
gradleVersion = '1.5'
jarFile = 'wrapper/wrapper.jar'
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'findbugs' //TODO: disable findbugs & checkstyle by default.
apply plugin: 'checkstyle'
apply plugin: 'pmd'
pmd.ignoreFailures = true
findbugs.ignoreFailures = true
findbugsMain.enabled = true
findbugsTest.enabled = true
checkstyleTest.enabled = true
checkstyleMain.enabled = true
checkstyle {
configFile = new File(rootDir, "config/checkstyle/checkstyle.xml")
ignoreFailures = true
}
My intention is to get all the warnings/errors for pmd, findbugs and checkstyle.
I am trying gradlew check but i am not able to see any certain behavior. At times findbugs alone runs.
Can anybody suggest where i am missing?
Thanks in advance,
Vijay Bhore
get you list the output of your
./gradlew check
invocation. Usually this should work, though enabling your tasks manually (e.g. 'findbugsMain.enabled = true') shouldnt be necessary.
cheers,
René

Resources