forked from remkop/picocli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
160 lines (140 loc) · 5.47 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import aQute.bnd.gradle.Bundle
group 'info.picocli'
description 'Java command line parser with both an annotations API and a programmatic API. Usage help with ANSI styles and colors. Autocomplete. Nested subcommands. Easily included as source to avoid adding a dependency.'
version "$projectVersion"
ext.moduleName = 'info.picocli'
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-jvm:$asciidoctorGradlePluginVersion"
classpath 'org.asciidoctor:asciidoctorj-pdf:1.6.0'
classpath "gradle.plugin.org.beryx:badass-jar:1.2.0"
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:6.1.0'
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
}
}
apply plugin: "org.beryx.jar"
apply plugin: 'io.codearte.nexus-staging'
if (System.getenv('MAVEN_OSS_USER')) { // on home system
apply plugin: 'biz.aQute.bnd.builder'
} else {
try { // otherwise, only apply if available
Class.forName('aQute.bnd.gradle.BndPlugin')
Class.forName('aQute.bnd.build.Project')
apply plugin: 'biz.aQute.bnd.builder'
} catch (Throwable ignored) {}
}
pluginManager.withPlugin('biz.aQute.bnd.builder') { // if plugin applied, execute this action
configurations {
bundleCompile
baseline
}
dependencies {
baseline('group': group, 'name': jar.archiveBaseName) {
version {
strictly "(,${jar.archiveVersion}["
}
transitive = false
}
}
sourceSets {
bundle
}
task bundle(type: Bundle) {
from sourceSets.bundle.output
bndfile = 'bnd.bnd'
sourceSet = sourceSets.bundle
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'java-library' // to avoid https://github.com/gradle/gradle/issues/1118
sourceCompatibility = !JavaVersion.current().isJava9Compatible() ?
1.5 : JavaVersion.current().isJava11Compatible() ? 1.7 : 1.6
targetCompatibility = !JavaVersion.current().isJava9Compatible() ?
1.5 : JavaVersion.current().isJava11Compatible() ? 1.7 : 1.6
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
repositories {
maven { url 'https://repo.spring.io/libs-snapshot' }
mavenCentral()
}
configurations.all {
resolutionStrategy {
// avoid "Could not resolve junit:junit-dep:[4.9,)" caused by stefanbirkner:system-rules when building offline
force "junit:junit-dep:$junitDepVersion"
}
}
dependencies {
testImplementation "junit:junit:$junitVersion",
"org.hamcrest:hamcrest-core:$hamcrestCoreVersion",
"org.fusesource.jansi:jansi:$jansiVersion",
"org.codehaus.groovy:groovy-all:$groovyVersion",
"com.github.stefanbirkner:system-rules:$systemRulesVersion",
"pl.pragmatists:JUnitParams:1.1.1"
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
javadoc.destinationDir = file("build/docs/apidocs")
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
// work around https://github.com/gradle/gradle/issues/4046
javadoc.dependsOn('copyJavadocDocFiles')
task copyJavadocDocFiles(type: Copy) {
from('src/main/java')
into 'build/docs/apidocs'
include '**/doc-files/*.*'
}
}
sourceSets.main.java.srcDirs = ['src/main/java', 'src/main/java9']
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
if (JavaVersion.current().isJava9Compatible()) {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
}
classpath = files()
}
}
jar {
manifest {
attributes 'Specification-Title' : 'picocli',
'Specification-Vendor' : 'Remko Popma',
'Specification-Version' : archiveVersion.get(),
'Implementation-Title' : 'picocli',
'Implementation-Vendor' : 'Remko Popma',
'Implementation-Version': archiveVersion.get(),
'Main-Class' : 'picocli.AutoComplete'
}
// copy module-info.class to META-INF/versions/9
multiRelease = true
}
// jacoco 0.8.2 does not work with Java 13; gradle 4.x has no JavaVersion enum value for Java 12
if (JavaVersion.current().isJava11Compatible()) {
project.logger.lifecycle("skipping jacoco test for Java version ${JavaVersion.current()}")
} else {
project.logger.lifecycle("applying jacoco build file for Java version ${JavaVersion.current()}")
apply from: "gradle/jacoco.gradle"
}
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_18)) {
// https://github.com/remkop/picocli/issues/1503
test { // explicitly enable security manager on Java 18 for System.exit tests
systemProperty "java.security.manager", "allow"
}
}
// javadoc and asciidoc customization
apply from: "${rootProject.projectDir}/gradle/docs.gradle"
// publishing-related
ext {
PUBLISH_GROUP_ID = group
PUBLISH_ARTIFACT_ID = project.name
PUBLISH_VERSION = "$projectVersion"
}
apply from: "${rootProject.projectDir}/gradle/publish-mavencentral.gradle"
// release-related custom gradle tasks and release procedure steps
apply from: "${rootProject.projectDir}/gradle/release-tasks.gradle"