| 1 |
|
| 2 |
plugins { |
| 3 |
id 'com.diffplug.spotless' version "5.17.1" apply false |
| 4 |
id "com.palantir.consistent-versions" version "2.5.0" |
| 5 |
} |
| 6 |
|
| 7 |
apply from: file('gradle/min-gradle-version.gradle') |
| 8 |
apply from: file('gradle/gitinfo.gradle') |
| 9 |
apply from: file('gradle/buildinfo.gradle') |
| 10 |
|
| 11 |
apply plugin: 'base' |
| 12 |
|
| 13 |
def currentVersion = '1.0.7-SNAPSHOT' |
| 14 |
|
| 15 |
ext { |
| 16 |
gitRev = gitStatus.id |
| 17 |
|
| 18 |
licenseHeader = file('etc/license-header.txt') |
| 19 |
|
| 20 |
replaceTokens = [ |
| 21 |
'version': currentVersion, |
| 22 |
'gitRev': gitRev, |
| 23 |
'buildDate': buildDate, |
| 24 |
'buildDateTrimmed': buildDateTrimmed |
| 25 |
] |
| 26 |
|
| 27 |
isIdea = System.getProperty("idea.active") != null || gradle.startParameter.taskNames.contains('idea') || gradle.startParameter.taskNames.contains('cleanIdea') |
| 28 |
} |
| 29 |
|
| 30 |
allprojects { |
| 31 |
apply plugin: 'idea' |
| 32 |
|
| 33 |
group "com.carrotsearch" |
| 34 |
version = currentVersion |
| 35 |
|
| 36 |
repositories { |
| 37 |
mavenCentral() |
| 38 |
} |
| 39 |
|
| 40 |
idea { |
| 41 |
module { |
| 42 |
outputDir file('build/idea/classes/main') |
| 43 |
testOutputDir file('build/idea/classes/test') |
| 44 |
downloadSources = true |
| 45 |
} |
| 46 |
|
| 47 |
project { |
| 48 |
jdkName = '9' |
| 49 |
languageLevel = '1.9' |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
allprojects { |
| 55 |
apply plugin: 'java' |
| 56 |
apply plugin: 'com.diffplug.spotless' |
| 57 |
|
| 58 |
sourceCompatibility = 1.9 |
| 59 |
targetCompatibility = 1.9 |
| 60 |
|
| 61 |
dependencies { |
| 62 |
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner" |
| 63 |
testImplementation "org.assertj:assertj-core" |
| 64 |
testImplementation "com.google.guava:guava" |
| 65 |
} |
| 66 |
|
| 67 |
spotless { |
| 68 |
java { |
| 69 |
licenseHeaderFile licenseHeader |
| 70 |
lineEndings 'UNIX' |
| 71 |
endWithNewline() |
| 72 |
googleJavaFormat('1.13.0') |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
test { |
| 77 |
maxParallelForks = (int) Math.max(Runtime.runtime.availableProcessors() / 2.0, 4.0) |
| 78 |
} |
| 79 |
|
| 80 |
tasks.withType(JavaCompile) { |
| 81 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
| 82 |
options.encoding = "UTF-8" |
| 83 |
} |
| 84 |
|
| 85 |
tasks.withType(Jar) { |
| 86 |
manifest { |
| 87 |
attributes("Implementation-Title": project.name, |
| 88 |
"Implementation-Version": "${project.version} (${gitRev}, ${buildDateTrimmed})") |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
javadoc { |
| 93 |
title = "${project.name} ${project.version} API Documentation" |
| 94 |
|
| 95 |
if (JavaVersion.current().isJava9Compatible()) { |
| 96 |
options.addBooleanOption('html5', true) |
| 97 |
options.addStringOption('Xdoclint:all,-missing', '-noindex') |
| 98 |
} |
| 99 |
|
| 100 |
options.encoding = 'UTF-8' |
| 101 |
} |
| 102 |
|
| 103 |
afterEvaluate { |
| 104 |
check.dependsOn(spotlessCheck) |
| 105 |
precommit.dependsOn(spotlessCheck) |
| 106 |
|
| 107 |
tasks.withType(AbstractArchiveTask) { |
| 108 |
duplicatesStrategy = 'fail' |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
task precommit { |
| 114 |
description "Runs code quality and other precommit checks" |
| 115 |
group "Verification" |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
configure(project) { |
| 120 |
apply plugin: 'maven-publish' |
| 121 |
apply plugin: 'signing' |
| 122 |
|
| 123 |
def mavenBuildRepo = "${rootProject.buildDir}/maven" |
| 124 |
|
| 125 |
task sourcesJar(type: Jar, dependsOn: classes) { |
| 126 |
archiveClassifier = 'sources' |
| 127 |
from sourceSets.main.allJava |
| 128 |
} |
| 129 |
|
| 130 |
task javadocJar(type: Jar, dependsOn: javadoc) { |
| 131 |
archiveClassifier = 'javadoc' |
| 132 |
from javadoc.destinationDir |
| 133 |
} |
| 134 |
|
| 135 |
publishing { |
| 136 |
repositories { |
| 137 |
maven { |
| 138 |
name = 'build' |
| 139 |
url = mavenBuildRepo |
| 140 |
} |
| 141 |
maven { |
| 142 |
name = 'sonatype' |
| 143 |
url "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" |
| 144 |
credentials { |
| 145 |
if (project.hasProperty('nexusUsername')) { |
| 146 |
username project.nexusUsername |
| 147 |
} |
| 148 |
if (project.hasProperty('nexusPassword')) { |
| 149 |
password project.nexusPassword |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
publications { |
| 156 |
maven(MavenPublication) { |
| 157 |
afterEvaluate { |
| 158 |
from components.java |
| 159 |
artifactId = project.archivesBaseName |
| 160 |
|
| 161 |
artifact sourcesJar |
| 162 |
artifact javadocJar |
| 163 |
} |
| 164 |
|
| 165 |
pom { |
| 166 |
name = "${project.name}" |
| 167 |
description = "${project.name}" |
| 168 |
url = 'https://github.com/carrotsearch/procfork' |
| 169 |
inceptionYear = "2019" |
| 170 |
licenses { |
| 171 |
license { |
| 172 |
name = 'BSD License' |
| 173 |
url = 'https://github.com/carrotsearch/procfork/blob/master/LICENSE.txt' |
| 174 |
} |
| 175 |
} |
| 176 |
organization { |
| 177 |
name = "Carrot Search s.c." |
| 178 |
url = "https://www.carrotsearch.com" |
| 179 |
} |
| 180 |
developers { |
| 181 |
developer { |
| 182 |
id = 'stanislaw.osinski' |
| 183 |
name = 'Stanisław Osiński' |
| 184 |
email = '[email protected]' |
| 185 |
} |
| 186 |
developer { |
| 187 |
id = 'dawid.weiss' |
| 188 |
name = 'Dawid Weiss' |
| 189 |
email = '[email protected]' |
| 190 |
} |
| 191 |
} |
| 192 |
scm { |
| 193 |
connection = 'scm:git:[email protected]:carrotsearch/procfork.git' |
| 194 |
developerConnection = 'scm:git:[email protected]:carrotsearch/procfork.git' |
| 195 |
url = 'https://github.com/carrotsearch/procfork' |
| 196 |
} |
| 197 |
} |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
signing { |
| 203 |
sign publishing.publications.maven |
| 204 |
} |
| 205 |
|
| 206 |
afterEvaluate { |
| 207 |
task mavenLocal(dependsOn: publishMavenPublicationToBuildRepository) { |
| 208 |
group "Publishing" |
| 209 |
description "Publish Maven artifacts locally to " + file(mavenBuildRepo) |
| 210 |
} |
| 211 |
|
| 212 |
task mavenSonatype(dependsOn: publishMavenPublicationToSonatypeRepository) { |
| 213 |
group "Publishing" |
| 214 |
description "Publish Maven artifacts to Sonatype OSS Nexus" |
| 215 |
} |
| 216 |
} |
| 217 |
} |