build.gradle
Rama develop · réplica de lectura del repositorio original.
/*
* Copyright (c) 2020 - present Cloudogu GmbH
*
* 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, version 3.
*
* 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 https://www.gnu.org/licenses/.
*/
plugins {
id 'java-platform'
id 'maven-publish'
id "org.sonarqube" version "7.5.0.8588"
id "org.scm-manager.changelog" version "0.2.0"
id 'org.scm-manager.license' version "0.9.0"
id "cloud.rio.license-report" version "0.18.0"
id "com.github.ben-manes.versions" version "0.54.0"
}
changelog {
versionUrlPattern = "https://scm-manager.org/download/{0}"
}
subprojects { s ->
repositories {
mavenLocal()
mavenCentral()
maven {
url = uri('https://packages.scm-manager.org/repository/public/')
content {
includeGroupByRegex "sonia\\..*"
includeGroupByRegex "org\\.scm-manager\\..*"
includeGroupByRegex "com\\.cloudogu\\..*"
includeGroup "org.tmatesoft.svnkit"
includeGroup "org.apache.shiro"
includeGroup "com.aragost.javahg"
includeGroup "commons-daemon"
}
}
}
}
dependencies {
constraints {
// lombok
api libs.lombok
// jakarta
api libs.jakartaAnnotationApi
// servlet api
api libs.servletApi
// logging
api libs.slf4jApi
api libs.slf4jJcl
api libs.logback
// injection
api libs.guice
api libs.guiceServlet
api libs.guiceThrowingproviders
api libs.guiceAssistedinject
// rest api
api libs.jaxRs
api libs.resteasyCore
// json
api(libs.jacksonCore) {
version { strictly libs.versions.jackson.get() }
}
api(libs.jacksonAnnotations) {
version { strictly libs.versions.jacksonAnnotations.get() }
}
// hypermedia
api libs.edison
api libs.damnhandy
// dto mapping
api libs.mapstruct
api libs.mapstructProcessor
// events
api libs.legman
// xml binding
api libs.jaxbApi
api libs.jaxbRuntime
// validation
api libs.validator
api libs.elApi
api libs.elRuntime
// utils
api libs.guava
api libs.commonsLang
// security
api libs.shiroCore
api libs.ssp
api libs.sspProcessor
api libs.shiroUnit
// tests
api libs.junitJupiterApi
api libs.junitJupiterParams
api libs.junitJupiterEngine
// junit 4 support
api libs.junitVintageEngine
api libs.junit
// assertions
api libs.hamcrestCore
api libs.hamcrestLibrary
api libs.assertj
// mocking
api libs.mockitoCore
api libs.mockitoJunitJupiter
}
}
license {
header rootProject.file("LICENSE-HEADER.txt")
newLine = true
ignoreNewLine = true
lineEnding = "\n"
tasks {
build {
files.from("build.gradle", "settings.gradle", "gradle.properties")
}
}
}
downloadLicenses {
dependencyConfiguration = "runtimeClasspath"
}
// set build props
project.ext {
parseScmVersion = { String value ->
def matcher = value =~ /^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/
if (!matcher.matches()) {
throw new GradleException("version must match major.minor.patch[-qualifier], but was '${value}'")
}
[
major: matcher.group(1).toInteger(),
minor: matcher.group(2).toInteger(),
micro: matcher.group(3).toInteger(),
qualifier: matcher.group(4)
]
}
timestamp = new Date().format('yyyyMMddHHmmSS')
revision = "git rev-parse --short HEAD".execute().text.trim()
if (project.version.contains('-SNAPSHOT')) {
isSnapshot = true
expandedVersion = project.version.replace('SNAPSHOT', timestamp)
expandedVersionWithDot = project.version.replace('-SNAPSHOT', ".${timestamp}")
if (project.version.contains('-REACT19-')) {
dockerRepository = 'docker.io/cloudogu/scm-manager-react19'
} else {
dockerRepository = 'docker.io/cloudogu/scm-manager'
}
String snapshotVersion = revision
def buildNumber = System.getenv('BUILD_NUMBER')
if (buildNumber != null) {
snapshotVersion += "-${buildNumber}"
}
dockerTag = project.version.replace('SNAPSHOT', snapshotVersion)
} else {
isSnapshot = false
expandedVersion = project.version
expandedVersionWithDot = project.version
dockerRepository = 'docker.io/scmmanager/scm-manager'
dockerTag = project.version
}
def v = parseScmVersion(project.version.toString())
nextSnapshotVersion = "${v.major}.${v.minor}.${v.micro + 1}-SNAPSHOT"
// base url for generating links such as
// https://scm-manager.org/docs/3.4.x/en/installation/k8s/
documentationUrl = "https://scm-manager.org/docs/${v.major}.${v.minor}.x"
isCI = isRunningOnCiServer()
os = os()
arch = arch()
// 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"))
}
}
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")
}
}
}
}
}
// determine if we run on ci
def isRunningOnCiServer() {
return isEnvAvailable("JENKINS_URL") && isEnvAvailable("BUILD_ID")
}
def isEnvAvailable(String key) {
String value = System.getenv(key)
return value != null && !value.trim().isEmpty()
}
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
}
// 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
}
}
allprojects {
configurations.all {
resolutionStrategy {
// Force all swagger-related libraries to the same, consistent version
force 'io.swagger.core.v3:swagger-core-jakarta:2.2.55'
force 'io.swagger.core.v3:swagger-models-jakarta:2.2.55'
force 'io.swagger.core.v3:swagger-annotations-jakarta:2.2.55'
force 'io.swagger.core.v3:swagger-integration-jakarta:2.2.55'
force 'io.swagger.core.v3:swagger-jaxrs2-jakarta:2.2.55'
}
}
}
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)
}
}
}