diff --git a/.gitignore b/.gitignore index 55fa309e81..e5715190cf 100644 --- a/.gitignore +++ b/.gitignore @@ -11,9 +11,10 @@ !.gitignore !.github -# Ignore Gradle temp files +# Ignore Gradle files we don't want committed build/ /gradle.properties +config/analytics # Ignore IntelliJ files */out/ @@ -55,4 +56,3 @@ local.properties # Ignore generated output of mdbook for Github Pages docs/book - diff --git a/Jenkinsfile b/Jenkinsfile index d42df872cb..76c01b7dd4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,9 +32,9 @@ pipeline { recordIssues tool: javaDoc() //Note: Javadoc archiver only works for one directory :-( step([$class: 'JavadocArchiver', javadocDir: 'nui/build/docs/javadoc', keepAll: false]) - //recordIssues tool: checkStyle(pattern: '**/build/reports/checkstyle/*.xml') - //recordIssues tool: spotBugs(pattern: '**/build/reports/spotbugs/main/*.xml', useRankAsPriority: true) - //recordIssues tool: pmdParser(pattern: '**/build/reports/pmd/*.xml') + recordIssues tool: checkStyle(pattern: '**/build/reports/checkstyle/*.xml') + recordIssues tool: spotBugs(pattern: '**/build/reports/spotbugs/main/*.xml', useRankAsPriority: true) + recordIssues tool: pmdParser(pattern: '**/build/reports/pmd/*.xml') recordIssues tool: taskScanner(includePattern: '**/*.java,**/*.groovy,**/*.gradle', lowTags: 'WIBNIF', normalTags: 'TODO', highTags: 'ASAP') } } diff --git a/build.gradle b/build.gradle index ebdda74f03..b2ddaa4ab7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,26 @@ // See gradle/common.gradle for more or less global build logic applied to the subprojects +buildscript { + repositories { + // External libs - jcenter is Bintray and is supposed to be a superset of Maven Central, but do both just in case + jcenter() + mavenCentral() + gradlePluginPortal() + } + + dependencies { + //Spotbugs + classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.0" + } +} + plugins { - id 'idea' + // Needed for extending the "clean" task to also delete custom stuff defined here like analytics config + id "base" + + id "idea" + // For the "Build and run using: Intellij IDEA | Gradle" switch + id "org.jetbrains.gradle.plugin.idea-ext" version "0.7" } ext { @@ -10,4 +29,42 @@ ext { // JOML version we're tracking jomlVersion = "1.9.25" + + dirAnalyticsConfig = 'gradle/analytics' +} + +// Declare remote repositories we're interested in - library files will be fetched from here +repositories { + // Artifactory instance for our stuff and binaries not readily available elsewhere + maven { + name "Terasology Artifactory" + url "http://artifactory.terasology.org/artifactory/virtual-repo-live" + allowInsecureProtocol true // 😱 + } +} + +// Define configurations for analytics config +configurations { + codeAnalyticsConfig +} + +dependencies { + // Config for our code analytics lives in a centralized repo: https://github.com/MovingBlocks/TeraConfig + codeAnalyticsConfig group: 'org.terasology.config', name: 'codemetrics', version: '1.3.2', ext: 'zip' +} + +task extractAnalyticsConfig(type: Copy) { + description = "Extracts configuration files for our analytics from the zip we fetched as a dependency" + from { + configurations.codeAnalyticsConfig.collect { + zipTree(it) + } + } + into "$rootDir/$dirAnalyticsConfig" +} + +// Include deletion of extracted stuff in the global clean task. Without the doLast it runs on *every* execution ... +clean.doLast { + new File(dirAnalyticsConfig).deleteDir() + println "Cleaned root - don't forget to re-extract stuff! 'gradlew extractAnalyticsConfig' will do so" } diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml deleted file mode 100644 index 67ff87514d..0000000000 --- a/config/checkstyle/checkstyle.xml +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml deleted file mode 100644 index efd97d8060..0000000000 --- a/config/checkstyle/suppressions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/config/pmd/pmd.xml b/config/pmd/pmd.xml deleted file mode 100644 index 73ad0e5fcc..0000000000 --- a/config/pmd/pmd.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - Terasology PMD ruleset - - - - - - - - - - - - - - - - - - - - - - - - - .*/org.terasology.protobuf/.* - diff --git a/gradle/common.gradle b/gradle/common.gradle index 4966de2eff..facf8e75a0 100644 --- a/gradle/common.gradle +++ b/gradle/common.gradle @@ -1,3 +1,9 @@ +// Analytics +apply plugin: 'project-report' +apply plugin: 'checkstyle' +apply plugin: 'pmd' +apply plugin: 'com.github.spotbugs' + java { withSourcesJar() withJavadocJar() @@ -6,6 +12,9 @@ java { targetCompatibility(JavaVersion.VERSION_1_8) } +// Extract analytics config files if needed (note: does not help IDE execution or cases like 'gradlew spotbugsMain') +check.dependsOn rootProject.extractAnalyticsConfig + // We use both Maven Central and our own Artifactory instance, which contains module builds, extra libs, and so on repositories { // For development so you can publish binaries locally and have them grabbed from there @@ -32,12 +41,6 @@ repositories { allowInsecureProtocol true // 😱 } } - - maven { - name "snowplow (pre-0.9)" - url "http://maven.snplow.com/releases" - allowInsecureProtocol true // 😱 - } } // Extra details provided for unit tests @@ -61,6 +64,34 @@ javadoc { failOnError = false } +checkstyle { + ignoreFailures = true + configFile = new File(rootDir, 'gradle/analytics/checkstyle/checkstyle.xml') + configProperties.samedir = checkstyle.configFile.parentFile +} + +pmd { + ignoreFailures = true + ruleSetFiles = files("$rootDir/gradle/analytics/pmd/pmd.xml") + // By default, gradle uses both ruleset file AND the rulesets. Override the ruleSets to use only those from the file + ruleSets = [] +} + +spotbugs { + toolVersion = '4.0.0' + ignoreFailures = true + excludeFilter = new File(rootDir, "gradle/analytics/findbugs/findbugs-exclude.xml") +} + +spotbugsMain { + reports { + xml { + enabled = true + destination = file("$buildDir/reports/spotbugs/main/spotbugs.xml") + } + } +} + group = 'org.terasology.nui' version = nuiVersion diff --git a/nui/build.gradle b/nui/build.gradle index bfe9119388..b0be41f23a 100644 --- a/nui/build.gradle +++ b/nui/build.gradle @@ -33,5 +33,4 @@ dependencies { test { useJUnitPlatform() - }