/* * 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 "3.0" id "org.scm-manager.changelog" version "0.2.0" id 'org.scm-manager.license' version "0.7.1" id "com.github.hierynomus.license-report" version"0.16.1" } changelog { versionUrlPattern = "https://scm-manager.org/download/{0}" } subprojects { s -> repositories { mavenLocal() maven { url 'https://packages.scm-manager.org/repository/public/' } } } allprojects { apply from: rootProject.file('gradle/dependencies.gradle') } dependencies { constraints { // lombok api libraries.lombok // jakarta api libraries.jakartaAnnotationApi // servlet api api libraries.servletApi // logging api libraries.slf4jApi api libraries.slf4jJcl api libraries.logback // injection api libraries.guice api libraries.guiceServlet api libraries.guiceThrowingproviders api libraries.guiceAssistedinject // rest api api libraries.jaxRs api libraries.resteasyCore // json api libraries.jacksonCore api libraries.jacksonAnnotations // hypermedia api libraries.edison // dto mapping api libraries.mapstruct api libraries.mapstructProcessor // events api libraries.legman // xml binding api libraries.jaxbApi api libraries.jaxbRuntime // validation api libraries.validator api libraries.elApi api libraries.elRuntime // utils api libraries.guava api libraries.commonsLang // security api libraries.shiroCore api libraries.ssp api libraries.sspProcessor api libraries.shiroUnit // tests api libraries.junitJupiterApi api libraries.junitJupiterParams api libraries.junitJupiterEngine // junit 4 support api libraries.junitVintageEngine api libraries.junit // assertions api libraries.hamcrestCore api libraries.hamcrestLibrary api libraries.assertj // mocking api libraries.mockitoCore api libraries.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" } import org.gradle.util.VersionNumber // set build props project.ext { 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}") 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 } VersionNumber v = VersionNumber.parse(project.version) 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 } } 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) } } }