Skip to content

Commit

Permalink
Gradle tidy-up. (#1242)
Browse files Browse the repository at this point in the history
Use central version repository for dependencies (current
best practice)

Fix Jacoco coverage reports.
Start fixing JMH benchmarks.

General warning fixes.

Remove some unused plugins, e.g. Truth, Roboelectric.
  • Loading branch information
prbprbprb authored Oct 23, 2024
1 parent 7f1e02b commit 8c8a05f
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 87 deletions.
6 changes: 1 addition & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ buildscript {
mavenCentral()
}
dependencies {
classpath libraries.android_tools
classpath libs.android.tools
}
}

plugins {
id 'digital.wup.android-maven-publish' version '3.6.2'
}

description = 'Conscrypt: Android'

ext {
Expand Down
8 changes: 4 additions & 4 deletions benchmark-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath libraries.android_tools
classpath libs.android.tools
}
}

Expand Down Expand Up @@ -61,14 +61,14 @@ if (androidSdkInstalled) {

dependencies {
depsJarApi project(path: ':conscrypt-android'),
libraries.bouncycastle_provider,
libraries.bouncycastle_apis
libs.bouncycastle.provider,
libs.bouncycastle.apis

depsJarImplementation project(':conscrypt-benchmark-base'),
project(path: ":conscrypt-testing", configuration: "shadow"),
project(':conscrypt-libcore-stub')

implementation 'com.google.caliper:caliper:1.0-beta-2'
implementation libs.caliper
}

// This task bundles up everything we're going to send to the device into a single jar.
Expand Down
2 changes: 1 addition & 1 deletion benchmark-base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ description = 'Conscrypt: Base library for benchmarks'

dependencies {
implementation project(path: ":conscrypt-testing", configuration: "shadow"),
libraries.junit
libs.junit
}
29 changes: 14 additions & 15 deletions benchmark-jmh/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
plugins {
id 'me.champeau.gradle.jmh' version '0.5.3'
alias libs.plugins.jmh
}

apply plugin: 'idea'

description = 'Conscrypt: JMH on OpenJDK Benchmarks'

evaluationDependsOn(':conscrypt-openjdk')
Expand Down Expand Up @@ -31,13 +29,13 @@ jmh {
setBenchmarkParameters(parseParams(jmhParams))
}
warmupIterations = "$jmhWarmupIterations".toInteger()
iterations = "$jmhIterations".toInteger();
iterations = "$jmhIterations".toInteger()
fork = "$jmhFork".toInteger()
jvmArgs = jmhJvmArgs.toString()
// jvmArgs = jmhJvmArgs
if (jmhJvm != null) {
jvm = jmhJvm
}
duplicateClassesStrategy = 'warn'
duplicateClassesStrategy = DuplicatesStrategy.WARN
}

configurations {
Expand Down Expand Up @@ -65,20 +63,21 @@ sourceSets {
}

dependencies {
implementation project(path: ":conscrypt-openjdk", configuration: "runtimeElements"),
implementation project(":conscrypt-openjdk"),
project(path: ":conscrypt-testing", configuration: "runtimeElements"),
project(':conscrypt-benchmark-base'),
// Add the preferred native openjdk configuration for this platform.
project(':conscrypt-openjdk').sourceSets["$preferredSourceSet"].output,
libraries.junit,
libraries.netty_handler,
libraries.netty_tcnative
//project(':conscrypt-openjdk').sourceSets["$preferredSourceSet"].output,
libs.junit,
libs.netty.handler,
libs.netty.tcnative

jmhGeneratorAnnprocess libraries.jmh_generator_annprocess
jmhGeneratorAnnprocess libs.jmh.generator.annprocess

// Override the default JMH dependencies with the new versions.
jmh libraries.jmh_core,
libraries.jmh_generator_reflection,
libraries.jmh_generator_bytecode
jmh libs.jmh.core,
libs.jmh.generator.reflection,
libs.jmh.generator.bytecode
}

// Running benchmarks in IntelliJ seems broken without this.
Expand Down
58 changes: 21 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@ import org.ajoberstar.grgit.Grgit
import org.gradle.util.VersionNumber

buildscript {
ext.android_tools = 'com.android.tools.build:gradle:7.4.0'
ext.errorproneVersion = '2.31.0'
repositories {
google()
mavenCentral()
}
dependencies {
// This must be applied in the root project otherwise each subproject will
// have it in a different ClassLoader.
classpath android_tools
classpath libs.android.tools
}
}

plugins {
// Add dependency for build script so we can access Git from our
// build script.
id 'org.ajoberstar.grgit' version '5.2.2'
id 'net.ltgt.errorprone' version '4.0.0'
id "com.google.osdetector" version "1.7.3"
id "biz.aQute.bnd.builder" version "6.4.0" apply false
alias libs.plugins.bnd apply false
alias libs.plugins.errorprone
alias libs.plugins.grgit
alias libs.plugins.osdetector
alias libs.plugins.task.tree
}

subprojects {
Expand Down Expand Up @@ -65,9 +62,8 @@ subprojects {
}
}
}
apply plugin: "idea"
apply plugin: "jacoco"
apply plugin: "net.ltgt.errorprone"
apply plugin: libs.plugins.errorprone.get().pluginId

