mirrored from https://www.bouncycastle.org/repositories/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathbuild.gradle
More file actions
163 lines (126 loc) · 4.64 KB
/
build.gradle
File metadata and controls
163 lines (126 loc) · 4.64 KB
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
161
162
163
plugins {
id "biz.aQute.bnd.builder" version "7.1.0"
}
sourceSets {
java9 {
java {
srcDirs = ['src/main/jdk1.9']
}
}
}
dependencies {
implementation project(':prov')
implementation project(':util')
java9Implementation project(':prov')
java9Implementation project(':util')
java9Implementation files(sourceSets.main.output.classesDirs) {
builtBy compileJava
}
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
}
evaluationDependsOn(":prov")
evaluationDependsOn(":util")
// Stamp the current project version into the BCPG default-version string in
// ArmoredOutputStream and the matching PGP-armored test inputs. Operates in
// place (no generated-src copy) and is idempotent: files are only rewritten
// when their stamped content actually differs, so a clean checkout matching
// the gradle version produces no working-tree diff and downstream compile
// tasks stay UP-TO-DATE.
//
// The stamped set is explicit rather than tree-walked because several test
// classes pin historical BCPG version strings (e.g. v1.32, v1.68) as parser
// fixtures and must not be rewritten.
task stampVersion {
description = 'Stamps the current project version into ArmoredOutputStream and the matching PGP-armored test inputs.'
doLast {
def stamp = "BCPG v${version}".toString()
def pattern = ~/BCPG v\d+(?:\.\d+){1,2}(?:-SNAPSHOT)?/
def filesToStamp = [
file('src/main/java/org/bouncycastle/bcpg/ArmoredOutputStream.java'),
file('src/main/jdk1.4/org/bouncycastle/bcpg/ArmoredOutputStream.java'),
file('src/test/java/org/bouncycastle/openpgp/test/ECDSAKeyPairTest.java'),
file('src/test/java/org/bouncycastle/openpgp/test/PGPv6SignatureTest.java'),
file('src/test/java/org/bouncycastle/bcpg/test/BCPGOutputStreamTest.java')
]
filesToStamp.each { f ->
def text = f.text
def updated = pattern.matcher(text).replaceAll(stamp)
if (updated != text) {
f.text = updated
logger.lifecycle("Stamped ${stamp} into ${f}")
}
}
}
}
compileJava.dependsOn stampVersion
compileTestJava.dependsOn stampVersion
compileJava {
options.release = 8
}
compileJava9Java {
options.release = 9
def prov_jar="${project(":prov").jar.outputs.files.getFiles().getAt(0)}"
def util_jar="${project(":util").jar.outputs.files.getFiles().getAt(0)}"
options.compilerArgs += [
'--module-path', "${prov_jar}${File.pathSeparator}${util_jar}"
]
options.sourcepath = files(['src/main/java', 'src/main/jdk1.9'])
}
jar.archiveBaseName = "bcpg-$vmrange"
task sourcesJar(type: Jar) {
dependsOn stampVersion
archiveBaseName = jar.archiveBaseName
archiveClassifier = 'sources'
from sourceSets.main.allSource
exclude("**/*.so")
into('META-INF/versions/9') {
from sourceSets.java9.allSource
}
}
jar {
from sourceSets.main.output
into('META-INF/versions/9') {
from sourceSets.java9.output
}
String v = "${rootProject.extensions.ext.bundle_version}"
manifest.attributes('Multi-Release': 'true')
manifest.attributes('Bundle-RequiredExecutionEnvironment': 'JavaSE-1.8')
manifest.attributes('Bundle-Name': 'bcpg')
manifest.attributes('Bundle-SymbolicName': 'bcpg')
manifest.attributes('Export-Package': "org.bouncycastle.{apache|bcpg|gpg|openpgp}.*;version=${v}")
manifest.attributes('Import-Package': "java.*;resolution:=optional,javax.*;resolution:=optional,!org.bouncycastle.{apache|bcpg|gpg|openpgp|}.*,org.bouncycastle.*;version=\"[${v},${maxVersion})\"")
manifest.attributes('Bundle-Version': "${v}")
manifest.attributes('Permissions': 'all-permissions')
manifest.attributes('Codebase': '*')
manifest.attributes('Application-Library-Allowable-Codebase': '*')
manifest.attributes('Caller-Allowable-Codebase': '*')
manifest.attributes('Trusted-Library': 'true')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveBaseName = jar.archiveBaseName
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
test {
forkEvery = 1;
maxParallelForks = 8;
maxHeapSize = "3g";
jvmArgs = ['-Dtest.java.version.prefix=any']
}
compileJava9Java.dependsOn([":prov:jar", ":util:jar"])
publishing {
publications {
maven(MavenPublication) {
groupId = 'org.bouncycastle'
artifactId = "bcpg-$vmrange"
from components.java
artifact(javadocJar)
artifact(sourcesJar)
}
}
}