2020-12-18 13:06:04 +01:00
|
|
|
/*
|
|
|
|
|
* MIT License
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
|
id 'java-platform'
|
2021-01-07 15:19:40 +01:00
|
|
|
id 'maven-publish'
|
2021-01-13 18:44:07 +01:00
|
|
|
id "org.sonarqube" version "3.0"
|
2023-01-23 17:12:48 +01:00
|
|
|
id "org.scm-manager.changelog" version "0.2.0"
|
2021-12-23 09:43:32 +01:00
|
|
|
id 'org.scm-manager.license' version "0.7.1"
|
2024-09-03 10:04:11 +02:00
|
|
|
id "com.github.hierynomus.license-report" version"0.16.1"
|
2021-02-02 11:02:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
changelog {
|
2021-10-28 11:00:24 +02:00
|
|
|
versionUrlPattern = "https://scm-manager.org/download/{0}"
|
2020-12-18 13:06:04 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-07 15:19:40 +01:00
|
|
|
subprojects { s ->
|
2021-01-06 15:13:55 +01:00
|
|
|
repositories {
|
2021-03-24 15:54:29 +01:00
|
|
|
mavenLocal()
|
2021-01-06 15:13:55 +01:00
|
|
|
maven {
|
|
|
|
|
url 'https://packages.scm-manager.org/repository/public/'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-06 17:34:24 +01:00
|
|
|
allprojects {
|
|
|
|
|
apply from: rootProject.file('gradle/dependencies.gradle')
|
|
|
|
|
}
|
2021-01-04 15:07:20 +01:00
|
|
|
|
2020-12-18 13:06:04 +01:00
|
|
|
dependencies {
|
|
|
|
|
constraints {
|
2020-12-18 14:14:07 +01:00
|
|
|
// lombok
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.lombok
|
2020-12-18 14:14:07 +01:00
|
|
|
|
2023-11-29 18:14:03 +01:00
|
|
|
// jakarta
|
|
|
|
|
api libraries.jakartaAnnotationApi
|
|
|
|
|
|
2020-12-18 14:14:07 +01:00
|
|
|
// servlet api
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.servletApi
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// logging
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.slf4jApi
|
|
|
|
|
api libraries.slf4jJcl
|
|
|
|
|
api libraries.logback
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// injection
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.guice
|
|
|
|
|
api libraries.guiceServlet
|
|
|
|
|
api libraries.guiceThrowingproviders
|
|
|
|
|
api libraries.guiceAssistedinject
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// rest api
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.jaxRs
|
|
|
|
|
api libraries.resteasyCore
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// json
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.jacksonCore
|
|
|
|
|
api libraries.jacksonAnnotations
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// hypermedia
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.edison
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// dto mapping
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.mapstruct
|
|
|
|
|
api libraries.mapstructProcessor
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// events
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.legman
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// xml binding
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.jaxbApi
|
|
|
|
|
api libraries.jaxbRuntime
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// validation
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.validator
|
|
|
|
|
api libraries.elApi
|
|
|
|
|
api libraries.elRuntime
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// utils
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.guava
|
|
|
|
|
api libraries.commonsLang
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// security
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.shiroCore
|
|
|
|
|
api libraries.ssp
|
|
|
|
|
api libraries.sspProcessor
|
|
|
|
|
api libraries.shiroUnit
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// tests
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.junitJupiterApi
|
|
|
|
|
api libraries.junitJupiterParams
|
|
|
|
|
api libraries.junitJupiterEngine
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// junit 4 support
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.junitVintageEngine
|
|
|
|
|
api libraries.junit
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// assertions
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.hamcrestCore
|
|
|
|
|
api libraries.hamcrestLibrary
|
|
|
|
|
api libraries.assertj
|
2020-12-18 14:14:07 +01:00
|
|
|
|
|
|
|
|
// mocking
|
2021-01-04 15:07:20 +01:00
|
|
|
api libraries.mockitoCore
|
|
|
|
|
api libraries.mockitoJunitJupiter
|
2020-12-18 13:06:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-23 09:43:32 +01:00
|
|
|
license {
|
|
|
|
|
header rootProject.file("LICENSE.txt")
|
|
|
|
|
newLine = true
|
|
|
|
|
ignoreNewLine = true
|
|
|
|
|
lineEnding = "\n"
|
|
|
|
|
|
|
|
|
|
tasks {
|
|
|
|
|
build {
|
|
|
|
|
files.from("build.gradle", "settings.gradle", "gradle.properties")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-03 10:04:11 +02:00
|
|
|
downloadLicenses {
|
|
|
|
|
dependencyConfiguration = "runtimeClasspath"
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 10:38:20 +01:00
|
|
|
import org.gradle.util.VersionNumber
|
|
|
|
|
|
2020-12-23 11:18:55 +01:00
|
|
|
// set build props
|
|
|
|
|
project.ext {
|
|
|
|
|
timestamp = new Date().format('yyyyMMddHHmmSS')
|
|
|
|
|
revision = "git rev-parse --short HEAD".execute().text.trim()
|
|
|
|
|
if (project.version.contains('-SNAPSHOT')) {
|
2021-01-11 13:31:52 +01:00
|
|
|
isSnapshot = true
|
2020-12-23 11:18:55 +01:00
|
|
|
expandedVersion = project.version.replace('SNAPSHOT', timestamp)
|
|
|
|
|
expandedVersionWithDot = project.version.replace('-SNAPSHOT', ".${timestamp}")
|
|
|
|
|
dockerRepository = 'docker.io/cloudogu/scm-manager'
|
|
|
|
|
String snapshotVersion = revision
|
|
|
|
|
def buildNumber = System.getenv('BUILD_NUMBER')
|
|
|
|
|
if (buildNumber != null) {
|
|
|
|
|
snapshotVersion += "-${buildNumber}"
|
|
|
|
|
}
|
2021-01-13 10:38:20 +01:00
|
|
|
dockerTag = project.version.replace('SNAPSHOT', snapshotVersion)
|
2020-12-23 11:18:55 +01:00
|
|
|
} else {
|
2021-01-11 13:31:52 +01:00
|
|
|
isSnapshot = false
|
2020-12-23 11:18:55 +01:00
|
|
|
expandedVersion = project.version
|
|
|
|
|
expandedVersionWithDot = project.version
|
|
|
|
|
dockerRepository = 'docker.io/scmmanager/scm-manager'
|
2021-01-13 10:38:20 +01:00
|
|
|
dockerTag = project.version
|
2020-12-23 11:18:55 +01:00
|
|
|
}
|
2021-01-13 10:38:20 +01:00
|
|
|
|
|
|
|
|
VersionNumber v = VersionNumber.parse(project.version)
|
|
|
|
|
nextSnapshotVersion = "${v.major}.${v.minor}.${v.micro + 1}-SNAPSHOT"
|
2021-01-13 14:32:07 +01:00
|
|
|
|
|
|
|
|
isCI = isRunningOnCiServer()
|
2021-01-13 18:44:07 +01:00
|
|
|
os = os()
|
|
|
|
|
arch = arch()
|
2021-01-15 09:16:22 +01:00
|
|
|
|
|
|
|
|
// map signing environment variables
|
|
|
|
|
// this is required because of environment variables should not have a dot in the name
|
|
|
|
|
// but the gradle signing props are using dots
|
|
|
|
|
// also we use the set method, because setting props with dots works neither
|
|
|
|
|
if (isEnvAvailable("GPG_KEY_RING")) {
|
|
|
|
|
set('signing.secretKeyRingFile', System.getenv("GPG_KEY_RING"))
|
|
|
|
|
}
|
|
|
|
|
if (isEnvAvailable("GPG_KEY_ID")) {
|
|
|
|
|
set('signing.keyId', System.getenv("GPG_KEY_ID"))
|
|
|
|
|
}
|
|
|
|
|
if (isEnvAvailable("GPG_KEY_PASSWORD")) {
|
|
|
|
|
set('signing.password', System.getenv("GPG_KEY_PASSWORD"))
|
|
|
|
|
}
|
2020-12-23 11:18:55 +01:00
|
|
|
}
|
2021-01-11 15:00:30 +01:00
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
|
publications {
|
|
|
|
|
mavenJava(MavenPublication) {
|
|
|
|
|
artifactId project.name
|
|
|
|
|
from components.javaPlatform
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
repositories {
|
|
|
|
|
maven {
|
|
|
|
|
String releasesRepoUrl = "https://packages.scm-manager.org/repository/releases/"
|
|
|
|
|
String snapshotsRepoUrl = "https://packages.scm-manager.org/repository/snapshots/"
|
|
|
|
|
url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
|
|
|
|
|
if (project.hasProperty("packagesScmManagerUsername") && project.hasProperty("packagesScmManagerPassword")) {
|
|
|
|
|
credentials {
|
|
|
|
|
username project.property("packagesScmManagerUsername")
|
|
|
|
|
password project.property("packagesScmManagerPassword")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-13 10:38:20 +01:00
|
|
|
|
2021-01-13 14:32:07 +01:00
|
|
|
// determine if we run on ci
|
2021-01-13 18:44:07 +01:00
|
|
|
|
2021-01-13 14:32:07 +01:00
|
|
|
def isRunningOnCiServer() {
|
|
|
|
|
return isEnvAvailable("JENKINS_URL") && isEnvAvailable("BUILD_ID")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def isEnvAvailable(String key) {
|
|
|
|
|
String value = System.getenv(key)
|
|
|
|
|
return value != null && !value.trim().isEmpty()
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 18:44:07 +01:00
|
|
|
def os() {
|
|
|
|
|
return System.getProperty("os.name").toLowerCase(Locale.ENGLISH)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def arch() {
|
|
|
|
|
def arch = System.getProperty("os.arch")
|
|
|
|
|
if ("amd64".equals(arch)) {
|
|
|
|
|
return "x64"
|
|
|
|
|
}
|
|
|
|
|
return arch
|
|
|
|
|
}
|
2021-01-13 14:32:07 +01:00
|
|
|
|
2021-01-13 10:38:20 +01:00
|
|
|
// release related tasks
|
|
|
|
|
|
|
|
|
|
task setVersion {
|
|
|
|
|
doLast {
|
|
|
|
|
if (!project.hasProperty('newVersion')) {
|
|
|
|
|
throw new GradleException('usage setVersion -PnewVersion=x.y.z')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String version = project.property('newVersion')
|
|
|
|
|
setNewVersion(version)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task setVersionToNextSnapshot {
|
|
|
|
|
doLast {
|
|
|
|
|
setNewVersion(nextSnapshotVersion)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task printVersion {
|
|
|
|
|
doLast {
|
|
|
|
|
println project.version
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def setNewVersion(String newVersion) {
|
|
|
|
|
File propertiesFile = new File(project.rootDir, 'gradle.properties')
|
|
|
|
|
|
|
|
|
|
if (project.version == newVersion) {
|
|
|
|
|
println "project uses already version ${newVersion}"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def lines = propertiesFile.readLines('UTF-8')
|
|
|
|
|
def newLines = lines.collect{ line ->
|
|
|
|
|
if (line.trim().startsWith('version')) {
|
|
|
|
|
return "version = ${newVersion}"
|
|
|
|
|
}
|
|
|
|
|
return line
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println "set version from ${project.version} to ${newVersion}"
|
|
|
|
|
propertiesFile.withWriter('UTF-8') {writer ->
|
|
|
|
|
newLines.forEach { line ->
|
|
|
|
|
writer.writeLine(line)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|