Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Ignore Gradle
# Ignore Gradle related files we don't want to commit
/.gradle/
build/
gradle/analytics
local.properties

# Ignore IntelliJ
/out/
Expand Down
58 changes: 58 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2015 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

pipeline {
agent {
label "light-java"
}
stages {
stage('Build') {
steps {
sh './gradlew --info --console=plain jar'
}
}
stage('Analytics') {
steps {
sh './gradlew --info --console=plain javadoc check'
}
}
stage('Publish') {
when {
anyOf {
branch 'master'
branch pattern: "release/v\\d+.x", comparator: "REGEXP"
}
}
steps {
withCredentials([usernamePassword(credentialsId: 'artifactory-gooey', usernameVariable: 'artifactoryUser', passwordVariable: 'artifactoryPass')]) {
sh './gradlew --info --console=plain -Dorg.gradle.internal.publish.checksums.insecure=true publish -PmavenUser=${artifactoryUser} -PmavenPass=${artifactoryPass}'
}
}
}
stage('Record') {
steps {
junit testResults: '**/build/test-results/test/*.xml', allowEmptyResults: true
recordIssues tool: javaDoc()
//Note: Javadoc archiver only works for one directory :-(
step([$class: 'JavadocArchiver', javadocDir: 'gestalt-entity-system/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: taskScanner(includePattern: '**/*.java,**/*.groovy,**/*.gradle', lowTags: 'WIBNIF', normalTags: 'TODO', highTags: 'ASAP')
}
}
}
}
179 changes: 42 additions & 137 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,161 +1,68 @@
/*
* This is a Gradle build file:
* - Gradle Homepage: http://gradle.org/
* - Gradle Documentation: http://gradle.org/documentation
* - View tasks for this project: $ gradlew tasks
*/
apply plugin: 'project-report'

allprojects {
apply plugin: 'idea'

group = 'org.terasology'

// Declare remote repositories we're interested in - library files will be fetched from here
buildscript {
repositories {
// Main Maven repo
// External libs - jcenter is Bintray and is supposed to be a superset of Maven Central, but do both just in case
jcenter()
mavenCentral()
maven {
url "http://artifactory.terasology.org/artifactory/repo"
}
gradlePluginPortal()
}
}

subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
}

configure(subprojects.findAll { !it.name.contains("testpack") && !it.name.startsWith("module") }) {
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'maven'
apply plugin: 'java-library-distribution'
apply plugin: 'artifactory-publish'
apply plugin: 'maven-publish'

// Primary dependencies definition
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'
compile group: 'com.google.guava', name: 'guava', version: '19.0'

// These dependencies are only needed for running tests
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
}

// Set the expected module Java level (can use a higher Java to run, but should not use features from a higher Java)
sourceCompatibility = 1.8
targetCompatibility = 1.8

jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": version)
}
from(['LICENSE', 'NOTICE'])
//Spotbugs
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.0"
}
}

task sourceJar(type: Jar) {
description = "Create a JAR with all sources"
from sourceSets.main.allSource
from sourceSets.test.allSource
classifier = 'sources'
}
// Needed for extending the "clean" task to also delete custom stuff defined here like analytics config
apply plugin: 'base'

task javadocJar(type: Jar, dependsOn: javadoc) {
description = "Create a JAR with the JavaDoc for the java sources"
from javadoc.destinationDir
classifier = 'javadoc'
}

// A configuration for publishing artifacts
configurations {
published
}
ext {
dirAnalyticsConfig = 'gradle/analytics'
}

// Define the artifacts we want to publish (the .pom will also be included since the Maven plugin is active)
artifacts {
published jar
published sourceJar
published javadocJar
}
// Define configurations for analytics config
configurations {
codeAnalyticsConfig
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact jar {
}
artifact sourceJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
}
}
}
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'
}

artifactory {
publish {
defaults {
publications('mavenJava')
}
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)
}
}

// Technically the plain "jar" both here and above is included automatically, but leaving it explicit for clarity
artifactoryPublish {
dependsOn jar, sourceJar, javadocJar
}

checkstyle {
ignoreFailures = true
configFile = new File(rootDir, "config/checkstyle/checkstyle.xml")
configProperties.samedir = new File(rootDir, "config/checkstyle")
toolVersion = "6.5"
}

pmd {
ignoreFailures = true
ruleSetFiles = files(new File(rootDir, "config/pmd/pmd.xml"))
}

findbugs {
toolVersion = '3.0.0'
ignoreFailures = true
effort = 'max'
reportLevel = 'medium'
excludeFilter = new File(rootDir, "config/findbugs/findbugs-exclude.xml")
}
into "$rootDir/$dirAnalyticsConfig"
}

// gradle wrapper version
wrapper {
gradleVersion '1.10'
// 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"
}

ext {
// Read environment variables, including variables passed by jenkins continuous integration server
env = System.getenv()
}

// Dependencies needed for what our Gradle scripts themselves use. It cannot be included via an external Gradle file :-(
buildscript {
allprojects {
apply plugin: 'idea'

// Declare remote repositories we're interested in - library files will be fetched from here
repositories {
// Main Maven repo
mavenCentral()
maven {
url 'http://dl.bintray.com/jfrog/jfrog-jars'
name "Terasology Artifactory"
url "http://artifactory.terasology.org/artifactory/virtual-repo-live"
allowInsecureProtocol true // 😱
}
}
}

dependencies {
// Artifactory plugin
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.3')
}
//configure(subprojects.findAll { !it.name.contains("testpack") && !it.name.startsWith("module") }) {
subprojects {
apply from: "$rootDir/gradle/common.gradle"
}

// Library and distribution config
Expand Down Expand Up @@ -198,7 +105,6 @@ idea {
}

ext {

// Activate 'git' as VCS
ideaActivateGit = { Node iprNode ->
def vcsMappings = iprNode.component.find { it.'@name' == 'VcsDirectoryMappings' }
Expand Down Expand Up @@ -250,5 +156,4 @@ ext {
'''))
}
}

}
Loading