Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

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

# Ignore IntelliJ
/out/
out/
*.iml
/*.ipr
/*.iws
Expand All @@ -41,4 +42,4 @@ Icon

#Ignore Windows
ehthumbs.db
Thumbs.db
Thumbs.db
42 changes: 42 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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')
}
}
}
}
269 changes: 42 additions & 227 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,254 +1,69 @@
/*
* 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
description = 'A set of libraries providing core capabilities for games and game engines'

// Setup IntelliJ-IDEA
idea {
project {
jdkName = '1.8'
languageLevel = 'JDK_1_8'

ipr {
withXml { xmlProvider ->
def iprNode = xmlProvider.asNode()

ideaActivateGit(iprNode)
ideaActivateCheckstyle(iprNode)
ideaActivateCopyright(iprNode)
}
}
}

module {
// Exclude Gradle dir
excludeDirs += file('gradle')

// Exclude Eclipse dirs
excludeDirs += file('bin')
excludeDirs += file('.settings')
}

workspace.iws.withXml { xmlProvider ->
def iwsNode = xmlProvider.asNode()
def runManager = iwsNode.find { it.@name == 'RunManager' }
def junitDefault = runManager.find { it.@factoryName == 'JUnit' }
def workingDir = junitDefault.find { it.@name == 'WORKING_DIRECTORY' }
workingDir.@value = 'file://$MODULE_DIR$'
}

}

ext {

// Activate 'git' as VCS
ideaActivateGit = { Node iprNode ->
def vcsMappings = iprNode.component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsMappings.mapping.@vcs = 'Git'
}

// Activate and config 'Checkstyle' plugin
ideaActivateCheckstyle = { Node iprNode ->
def checkstyle = iprNode.component.find { it.'@name' == 'CheckStyle-IDEA' }
if (checkstyle == null) {
// Create new CheckStyle component
checkstyle = iprNode.appendNode('component', [name: 'CheckStyle-IDEA'])
// use NodeBuilder to create the config block in the xml structure
def builder = new NodeBuilder()
def option = builder.option(name: 'configuration') {
map {
entry(key: 'active-configuration',
value: 'PROJECT_RELATIVE:$PROJECT_DIR$/config/checkstyle/checkstyle.xml:gestalt CheckStyle')
entry(key: 'check-nonjava-files', value: false)
entry(key: 'check-test-classes', value: true)
entry(key: 'location-0',
value: 'CLASSPATH:/sun_checks.xml:The default CheckStyle rules')
entry(key: 'location-1',
value: 'PROJECT_RELATIVE:$PROJECT_DIR$/config/checkstyle/checkstyle.xml:gestalt CheckStyle')
entry(key: 'property-1.samedir', value: 'config/checkstyle')
entry(key: 'suppress-errors', value: false)
entry(key: 'thirdparty-classpath', value: '')
}
}
// Add result from NodeBuilder
checkstyle.append option
}
}

// Activate copyright conventions
ideaActivateCopyright = { Node iprNode ->
def copyrightManager = iprNode.component.find { it.'@name' == 'CopyrightManager' }
copyrightManager.'@default' = "gestalt-module"
def copyright = copyrightManager.copyright.find { it.option.find { it.'@name' == "myName" }?.'@value' == "gestalt-module" }
if (copyright == null) {
copyrightManager.append(new XmlParser().parseText('''
<copyright>
<option name="notice" value="Copyright 2015 MovingBlocks&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10; http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
<option name="keyword" value="Copyright" />
<option name="allowReplaceKeyword" value="" />
<option name="myName" value="gestalt-module" />
<option name="myLocal" value="true" />
</copyright>
'''))
}
}

}
Loading