Skip to content

Commit

Permalink
Updated Gradle definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Mridang Agarwalla committed Apr 29, 2022
1 parent 1a036cf commit c4eb188
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 5 additions & 163 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
//file:noinspection GrUnresolvedAccess
//file:noinspection GroovyAssignabilityCheck
import org.gradle.api.tasks.testing.logging.TestLogEvent

buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id 'java'
id 'checkstyle'
id 'maven-publish'
id 'java-library'
id "jacoco"
id "com.github.johnrengelman.shadow" version "7.1.0"
id 'com.diffplug.spotless' version '5.0.0'
id "com.github.spotbugs" version "4.7.1"
id "net.ltgt.errorprone" version "2.0.1"
id 'net.ltgt.nullaway' version "1.1.0"
id "com.dorongold.task-tree" version "1.5"
id 'myproject.java-conventions'
}

group 'com.nosto'
version '0.0.7'

repositories {
mavenCentral()
maven {
url 'https://maven.onehippo.com/maven2/'
}
java {
sourceCompatibility "11"
targetCompatibility "11"
}

dependencies {
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.2.0'
testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.2.0'
implementation group: 'junit', name: 'junit', version: '4.12'
implementation group: 'junit', name: 'junit', version: '4.13.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.11.0'
implementation group: 'javax.annotation', name: 'jsr305', version: '1.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
Expand All @@ -59,121 +35,6 @@ dependencies {
spotbugsPlugins group: 'com.h3xstream.findsecbugs', name: 'findsecbugs-plugin', version: '1.10.1'
}

// Configuration for the nullaway extension. The rest of the parameters must be
// specified on the java-compile tasks. The only option that be specified here
// is the name of the root package to be analysed.
nullaway {
//noinspection GrUnresolvedAccess
annotatedPackages.add("com.nosto")
}

// Configuration for the Jacoco plugin. It seems that it isn't possible to define
// the output report formats here and those seem to be defined on the individual
// task level.
// I'm not sure why the tool version is defined here and it isn't managed as a
// dependency.
jacoco {
toolVersion = "0.8.5"
}

// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
jacocoTestReport {
reports {
csv.enabled = true
xml.enabled = false
html.enabled = true
}
}

test {
useJUnitPlatform()
testLogging.events.addAll([TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED])
reports {
junitXml.enabled = true
html.enabled = true
}
maxParallelForks = (int) (Runtime.runtime.availableProcessors() / 2 + 1)
finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}

javadoc {
options.addBooleanOption('html5', true)
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

java {
withSourcesJar()
withJavadocJar()
}

// Configuration for the Spotbugs plugin. It seems that it isn't possible to define
// the output report formats here and those seem to be defined on the individual
// task level.
// I'm not sure why the tool version is defined here and it isn't managed as a
// dependency.
spotbugs {
//noinspection GroovyAccessibility,GrFinalVariableAccess,GroovyAssignabilityCheck
toolVersion = '4.0.2'
//noinspection GroovyAccessibility,GrFinalVariableAccess,GroovyAssignabilityCheck
ignoreFailures = true
//noinspection GroovyAccessibility,GrFinalVariableAccess,GroovyAssignabilityCheck
effort = 'max'
// Exclude all *.scala files as Spotbugs doesn't work too well with Scala.
//noinspection GroovyAccessibility,GrFinalVariableAccess,GroovyAssignabilityCheck
excludeFilter = file("$rootDir/gradle/config/spotbugs/exclude.xml")
}

// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
spotbugsMain {
//noinspection GroovyAssignabilityCheck
reports {
xml.enabled = true
}
}

// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
spotbugsTest {
//noinspection GroovyAssignabilityCheck
reports {
xml.enabled = true
}
}

// Configuration for the Checkstyle plugin. It seems that it isn't possible to define
// the output report formats here and those seem to be defined on the individual
// task level.
// I'm not sure why the tool version is defined here and it isn't managed as a
// dependency.
checkstyle {
toolVersion "7.6.1"
config rootProject.resources.text.fromFile("gradle/config/checkstyle/checkstyle.xml")
}

// We only need the XML report so that the CI tools can parse it. The HTML isn't needed
// and must be explicitly disabled
checkstyleMain {
reports {
xml.enabled = true
html.enabled = false
}
}

// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
checkstyleTest {
reports {
xml.enabled = true
html.enabled = false
}
}

publishing {
repositories {
maven {
Expand Down Expand Up @@ -251,22 +112,3 @@ publishing {
}
}
}

// Task for building the zip file for upload
task buildZip(type: Zip) {
zip64 = true
archiveBaseName.set(rootProject.name)
from compileJava
from processResources
into('lib') {
from configurations.runtimeClasspath
}
}

shadowJar {
zip64 true
}

build {
dependsOn buildZip
}
30 changes: 30 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
id 'groovy-gradle-plugin'
}

repositories {
google()
mavenCentral()
gradlePluginPortal()
maven {
url "https://repo.spring.io/milestone"
}
}

dependencies {
implementation group: 'gradle.plugin.com.github.johnrengelman', name: 'shadow', version: '7.1.2'
implementation group: 'com.github.alisiikh', name: 'gradle-scalastyle-plugin', version: '3.4.1'
implementation group: 'com.diffplug.spotless', name: 'spotless-plugin-gradle', version: '6.5.0'
implementation group: 'com.github.spotbugs.snom', name: 'spotbugs-gradle-plugin', version: '5.0.6'
implementation group: 'net.ltgt.gradle', name: 'gradle-errorprone-plugin', version: '2.0.2'
implementation group: 'net.ltgt.gradle', name: 'gradle-nullaway-plugin', version: '1.2.0'
implementation group: 'com.dorongold.plugins', name: 'task-tree', version: '2.1.0'
implementation group: 'net.idlestate', name: 'gradle-duplicate-classes-check', version: '1.1.0'
implementation group: 'org.jetbrains.qodana', name: 'gradle-qodana-plugin', version: '0.1.13'
implementation group: 'org.jetbrains.intellij.plugins', name: 'gradle-intellij-plugin', version: '1.5.3'
implementation group: 'gradle.plugin.com.hierynomus.gradle.plugins', name: 'license-gradle-plugin', version: '0.16.1'
implementation group: 'gradle.plugin.io.snyk.gradle.plugin', name: 'snyk', version: '0.4'
implementation group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '2.7.0-M3'
implementation group: 'io.spring.gradle', name: 'dependency-management-plugin', version: '1.0.11.RELEASE'
implementation group: 'org.springdoc', name: 'springdoc-openapi-gradle-plugin', version: '1.3.4'
}
Loading

0 comments on commit c4eb188

Please sign in to comment.