group = "org.conscrypt"
description = 'Conscrypt is an alternate Java Security Provider that uses BoringSSL'
Expand All @@ -91,28 +87,6 @@ subprojects {
boringSslGit = Grgit.open(dir: boringsslHome)
boringSslVersion = boringSslGit.head().id

jmhVersion = '1.21'
libraries = [
android_tools: android_tools,
roboelectric: 'org.robolectric:android-all:7.1.0_r7-robolectric-0',

// Test dependencies.
bouncycastle_apis: 'org.bouncycastle:bcpkix-jdk15on:1.63',
bouncycastle_provider: 'org.bouncycastle:bcprov-jdk15on:1.63',
junit : 'junit:junit:4.13.2',
mockito: 'org.mockito:mockito-core:2.28.2',
truth : 'com.google.truth:truth:1.0',

// Benchmark dependencies
jmh_core: "org.openjdk.jmh:jmh-core:${jmhVersion}",
jmh_generator_annprocess: "org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}",
jmh_generator_asm: "org.openjdk.jmh:jmh-generator-asm:${jmhVersion}",
jmh_generator_bytecode: "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
jmh_generator_reflection: "org.openjdk.jmh:jmh-generator-reflection:${jmhVersion}",
netty_handler: 'io.netty:netty-handler:4.1.24.Final',
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.26.Final',
]

signJar = { jarPath ->
if (rootProject.hasProperty('signingKeystore') && rootProject.hasProperty('signingPassword')) {
def command = 'jarsigner -keystore ' + rootProject.signingKeystore +
Expand All @@ -133,11 +107,21 @@ subprojects {
}

jacoco {
toolVersion = "0.8.4"
toolVersion = libs.versions.jacoco
}

configurations {
jacocoAnt
jacocoAgent
}

dependencies {
jacocoAnt libs.jacoco.ant
jacocoAgent libs.jacoco.agent
}

dependencies {
errorprone("com.google.errorprone:error_prone_core:$errorproneVersion")
errorprone libs.errorprone
}

tasks.register("generateProperties", WriteProperties) {
Expand Down Expand Up @@ -192,12 +176,12 @@ subprojects {
}

tasks.register("javadocJar", Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc
}

tasks.register("sourcesJar", Jar) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

Expand Down
54 changes: 54 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[versions]
android-tools = "7.4.2"
bnd = "6.4.0"
bouncycastle = "1.67"
caliper = "1.0-beta-2"
errorprone = "2.31.0"
errorprone-plugin = "4.0.0"
grgit = "5.2.2"
jacoco = "0.8.12"
jmh = "1.37"
jmh-plugin = "0.7.2"
junit = "4.13.2"
mockito = "2.28.2"
netty-handler = "4.1.24.Final"
netty-tcnative = "2.0.26.Final"
osdetector = "1.7.3"
shadow = "7.1.2"
task-tree = "3.0.0"

[plugins]
bnd = { id = "biz.aQute.bnd.builder", version.ref = "bnd" }
errorprone = { id = "net.ltgt.errorprone", version.ref = "errorprone-plugin" }
grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" }
jmh = { id = "me.champeau.jmh", version.ref = "jmh-plugin" }
osdetector = { id = "com.google.osdetector", version.ref = "osdetector" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
task-tree = { id = "com.dorongold.task-tree", version.ref = "task-tree" }

[libraries]
# Android tooling
android-tools = { module = "com.android.tools.build:gradle", version.ref = "android-tools" }
caliper = { module = "com.google.caliper:caliper", version.ref = "caliper" }

# Bouncycastle
bouncycastle-apis = { module = "org.bouncycastle:bcpkix-jdk15on", version.ref = "bouncycastle" }
bouncycastle-provider = { module = "org.bouncycastle:bcprov-jdk15on", version.ref = "bouncycastle" }

# Testing
errorprone = { module = "com.google.errorprone:error_prone_core", version.ref = "errorprone" }
jacoco-agent = { module = "org.jacoco:org.jacoco.agent", version.ref = "jacoco" }
jacoco-ant = { module = "org.jacoco:org.jacoco.ant", version.ref = "jacoco" }
junit = { module = "junit:junit", version.ref = "junit" }
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }

# JMH Benchmarking
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
jmh-generator-annprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
jmh-generator-bytecode = { module = "org.openjdk.jmh:jmh-generator-bytecode", version.ref = "jmh" }
jmh-generator-reflection = { module = "org.openjdk.jmh:jmh-generator-reflection", version.ref = "jmh" }

# Netty
netty-handler = { module = "io.netty:netty-handler", version.ref = "netty-handler" }
netty-tcnative = { module = "io.netty:netty-tcnative-boringssl-static", version.ref = "netty-tcnative" }

2 changes: 1 addition & 1 deletion libcore-stub/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
// Only compile against this. Other modules will embed the generated code directly.
compileOnly project(':conscrypt-constants')

testImplementation libraries.junit
testImplementation libs.junit
}

// Disable the javadoc task.
Expand Down
2 changes: 1 addition & 1 deletion openjdk-uber/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ext {
}

if (buildUberJar) {
apply plugin: 'biz.aQute.bnd.builder'
apply plugin: libs.plugins.bnd.get().pluginId

configurations {
uberJar
Expand Down
Loading

0 comments on commit 8c8a05f

Please sign in to comment.