2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <info@pgpainless.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
buildscript {
|
2018-06-04 14:50:09 +02:00
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
repositories {
|
2018-06-28 17:12:15 +02:00
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
maven {
|
|
|
|
url "https://plugins.gradle.org/m2/"
|
|
|
|
}
|
|
|
|
mavenLocal()
|
|
|
|
mavenCentral()
|
|
|
|
}
|
2018-07-24 16:23:24 +02:00
|
|
|
dependencies {
|
2021-05-31 16:18:11 +02:00
|
|
|
classpath "gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0"
|
2018-07-24 16:23:24 +02:00
|
|
|
}
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
|
2018-07-18 18:44:38 +02:00
|
|
|
plugins {
|
2023-08-04 17:01:12 +02:00
|
|
|
id 'org.jetbrains.kotlin.jvm' version "1.8.10"
|
2023-10-23 09:00:18 +02:00
|
|
|
id 'com.diffplug.spotless' version '6.22.0' apply false
|
2018-07-18 18:44:38 +02:00
|
|
|
}
|
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
apply from: 'version.gradle'
|
2018-07-02 21:40:59 +02:00
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
allprojects {
|
2018-07-18 18:44:38 +02:00
|
|
|
apply plugin: 'java'
|
|
|
|
apply plugin: 'idea'
|
|
|
|
apply plugin: 'eclipse'
|
2018-07-24 13:00:57 +02:00
|
|
|
apply plugin: 'jacoco'
|
2018-07-18 18:44:38 +02:00
|
|
|
apply plugin: 'checkstyle'
|
2023-08-04 17:01:12 +02:00
|
|
|
apply plugin: 'kotlin'
|
2023-10-23 09:00:18 +02:00
|
|
|
apply plugin: 'com.diffplug.spotless'
|
2018-07-18 18:44:38 +02:00
|
|
|
|
2023-05-09 20:09:49 +02:00
|
|
|
compileJava {
|
|
|
|
options.release = 8
|
|
|
|
}
|
|
|
|
|
2022-01-11 15:18:34 +01:00
|
|
|
// Only generate jar for submodules
|
2022-01-12 01:00:00 +01:00
|
|
|
// without this we would generate an empty pgpainless.jar for the project root
|
2022-01-11 15:18:34 +01:00
|
|
|
// https://stackoverflow.com/a/25445035
|
|
|
|
jar {
|
|
|
|
onlyIf { !sourceSets.main.allSource.files.isEmpty() }
|
|
|
|
}
|
|
|
|
|
2018-07-18 18:44:38 +02:00
|
|
|
// checkstyle
|
|
|
|
checkstyle {
|
2023-06-27 15:00:21 +02:00
|
|
|
toolVersion = '10.12.1'
|
2018-07-18 18:44:38 +02:00
|
|
|
}
|
2018-07-02 21:40:59 +02:00
|
|
|
|
2023-10-23 09:00:18 +02:00
|
|
|
spotless {
|
|
|
|
kotlin {
|
|
|
|
ktfmt().dropboxStyle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
group 'org.pgpainless'
|
|
|
|
description = "Simple to use OpenPGP API for Java based on Bouncycastle"
|
|
|
|
version = shortVersion
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
sourceCompatibility = javaSourceCompatibility
|
2018-06-02 21:21:35 +02:00
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
2022-04-29 17:02:11 +02:00
|
|
|
mavenLocal()
|
2018-07-18 18:23:06 +02:00
|
|
|
}
|
2018-07-18 18:44:38 +02:00
|
|
|
|
2021-06-24 18:58:24 +02:00
|
|
|
// Reproducible Builds
|
|
|
|
tasks.withType(AbstractArchiveTask) {
|
|
|
|
preserveFileTimestamps = false
|
|
|
|
reproducibleFileOrder = true
|
2022-06-19 22:14:11 +02:00
|
|
|
|
|
|
|
dirMode = 0755
|
|
|
|
fileMode = 0644
|
2021-06-24 18:58:24 +02:00
|
|
|
}
|
|
|
|
|
2023-09-01 13:43:04 +02:00
|
|
|
// Compatibility of default implementations in kotlin interfaces with Java implementations.
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
|
|
|
kotlinOptions {
|
|
|
|
freeCompilerArgs += ["-Xjvm-default=all-compatibility"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 14:28:41 +02:00
|
|
|
project.ext {
|
2018-07-18 18:44:38 +02:00
|
|
|
rootConfigDir = new File(rootDir, 'config')
|
|
|
|
gitCommit = getGitCommit()
|
2020-04-14 15:19:31 +02:00
|
|
|
isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
|
2018-07-18 18:44:38 +02:00
|
|
|
isReleaseVersion = !isSnapshot
|
2020-04-14 15:21:13 +02:00
|
|
|
signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
|
2018-07-18 18:44:38 +02:00
|
|
|
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
|
|
|
|
sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
|
|
|
|
sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSnapshot) {
|
|
|
|
version = version + '-SNAPSHOT'
|
|
|
|
}
|
2020-08-24 14:48:55 +02:00
|
|
|
def projectDirFile = new File("$projectDir")
|
|
|
|
if (!project.ext.isSnapshot && !'git describe --exact-match HEAD'.execute(null, projectDirFile).text.trim().equals(ext.shortVersion)) {
|
2018-07-18 18:44:38 +02:00
|
|
|
throw new InvalidUserDataException('Untagged version detected! Please tag every release.')
|
|
|
|
}
|
2020-08-24 14:48:55 +02:00
|
|
|
if (!version.endsWith('-SNAPSHOT') && version != 'git tag --points-at HEAD'.execute(null, projectDirFile).text.trim()) {
|
2018-07-18 18:44:38 +02:00
|
|
|
throw new InvalidUserDataException(
|
|
|
|
'Tag mismatch detected, version is ' + version + ' but should be ' +
|
2020-08-24 14:48:55 +02:00
|
|
|
'git tag --points-at HEAD'.execute(null, projectDirFile).text.trim())
|
2018-07-18 18:44:38 +02:00
|
|
|
}
|
|
|
|
|
2018-07-24 13:00:57 +02:00
|
|
|
jacoco {
|
2023-06-28 14:06:27 +02:00
|
|
|
toolVersion = "0.8.8"
|
2018-07-24 13:00:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
jacocoTestReport {
|
|
|
|
dependsOn test
|
2020-01-09 19:05:50 +01:00
|
|
|
sourceDirectories.setFrom(project.files(sourceSets.main.allSource.srcDirs))
|
|
|
|
classDirectories.setFrom(project.files(sourceSets.main.output))
|
2018-07-24 13:00:57 +02:00
|
|
|
reports {
|
|
|
|
xml.enabled true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-13 16:31:59 +01:00
|
|
|
test {
|
|
|
|
useJUnitPlatform()
|
2021-04-26 13:38:12 +02:00
|
|
|
testLogging {
|
|
|
|
events "passed", "skipped", "failed"
|
|
|
|
exceptionFormat "full"
|
|
|
|
}
|
2020-11-13 16:31:59 +01:00
|
|
|
}
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
|
|
|
|
2018-07-18 18:23:06 +02:00
|
|
|
subprojects {
|
2020-04-14 15:19:31 +02:00
|
|
|
apply plugin: 'maven-publish'
|
2018-07-18 18:23:06 +02:00
|
|
|
apply plugin: 'signing'
|
|
|
|
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
|
|
classifier = 'sources'
|
|
|
|
from sourceSets.main.allSource
|
|
|
|
}
|
|
|
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
|
|
classifier = 'javadoc'
|
|
|
|
from javadoc.destinationDir
|
|
|
|
}
|
2020-04-14 15:19:31 +02:00
|
|
|
task testsJar(type: Jar, dependsOn: testClasses) {
|
2018-07-18 18:23:06 +02:00
|
|
|
classifier = 'tests'
|
|
|
|
from sourceSets.test.output
|
|
|
|
}
|
|
|
|
|
2020-04-14 15:19:31 +02:00
|
|
|
publishing {
|
|
|
|
publications {
|
|
|
|
mavenJava(MavenPublication) {
|
|
|
|
from components.java
|
|
|
|
artifact sourcesJar
|
|
|
|
artifact javadocJar
|
|
|
|
artifact testsJar
|
|
|
|
pom {
|
|
|
|
name = 'PGPainless'
|
2020-04-16 12:05:43 +02:00
|
|
|
description = 'Simple to use OpenPGP API for Java based on Bouncycastle'
|
2020-04-14 15:19:31 +02:00
|
|
|
url = 'https://github.com/pgpainless/pgpainless'
|
|
|
|
inceptionYear = '2018'
|
2018-07-18 18:23:06 +02:00
|
|
|
|
|
|
|
scm {
|
2020-04-14 15:19:31 +02:00
|
|
|
url = 'https://github.com/pgpainless/pgpainless'
|
|
|
|
connection = 'scm:https://github.com/pgpainless/pgpainless'
|
|
|
|
developerConnection = 'scm:git://github.com/pgpainless/pgpainless.git'
|
2018-07-18 18:23:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
licenses {
|
|
|
|
license {
|
2020-04-14 15:19:31 +02:00
|
|
|
name = 'The Apache Software License, Version 2.0'
|
|
|
|
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
|
|
distribution = 'repo'
|
2018-07-18 18:23:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
developers {
|
|
|
|
developer {
|
2020-04-14 15:19:31 +02:00
|
|
|
id = 'vanitasvitae'
|
|
|
|
name = 'Paul Schaub'
|
|
|
|
email = 'vanitasvitae@fsfe.org'
|
2018-07-18 18:23:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-14 15:19:31 +02:00
|
|
|
repositories {
|
|
|
|
if (sonatypeCredentialsAvailable) {
|
|
|
|
maven {
|
|
|
|
url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
|
|
|
|
credentials {
|
|
|
|
username = sonatypeUsername
|
|
|
|
password = sonatypePassword
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-18 18:23:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
signing {
|
2020-04-14 15:21:13 +02:00
|
|
|
useGpgCmd()
|
2018-07-18 18:23:06 +02:00
|
|
|
required { signingRequired }
|
2020-04-14 15:19:31 +02:00
|
|
|
sign publishing.publications.mavenJava
|
2018-07-18 18:23:06 +02:00
|
|
|
}
|
2018-06-02 21:21:35 +02:00
|
|
|
}
|
2018-07-18 18:23:06 +02:00
|
|
|
|
2018-07-18 18:44:38 +02:00
|
|
|
def getGitCommit() {
|
2020-08-24 14:48:55 +02:00
|
|
|
def projectDirFile = new File("$projectDir")
|
2018-07-18 18:44:38 +02:00
|
|
|
def dotGit = new File("$projectDir/.git")
|
|
|
|
if (!dotGit.isDirectory()) return 'non-git build'
|
|
|
|
|
|
|
|
def cmd = 'git describe --always --tags --dirty=+'
|
2020-08-24 14:48:55 +02:00
|
|
|
def proc = cmd.execute(null, projectDirFile)
|
2018-07-18 18:44:38 +02:00
|
|
|
def gitCommit = proc.text.trim()
|
|
|
|
assert !gitCommit.isEmpty()
|
|
|
|
|
|
|
|
def srCmd = 'git symbolic-ref --short HEAD'
|
2020-08-24 14:48:55 +02:00
|
|
|
def srProc = srCmd.execute(null, projectDirFile)
|
2018-07-18 18:44:38 +02:00
|
|
|
srProc.waitForOrKill(10 * 1000)
|
|
|
|
if (srProc.exitValue() == 0) {
|
|
|
|
// Only add the information if the git command was
|
|
|
|
// successful. There may be no symbolic reference for HEAD if
|
|
|
|
// e.g. in detached mode.
|
|
|
|
def symbolicReference = srProc.text.trim()
|
|
|
|
assert !symbolicReference.isEmpty()
|
|
|
|
gitCommit += "-$symbolicReference"
|
|
|
|
}
|
|
|
|
|
|
|
|
gitCommit
|
|
|
|
}
|
|
|
|
|
2018-07-24 16:23:24 +02:00
|
|
|
apply plugin: "com.github.kt3k.coveralls"
|
|
|
|
coveralls {
|
|
|
|
sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
|
|
|
|
}
|
|
|
|
|
2018-07-24 13:00:57 +02:00
|
|
|
task jacocoRootReport(type: JacocoReport) {
|
2018-07-24 17:31:21 +02:00
|
|
|
dependsOn = subprojects.jacocoTestReport
|
2020-01-09 19:05:50 +01:00
|
|
|
sourceDirectories.setFrom(files(subprojects.sourceSets.main.allSource.srcDirs))
|
|
|
|
classDirectories.setFrom(files(subprojects.sourceSets.main.output))
|
|
|
|
executionData.setFrom(files(subprojects.jacocoTestReport.executionData))
|
2018-07-24 13:00:57 +02:00
|
|
|
reports {
|
|
|
|
xml.enabled true
|
|
|
|
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
|
|
|
|
}
|
|
|
|
// We could remove the following setOnlyIf line, but then
|
|
|
|
// jacocoRootReport would silently be SKIPPED if something with
|
|
|
|
// the projectsWithUnitTests is wrong (e.g. a project is missing
|
|
|
|
// in there).
|
|
|
|
setOnlyIf { true }
|
|
|
|
}
|
2018-07-24 17:31:21 +02:00
|
|
|
|
2018-07-18 18:44:38 +02:00
|
|
|
task javadocAll(type: Javadoc) {
|
2020-08-30 22:34:29 +02:00
|
|
|
def currentJavaVersion = JavaVersion.current()
|
|
|
|
if (currentJavaVersion.compareTo(JavaVersion.VERSION_1_9) >= 0) {
|
|
|
|
options.addStringOption("-release", "8");
|
|
|
|
}
|
2018-07-18 18:44:38 +02:00
|
|
|
source subprojects.collect {project ->
|
|
|
|
project.sourceSets.main.allJava }
|
|
|
|
destinationDir = new File(buildDir, 'javadoc')
|
|
|
|
// Might need a classpath
|
|
|
|
classpath = files(subprojects.collect {project ->
|
|
|
|
project.sourceSets.main.compileClasspath})
|
|
|
|
options.linkSource = true
|
|
|
|
options.use = true
|
|
|
|
options.links = [
|
|
|
|
"https://docs.oracle.com/javase/${sourceCompatibility.getMajorVersion()}/docs/api/",
|
|
|
|
] as String[]
|
|
|
|
}
|
2022-12-05 13:47:54 +01:00
|
|
|
|
2023-01-16 19:38:52 +01:00
|
|
|
if (JavaVersion.current().isJava8Compatible()) {
|
|
|
|
tasks.withType(Javadoc) {
|
|
|
|
// The '-quiet' as second argument is actually a hack,
|
|
|
|
// since the one paramater addStringOption doesn't seem to
|
|
|
|
// work, we extra add '-quiet', which is added anyway by
|
|
|
|
// gradle. See https://github.com/gradle/gradle/issues/2354
|
|
|
|
// See JDK-8200363 (https://bugs.openjdk.java.net/browse/JDK-8200363)
|
|
|
|
// for information about the -Xwerror option.
|
|
|
|
options.addStringOption('Xwerror', '-quiet')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-05 13:47:54 +01:00
|
|
|
/**
|
|
|
|
* Fetch sha256 checksums of artifacts published to maven central.
|
|
|
|
*
|
|
|
|
* Example: gradle -Prelease=1.3.13 mavenCentralChecksums
|
|
|
|
*/
|
|
|
|
task mavenCentralChecksums() {
|
|
|
|
description 'Fetch and display checksums for artifacts published to Maven Central'
|
|
|
|
String ver = project.hasProperty('release') ? release : shortVersion
|
|
|
|
doLast {
|
|
|
|
Process p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-core/${ver}/pgpainless-core-${ver}.jar.sha256".execute()
|
|
|
|
if (p.waitFor() == 0) {
|
|
|
|
print p.text.trim()
|
|
|
|
println " pgpainless-core/build/libs/pgpainless-core-${ver}.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-sop/${ver}/pgpainless-sop-${ver}.jar.sha256".execute()
|
|
|
|
if (p.waitFor() == 0) {
|
|
|
|
print p.text.trim()
|
|
|
|
println " pgpainless-sop/build/libs/pgpainless-sop-${ver}.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-cli/${ver}/pgpainless-cli-${ver}-all.jar.sha256".execute()
|
|
|
|
if (p.waitFor() == 0) {
|
|
|
|
print p.text.trim()
|
|
|
|
println " pgpainless-cli/build/libs/pgpainless-cli-${ver}-all.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/pgpainless-cli/${ver}/pgpainless-cli-${ver}.jar.sha256".execute()
|
|
|
|
if (p.waitFor() == 0) {
|
|
|
|
print p.text.trim()
|
|
|
|
println " pgpainless-cli/build/libs/pgpainless-cli-${ver}.jar"
|
|
|
|
}
|
|
|
|
|
|
|
|
p = "curl -f https://repo1.maven.org/maven2/org/pgpainless/hsregex/${ver}/hsregex-${ver}.jar.sha256".execute()
|
|
|
|
if (p.waitFor() == 0) {
|
|
|
|
print p.text.trim()
|
|
|
|
println " hsregex/build/libs/hsregex-${ver}.jar"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|