Permalink
Browse files

fix gradle build

  • Loading branch information...
StefanLindel committed Jun 14, 2017
1 parent 12cfd3d commit 432f93faba608c5cb3783ffbea86efe68fc51156
Showing with 115 additions and 123 deletions.
  1. +2 −11 .gitignore
  2. +15 −1 .travis.yml
  3. +12 −3 build.gradle
  4. +6 −9 gradle/mavencentral.gradle
  5. +80 −99 gradle/version.gradle
View
@@ -3,16 +3,6 @@
/emma
/emmareports
/binInst
/junit2695874143824170240.properties
/junit8028690790230776496.properties
/junit8238872369999205539.properties
/junit9017782371638104547.properties
/junit9142822527714291419.properties
/junitvmwatcher23961660229565860.properties
/junitvmwatcher3193314448726953381.properties
/junitvmwatcher4615577556086699874.properties
/junitvmwatcher7015473125784659852.properties
/junitvmwatcher7720677413329481740.properties
.idea
.gradle
atlassian-ide-plugin.xml
@@ -24,5 +14,6 @@ atlassian-ide-plugin.xml
/build/
/.idea/
/gen/
*.jar
gradle.properties
*.gpg
View
@@ -1,11 +1,23 @@
language: java
jdk:
- oraclejdk8
before_script:
- sudo service postgresql stop || true
- sudo service mysql stop || true
- sudo service memcached stop || true
- sudo service bootlogd stop || true
- sudo service elasticsearch stop || true
- sudo service mongodb stop || true
- sudo service neo4j stop || true
- sudo service cassandra stop || true
- sudo service rsync stop || true
- sudo service x11-common stop || true
- unzip -P $SIGNITURE_PASSWORD signiture.zip
before_install:
- "export DISPLAY=:99.0"
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -extension RANDR -screen 0 1280x1024x16"
- chmod +x gradlew
addons:
coverity_scan:
project:
@@ -15,3 +27,5 @@ addons:
build_command_prepend: "gradle clean"
build_command: "gradle -xTest -xJavadoc"
branch_pattern: coverity_scan
after_success:
- ./gradlew version build uploadArchives
View
@@ -3,17 +3,23 @@ apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
if(new File("secring.gpg").exists()) {
apply plugin: 'signing'
// MAJOR VERSION - Manually set
//----------------------
ext{
majorNumber = 2
}
//----------------------
apply from: 'gradle/ide.gradle'
apply from: 'gradle/version.gradle'
apply from: 'gradle/tasks.gradle'
apply from: 'gradle/mavencentral.gradle'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = "org.sdmlib"
// apply plugins/external files only on jenkins build
// jenkins needs -Pjenkins switch
if (project.hasProperty('jenkins')) {
@@ -40,6 +46,9 @@ buildscript {
}
}
artifacts {
archives sourceJar, javadocJar, fatJar, pmJar, pmJarVersion
}
test {
if (project.hasProperty('maxParallelForks'))
View
@@ -1,15 +1,12 @@
import java.lang.ClassValue.Version;
artifacts {
archives sourceJar, javadocJar, fatJar, pmJar, pmJarVersion
}
def isReleaseBuild() {
return "$version".contains("SNAPSHOT") == false || project.hasProperty('release')
return gitVersion.isRelease();
}
if(new File("secring.gpg").exists()) {
if(project.hasProperty("signing.keyId")) {
apply plugin: 'signing'
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives")}
required { (isReleaseBuild() || gitVersion.isMaster() )&& gradle.taskGraph.hasTask("uploadArchives")}
sign configurations.archives
}
View
@@ -1,42 +1,58 @@
// MAJOR VERSION - Manually set
//----------------------
def majorNumber = 2
//----------------------
import java.text.SimpleDateFormat
task printVersion {
doFirst {
println "$version"
}
}
ext{
gitVersion = new GITVersion(major: majorNumber,minor: getGitTag(), branch: getWorkingBranch(), revision: revisionNumber(), hash: revisionHash(), buildTime: buildTime(), lecture: project.hasProperty('lectureBuild'), year: buildTimeYear(), mavenTime:mavenTime(), release:project.hasProperty('release'), latest: project.hasProperty('latest') )
try{
buildAntCompile.execute()
buildAnt.execute()
project.ext.Revisionnumber = Integer.parseInt(ant.Revisionnumber)
if (project.hasProperty("branch")) {
project.ext.Branchname = ant.Branchname + " " + project.get("branch")
}else {
project.ext.Branchname = ant.Branchname
}
project.ext.LastCommit = ant.LastCommit
project.ext.GitTag = Integer.parseInt(ant.GitTag)
}catch(Exception e) {
println e
project.ext.Revisionnumber = revisionNumber()
if (project.hasProperty("branch")) {
project.ext.Branchname = project.get("branch")
} else {
project.ext.Branchname = ""
}
project.ext.LastCommit = getGitLastCommit()
project.ext.GitTag = getGitTag()
}
gitVersion = new GITVersion(major: ext.majorNumber,minor: ext.GitTag, revision: ext.Revisionnumber, hash: ext.LastCommit, buildTime: buildTime(), branch: ext.Branchname, latest: project.hasProperty('latest'))
}
version = gitVersion
group = 'org.sdmlib'
task version {
group "Git"
description "Show Final Version of Repository"
doLast {
println gitVersion
println "Revisionnumber: " + project.ext.Revisionnumber
println "Branchname: " + project.ext.Branchname
println "LastCommit: " + project.ext.LastCommit
println "GitTag: " + project.ext.GitTag
}
}
// Define a method using a closure as the method body
public class GITVersion {
// MAJOR VERSION - Manually set
int major = -1
int minor = -1
int revision = -1
String buildTime
String mavenTime
String year
int major = -1
int minor = -1
int revision = -1
String buildTime
String hash = ""
String coverage = ""
String branch
String hash = ""
// change, if release is needed some day: boolean release
// also change version above to accept release property
boolean release = false
boolean lecture
String prefix = ""
boolean latest
String toString() {
String toString() {
if (System.getenv().BUILD_NUMBER) {
revision = System.getenv().BUILD_NUMBER as int
}
@@ -56,19 +72,11 @@ public class GITVersion {
}
}
def getGitTag() {
def gittag=0
def test = [0]
executeCommand("git", "tag").eachLine {
try {
test << (it.trim() as int)
} catch (Exception ex) {
// no problem as long as there's another tag with a number
}
}
gittag = test.max()
println "Git-Tag: " + gittag
gittag
def buildTime() {
//def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") //you can change it
def df = new SimpleDateFormat("yyyyMMdd'T'HHmmss") //you can change it
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
def executeCommand(String[] args) {
@@ -95,70 +103,43 @@ def executeCommand(String[] args) {
}
result
}
def getGitTag() {
def gittag=0
def test = [0]
executeCommand("git", "tag").eachLine {
try {
def id = it.trim()
def start = id.indexOf(".")
if(start>0) {
id = id.substring(start + 1)
start = id.indexOf(".")
if(start>0) {
id = id.substring(0, start)
}
}
test << (id as int)
} catch (Exception ex) {
// no problem as long as there's another tag with a number
}
}
gittag = test.max()
gittag
}
def getGitLastCommit() {
def gittag=""
executeCommand("git", "log", "--pretty=format:\"%H\"", "-1").eachLine {
gittag = it.trim()
}
gittag
}
def revisionNumber() {
def count = 0
executeCommand("git", "log", "--oneline").eachLine {
count = count + 1
}
println "RevisionNumber: " + count
count
}
def revisionHash() {
def gitFolder = "$projectDir/.git/"
def takeFromHash = 12
def head = new File(gitFolder + "HEAD").text.split(":")
def isCommit = head.length == 1
if(isCommit) return head[0].trim().take(takeFromHash)
def refHead = new File(gitFolder + head[1].trim())
refHead.text.trim().take takeFromHash
}
def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") //you can change it
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
def buildTimeYear() {
def df = new SimpleDateFormat("yyyy")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
def mavenTime() {
def df = new SimpleDateFormat("yyyyMMddHHmmss")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
/*
* Get the name of the working branch of the project
*
* @return Name of the working branch
*/
def getWorkingBranch() {
// Triple double-quotes for the breaklines
def commit, branch="", value
executeCommand("git", "rev-parse", "HEAD").eachLine {
commit = it.trim()
println "Commit: "+commit
executeCommand("git", "branch", "-r", "--contains", commit).eachLine {
if(it.startsWith("* ")) {
value = it.substring(1).trim()
} else {
value = it.trim()
}
if(value.lastIndexOf("/")>0) {
value = value.substring(value.lastIndexOf("/")+1)
}
branch = branch + " "+value
}
if( count == 0) {
count = -1
}
branch = branch.trim()
println "Git-Branch: " + branch
branch
count
}

0 comments on commit 432f93f

Please sign in to comment.