Skip to content

Commit 8e39b32

Browse files
committed
Port webauthn-server-attestation/build.gradle to build.gradle.kts
1 parent d6744bd commit 8e39b32

File tree

5 files changed

+126
-122
lines changed

5 files changed

+126
-122
lines changed

build.gradle

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ plugins {
1818

1919
import io.franzbecker.gradle.lombok.LombokPlugin
2020
import io.franzbecker.gradle.lombok.task.DelombokTask
21+
import com.yubico.gradle.GitUtils;
2122

2223
rootProject.description = "Metadata root for the com.yubico:webauthn-server-* module family"
2324

@@ -116,19 +117,6 @@ task assembleJavadoc(type: Sync) {
116117
destinationDir = file("${rootProject.buildDir}/javadoc")
117118
}
118119

119-
String getGitCommit() {
120-
def proc = "git rev-parse HEAD".execute(null, projectDir)
121-
proc.waitFor()
122-
if (proc.exitValue() != 0) {
123-
return null
124-
}
125-
return proc.text.trim()
126-
}
127-
128-
String getGitCommitOrUnknown() {
129-
return getGitCommit() ?: 'UNKNOWN'
130-
}
131-
132120
subprojects { project ->
133121

134122
if (project.plugins.hasPlugin('scala') && project.plugins.hasPlugin('com.diffplug.spotless')) {
@@ -207,7 +195,7 @@ subprojects { project ->
207195

208196
if (project.hasProperty('publishMe') && project.publishMe) {
209197

210-
if (getGitCommit() == null) {
198+
if (GitUtils.getGitCommit(projectDir) == null) {
211199
throw new RuntimeException("Failed to get git commit ID");
212200
}
213201

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.yubico.gradle;
2+
3+
public class GitUtils {
4+
5+
public static String getGitCommit(File projectDir) {
6+
def proc = "git rev-parse HEAD".execute(null, projectDir)
7+
proc.waitFor()
8+
if (proc.exitValue() != 0) {
9+
return null
10+
}
11+
return proc.text.trim()
12+
}
13+
14+
public static String getGitCommitOrUnknown(projectDir) {
15+
return getGitCommit(projectDir) ?: 'UNKNOWN'
16+
}
17+
18+
}

webauthn-server-attestation/build.gradle

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import com.yubico.gradle.GitUtils;
2+
plugins {
3+
`java-library`
4+
scala
5+
`maven-publish`
6+
signing
7+
id("com.diffplug.spotless")
8+
id("info.solidsoft.pitest")
9+
id("io.github.cosmicsilence.scalafix")
10+
}
11+
12+
description = "Yubico WebAuthn attestation subsystem"
13+
14+
val publishMe by extra(true)
15+
16+
java {
17+
sourceCompatibility = JavaVersion.VERSION_1_8
18+
targetCompatibility = JavaVersion.VERSION_1_8
19+
}
20+
21+
sourceSets {
22+
create("integrationTest") {
23+
compileClasspath += sourceSets.main.get().output
24+
runtimeClasspath += sourceSets.main.get().output
25+
}
26+
}
27+
28+
configurations["integrationTestImplementation"].extendsFrom(configurations.testImplementation.get())
29+
configurations["integrationTestRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
30+
31+
// Can't use test fixtures because they interfere with pitest: https://github.com/gradle/gradle/issues/12168
32+
evaluationDependsOn(":webauthn-server-core")
33+
val coreTestsOutput = project(":webauthn-server-core").extensions.getByType(SourceSetContainer::class).test.get().output
34+
35+
dependencies {
36+
api(platform(rootProject))
37+
38+
api(project(":webauthn-server-core"))
39+
40+
implementation(project(":yubico-util"))
41+
implementation("com.google.guava:guava")
42+
implementation("com.fasterxml.jackson.core:jackson-databind")
43+
implementation("org.bouncycastle:bcprov-jdk15on")
44+
implementation("org.slf4j:slf4j-api")
45+
46+
testImplementation(platform(project(":test-platform")))
47+
testImplementation(coreTestsOutput)
48+
testImplementation(project(":yubico-util-scala"))
49+
testImplementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")
50+
testImplementation("junit:junit")
51+
testImplementation("org.bouncycastle:bcpkix-jdk15on")
52+
testImplementation("org.eclipse.jetty:jetty-server:[9.4.9.v20180320,10)")
53+
testImplementation("org.mockito:mockito-core")
54+
testImplementation("org.scala-lang:scala-library")
55+
testImplementation("org.scalacheck:scalacheck_2.13")
56+
testImplementation("org.scalatest:scalatest_2.13")
57+
testImplementation("uk.org.lidalia:slf4j-test")
58+
59+
testImplementation("org.slf4j:slf4j-api") {
60+
version {
61+
strictly("[1.7.25,1.8-a)") // Pre-1.8 version required by slf4j-test
62+
}
63+
}
64+
}
65+
66+
val integrationTest = task<Test>("integrationTest") {
67+
description = "Runs integration tests."
68+
group = "verification"
69+
70+
testClassesDirs = sourceSets["integrationTest"].output.classesDirs
71+
classpath = sourceSets["integrationTest"].runtimeClasspath
72+
shouldRunAfter(tasks.test)
73+
74+
// Required for processing CRL distribution points extension
75+
systemProperty("com.sun.security.enableCRLDP", "true")
76+
}
77+
tasks["check"].dependsOn(integrationTest)
78+
79+
tasks.jar {
80+
manifest {
81+
attributes(mapOf(
82+
"Implementation-Id" to "java-webauthn-server-attestation",
83+
"Implementation-Title" to project.description,
84+
"Implementation-Version" to project.version,
85+
"Implementation-Vendor" to "Yubico",
86+
"Git-Commit" to GitUtils.getGitCommitOrUnknown(projectDir),
87+
))
88+
}
89+
}
90+
91+
pitest {
92+
pitestVersion.set("1.4.11")
93+
timestampedReports.set(false)
94+
95+
outputFormats.set(listOf("XML", "HTML"))
96+
97+
avoidCallsTo.set(listOf(
98+
"java.util.logging",
99+
"org.apache.log4j",
100+
"org.slf4j",
101+
"org.apache.commons.logging",
102+
"com.google.common.io.Closeables",
103+
))
104+
}

webauthn-server-core/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import com.yubico.gradle.GitUtils;
12
plugins {
23
id 'java-library'
34
id 'scala'
@@ -69,7 +70,7 @@ jar {
6970
'Implementation-Version': project.version,
7071
'Implementation-Vendor': 'Yubico',
7172
'Implementation-Source-Url': 'https://github.com/Yubico/java-webauthn-server',
72-
'Git-Commit': getGitCommitOrUnknown(),
73+
'Git-Commit': GitUtils.getGitCommitOrUnknown(projectDir),
7374
])
7475
}
7576
}

0 commit comments

Comments
 (0)