Skip to content

Commit c093a77

Browse files
kopporSiedlerchr
andauthored
Enable configuration caching (#14725)
* Use gradle download plugin * WIP: fix download * Use latest jbang plugin * Remove obsolete comment * Try other config * fix jbang dir * fix path on Windows * try with gradle home user dir * More config * Remvoe workaround * fix only if * fix config cache --------- Co-authored-by: Siedlerchr <[email protected]>
1 parent 33ab1ec commit c093a77

File tree

9 files changed

+32
-52
lines changed

9 files changed

+32
-52
lines changed

build-logic/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ plugins {
44

55
repositories {
66
gradlePluginPortal()
7+
maven { url = uri("https://jitpack.io") }
78
}
89

910
dependencies {
1011
implementation("com.adarshr:gradle-test-logger-plugin:4.0.0")
1112
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:3.5.1")
1213
implementation("com.github.andygoossens:gradle-modernizer-plugin:1.12.0")
14+
implementation("com.github.koppor:jbang-gradle-plugin:jitpack-SNAPSHOT")
15+
implementation("de.undercouch.download:de.undercouch.download.gradle.plugin:5.6.0")
1316
implementation("org.gradlex:extra-java-module-info:1.13.1")
1417
implementation("org.gradlex:java-module-dependencies:1.11")
1518
implementation("org.gradlex:java-module-packaging:1.2")

build-logic/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
rootProject.name = "build-logic"
2+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id("de.undercouch.download")
3+
}

build-logic/src/main/kotlin/org.jabref.gradle.module.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ plugins {
44
id("org.jabref.gradle.base.dependency-rules")
55
id("org.jabref.gradle.base.repositories")
66
id("org.jabref.gradle.base.targets")
7+
id("org.jabref.gradle.check.checkstyle")
8+
id("org.jabref.gradle.check.modernizer")
79
id("org.jabref.gradle.feature.compile")
810
id("org.jabref.gradle.feature.javadoc")
911
id("org.jabref.gradle.feature.test")
10-
id("org.jabref.gradle.check.checkstyle")
11-
id("org.jabref.gradle.check.modernizer")
1212
}

gradle.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ org.gradle.vfs.watch=true
55
org.gradle.jvmargs=-Xmx6g
66

77
# hint by https://docs.gradle.org/current/userguide/performance.html#enable_configuration_cache
8-
# Blocked by https://github.com/jbangdev/jbang-gradle-plugin/issues/7
9-
org.gradle.configuration-cache=false
10-
# org.gradle.configuration-cache.parallel=true
8+
org.gradle.configuration-cache=true
9+
org.gradle.configuration-cache.parallel=true
1110

1211
# hint by https://docs.gradle.org/current/userguide/performance.html#enable_the_build_cache
1312
org.gradle.caching=true

jablib/build.gradle.kts

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import dev.jbang.gradle.tasks.JBangTask
44
import net.ltgt.gradle.errorprone.errorprone
55
import net.ltgt.gradle.nullaway.nullaway
66
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
7-
import java.net.URI
87
import java.util.*
98

109
plugins {
1110
id("org.jabref.gradle.module")
11+
id("org.jabref.gradle.feature.download")
1212
id("java-library")
1313

1414
id("antlr")
@@ -17,10 +17,9 @@ plugins {
1717

1818
id("com.vanniktech.maven.publish") version "0.35.0"
1919

20-
// id("dev.jbang") version "0.2.0"
20+
// id("dev.jbang") version "0.3.0"
2121
// Workaround for https://github.com/jbangdev/jbang-gradle-plugin/issues/7
22-
// Build state at https://jitpack.io/#koppor/jbang-gradle-plugin/fix-7-SNAPSHOT
23-
id("com.github.koppor.jbang-gradle-plugin") version "8a85836163"
22+
id("com.github.koppor.jbang-gradle-plugin")
2423

2524
id("net.ltgt.errorprone") version "4.3.0"
2625
id("net.ltgt.nullaway") version "2.3.0"
@@ -260,7 +259,8 @@ var taskGenerateJournalListMV = tasks.register<JBangTask>("generateJournalListMV
260259

261260
inputs.dir(abbrvJabRefOrgDir)
262261
outputs.file(generatedJournalFile)
263-
onlyIf {!generatedJournalFile.get().asFile.exists()}
262+
val generatedJournalFileProv = generatedJournalFile
263+
onlyIf { !generatedJournalFileProv.get().asFile.exists() }
264264
}
265265

266266
var taskGenerateCitationStyleCatalog = tasks.register<JBangTask>("generateCitationStyleCatalog") {
@@ -272,37 +272,16 @@ var taskGenerateCitationStyleCatalog = tasks.register<JBangTask>("generateCitati
272272
inputs.dir(layout.projectDirectory.dir("src/main/resources/csl-styles"))
273273
val cslCatalogJson = layout.buildDirectory.file("generated/resources/citation-style-catalog.json")
274274
outputs.file(cslCatalogJson)
275-
onlyIf {!cslCatalogJson.get().asFile.exists()}
275+
val cslCatalogJsonProv = cslCatalogJson
276+
onlyIf { !cslCatalogJsonProv.get().asFile.exists() }
276277
}
277278

278-
var ltwaCsvFile = layout.buildDirectory.file("tmp/ltwa_20210702.csv")
279+
val ltwaCsvFile = layout.buildDirectory.file("tmp/ltwa_20210702.csv")
279280

280-
tasks.register("downloadLtwaFile") {
281-
group = "JabRef"
282-
description = "Downloads the LTWA file for journal abbreviations"
283-
284-
val ltwaUrl = "https://www.issn.org/wp-content/uploads/2021/07/ltwa_20210702.csv"
285-
val ltwaDir = layout.buildDirectory.dir("resources/main/journals")
286-
287-
outputs.file(ltwaCsvFile)
288-
289-
// Ensure that the task really is not run if the file already exists (otherwise, the task could also run if gradle's cache is cleared, ...)
290-
onlyIf {!ltwaCsvFile.get().asFile.exists()}
291-
292-
doLast {
293-
val dir = ltwaDir.get().asFile
294-
val file = ltwaCsvFile.get().asFile
295-
296-
dir.mkdirs()
297-
298-
URI(ltwaUrl).toURL().openStream().use { input ->
299-
file.outputStream().use { output ->
300-
input.copyTo(output)
301-
}
302-
}
303-
304-
logger.debug("Downloaded LTWA file to $file")
305-
}
281+
tasks.register<de.undercouch.gradle.tasks.download.Download>("downloadLtwaFile") {
282+
src("https://www.issn.org/wp-content/uploads/2021/07/ltwa_20210702.csv")
283+
dest(ltwaCsvFile)
284+
onlyIfModified(true)
306285
}
307286

308287
var taskGenerateLtwaListMV = tasks.register<JBangTask>("generateLtwaListMV") {
@@ -315,15 +294,15 @@ var taskGenerateLtwaListMV = tasks.register<JBangTask>("generateLtwaListMV") {
315294
inputs.file(ltwaCsvFile)
316295
val ltwaListMv = layout.buildDirectory.file("generated/resources/journals/ltwa-list.mv");
317296
outputs.file(ltwaListMv)
318-
onlyIf {!ltwaListMv.get().asFile.exists()}
297+
val ltwaListMvProv = ltwaListMv
298+
onlyIf { !ltwaListMvProv.get().asFile.exists() }
319299
}
320300

321301
// Adds ltwa, journal-list.mv, and citation-style-catalog.json to the resources directory
322302
sourceSets["main"].resources {
323303
srcDir(layout.buildDirectory.dir("generated/resources"))
324304
}
325305

326-
327306
// region processResources
328307
abstract class JoinNonCommentedLines : DefaultTask() {
329308

jabls-cli/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ tasks.test {
5252
}
5353

5454
tasks.named<JavaExec>("run") {
55-
doFirst {
56-
application.applicationDefaultJvmArgs =
57-
listOf(
58-
"--enable-native-access=com.sun.jna"
59-
)
60-
}
55+
// "assert" statements in the code should activated when running using gradle
56+
enableAssertions = true
57+
jvmArgs("--enable-native-access=com.sun.jna")
6158
}
6259

6360
javaModulePackaging {

jabsrv-cli/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,9 @@ tasks.test {
102102
}
103103

104104
tasks.named<JavaExec>("run") {
105-
doFirst {
106-
application.applicationDefaultJvmArgs =
107-
listOf(
108-
"--enable-native-access=com.sun.jna"
109-
)
110-
}
105+
// "assert" statements in the code should activated when running using gradle
106+
enableAssertions = true
107+
jvmArgs("--enable-native-access=com.sun.jna")
111108
}
112109

113110
javaModulePackaging {

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pluginManagement {
1919
maven("https://jitpack.io")
2020
}
2121
}
22+
2223
plugins {
2324
id("org.jabref.gradle.build")
2425
}

0 commit comments

Comments
 (0)