Files
ma1sd/build.gradle
2017-09-06 04:17:46 +02:00

196 lines
5.1 KiB
Groovy

import java.util.regex.Pattern
/*
* mxisd - Matrix Identity Server Daemon
* Copyright (C) 2017 Maxime Dor
*
* https://max.kamax.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
def confFileName = "application.example.yaml"
def distDir = "${project.buildDir}/dist"
def debBinPath = "/usr/lib/mxisd"
def debConfPath = "/etc/mxisd"
def debDataPath = "/var/lib/mxisd"
def debSystemdPath = "/etc/systemd/system"
def debConfFileName = "mxisd-sample.yaml"
def debBuildBasePath = "${project.buildDir}/tmp/debian"
def debBuildDebianPath = "${debBuildBasePath}/DEBIAN"
def debBuildBinPath = "${debBuildBasePath}${debBinPath}"
def debBuildConfPath = "${debBuildBasePath}${debConfPath}"
def debBuildDataPath = "${debBuildBasePath}${debDataPath}"
def debBuildSystemdPath = "${debBuildBasePath}${debSystemdPath}"
String gitVersion() {
def versionPattern = Pattern.compile("v(\\d+\\.)?(\\d+\\.)?(\\d+)(-.*)?")
ByteArrayOutputStream out = new ByteArrayOutputStream()
exec {
commandLine = [ 'git', 'describe', '--always', '--dirty' ]
standardOutput = out
}
def v = out.toString().replace(System.lineSeparator(), '')
return versionPattern.matcher(v).matches() ? v.substring(1) : v
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE'
}
}
repositories {
maven { url "https://kamax.io/maven/releases/" }
mavenCentral()
}
dependencies {
// We are a groovy project
compile 'org.codehaus.groovy:groovy-all:2.4.7'
// Easy file management
compile 'commons-io:commons-io:2.5'
// Spring Boot - standalone app
compile 'org.springframework.boot:spring-boot-starter-web:1.5.3.RELEASE'
// Matrix Java SDK
compile 'io.kamax:matrix-java-sdk:0.0.2'
// ed25519 handling
compile 'net.i2p.crypto:eddsa:0.1.0'
// LDAP connector
compile 'org.apache.directory.api:api-all:1.0.0-RC2'
// DNS lookups
compile 'dnsjava:dnsjava:2.1.8'
// HTTP connections
compile 'org.apache.httpcomponents:httpclient:4.5.3'
// JSON
compile 'com.google.code.gson:gson:2.8.1'
// Phone numbers validation
compile 'com.googlecode.libphonenumber:libphonenumber:8.7.1'
// E-mail sending
compile 'com.sun.mail:javax.mail:1.5.6'
compile 'javax.mail:javax.mail-api:1.5.6'
// Google Firebase Authentication backend
compile 'com.google.firebase:firebase-admin:5.3.0'
testCompile 'junit:junit:4.12'
}
springBoot {
executable = true
embeddedLaunchScriptProperties = [
confFolder: "/etc/default"
]
}
task buildDeb(dependsOn: build) {
doLast {
def v = gitVersion()
println "Version for package: ${v}"
mkdir distDir
mkdir debBuildBasePath
mkdir "${debBuildBasePath}/DEBIAN"
mkdir debBuildBinPath
mkdir debBuildConfPath
mkdir debBuildDataPath
mkdir debBuildSystemdPath
copy {
from "${project.buildDir}/libs/mxisd.jar"
into debBuildBinPath
}
ant.chmod(
file: "${debBuildBinPath}/mxisd.jar",
perm: 'a+x'
)
copy {
from(project.file(confFileName)) {
rename confFileName, debConfFileName
}
into debBuildConfPath
}
ant.replace(
file: "${debBuildConfPath}/${debConfFileName}",
token: '%SIGNING_KEYS_PATH%',
value: "${debDataPath}/signing.key"
)
copy {
from project.file('src/debian')
into debBuildDebianPath
}
ant.replace(
file: "${debBuildDebianPath}/control",
token: 'Version: 0',
value: "Version: ${v}"
)
ant.replace(
file: "${debBuildDebianPath}/postinst",
token: '%DEB_DATA_DIR%',
value: debDataPath
)
ant.chmod(
file: "${debBuildDebianPath}/postinst",
perm: 'a+x'
)
ant.chmod(
file: "${debBuildDebianPath}/prerm",
perm: 'a+x'
)
copy {
from "${project.file('src/systemd/mxisd.service')}"
into debBuildSystemdPath
}
exec {
commandLine(
'fakeroot',
'dpkg-deb',
'-b',
debBuildBasePath,
"${project.buildDir}/dist"
)
}
}
}