diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index cad30a11d37..80529d28246 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -4,12 +4,15 @@ plugins { repositories { gradlePluginPortal() + maven { url = uri("https://jitpack.io") } } dependencies { implementation("com.adarshr:gradle-test-logger-plugin:4.0.0") implementation("com.autonomousapps:dependency-analysis-gradle-plugin:3.5.1") implementation("com.github.andygoossens:gradle-modernizer-plugin:1.12.0") + implementation("com.github.koppor:jbang-gradle-plugin:jitpack-SNAPSHOT") + implementation("de.undercouch.download:de.undercouch.download.gradle.plugin:5.6.0") implementation("org.gradlex:extra-java-module-info:1.13.1") implementation("org.gradlex:java-module-dependencies:1.11") implementation("org.gradlex:java-module-packaging:1.2") diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index 7fbbd448ef1..010c352fc42 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -1 +1,2 @@ rootProject.name = "build-logic" + diff --git a/build-logic/src/main/kotlin/org.jabref.gradle.feature.download.gradle.kts b/build-logic/src/main/kotlin/org.jabref.gradle.feature.download.gradle.kts new file mode 100644 index 00000000000..046df9da56a --- /dev/null +++ b/build-logic/src/main/kotlin/org.jabref.gradle.feature.download.gradle.kts @@ -0,0 +1,3 @@ +plugins { + id("de.undercouch.download") +} diff --git a/build-logic/src/main/kotlin/org.jabref.gradle.module.gradle.kts b/build-logic/src/main/kotlin/org.jabref.gradle.module.gradle.kts index 83216741b67..2ff23a99b9e 100644 --- a/build-logic/src/main/kotlin/org.jabref.gradle.module.gradle.kts +++ b/build-logic/src/main/kotlin/org.jabref.gradle.module.gradle.kts @@ -4,9 +4,9 @@ plugins { id("org.jabref.gradle.base.dependency-rules") id("org.jabref.gradle.base.repositories") id("org.jabref.gradle.base.targets") + id("org.jabref.gradle.check.checkstyle") + id("org.jabref.gradle.check.modernizer") id("org.jabref.gradle.feature.compile") id("org.jabref.gradle.feature.javadoc") id("org.jabref.gradle.feature.test") - id("org.jabref.gradle.check.checkstyle") - id("org.jabref.gradle.check.modernizer") } diff --git a/gradle.properties b/gradle.properties index 9f29752cb56..efec473a754 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,9 +5,8 @@ org.gradle.vfs.watch=true org.gradle.jvmargs=-Xmx6g # hint by https://docs.gradle.org/current/userguide/performance.html#enable_configuration_cache -# Blocked by https://github.com/jbangdev/jbang-gradle-plugin/issues/7 -org.gradle.configuration-cache=false -# org.gradle.configuration-cache.parallel=true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true # hint by https://docs.gradle.org/current/userguide/performance.html#enable_the_build_cache org.gradle.caching=true diff --git a/jablib/build.gradle.kts b/jablib/build.gradle.kts index 2756c0fd5d2..d357909f6da 100644 --- a/jablib/build.gradle.kts +++ b/jablib/build.gradle.kts @@ -4,11 +4,11 @@ import dev.jbang.gradle.tasks.JBangTask import net.ltgt.gradle.errorprone.errorprone import net.ltgt.gradle.nullaway.nullaway import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import java.net.URI import java.util.* plugins { id("org.jabref.gradle.module") + id("org.jabref.gradle.feature.download") id("java-library") id("antlr") @@ -17,10 +17,9 @@ plugins { id("com.vanniktech.maven.publish") version "0.35.0" - // id("dev.jbang") version "0.2.0" + // id("dev.jbang") version "0.3.0" // Workaround for https://github.com/jbangdev/jbang-gradle-plugin/issues/7 - // Build state at https://jitpack.io/#koppor/jbang-gradle-plugin/fix-7-SNAPSHOT - id("com.github.koppor.jbang-gradle-plugin") version "8a85836163" + id("com.github.koppor.jbang-gradle-plugin") id("net.ltgt.errorprone") version "4.3.0" id("net.ltgt.nullaway") version "2.3.0" @@ -260,7 +259,8 @@ var taskGenerateJournalListMV = tasks.register("generateJournalListMV inputs.dir(abbrvJabRefOrgDir) outputs.file(generatedJournalFile) - onlyIf {!generatedJournalFile.get().asFile.exists()} + val generatedJournalFileProv = generatedJournalFile + onlyIf { !generatedJournalFileProv.get().asFile.exists() } } var taskGenerateCitationStyleCatalog = tasks.register("generateCitationStyleCatalog") { @@ -272,37 +272,16 @@ var taskGenerateCitationStyleCatalog = tasks.register("generateCitati inputs.dir(layout.projectDirectory.dir("src/main/resources/csl-styles")) val cslCatalogJson = layout.buildDirectory.file("generated/resources/citation-style-catalog.json") outputs.file(cslCatalogJson) - onlyIf {!cslCatalogJson.get().asFile.exists()} + val cslCatalogJsonProv = cslCatalogJson + onlyIf { !cslCatalogJsonProv.get().asFile.exists() } } -var ltwaCsvFile = layout.buildDirectory.file("tmp/ltwa_20210702.csv") +val ltwaCsvFile = layout.buildDirectory.file("tmp/ltwa_20210702.csv") -tasks.register("downloadLtwaFile") { - group = "JabRef" - description = "Downloads the LTWA file for journal abbreviations" - - val ltwaUrl = "https://www.issn.org/wp-content/uploads/2021/07/ltwa_20210702.csv" - val ltwaDir = layout.buildDirectory.dir("resources/main/journals") - - outputs.file(ltwaCsvFile) - - // 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, ...) - onlyIf {!ltwaCsvFile.get().asFile.exists()} - - doLast { - val dir = ltwaDir.get().asFile - val file = ltwaCsvFile.get().asFile - - dir.mkdirs() - - URI(ltwaUrl).toURL().openStream().use { input -> - file.outputStream().use { output -> - input.copyTo(output) - } - } - - logger.debug("Downloaded LTWA file to $file") - } +tasks.register("downloadLtwaFile") { + src("https://www.issn.org/wp-content/uploads/2021/07/ltwa_20210702.csv") + dest(ltwaCsvFile) + onlyIfModified(true) } var taskGenerateLtwaListMV = tasks.register("generateLtwaListMV") { @@ -315,7 +294,8 @@ var taskGenerateLtwaListMV = tasks.register("generateLtwaListMV") { inputs.file(ltwaCsvFile) val ltwaListMv = layout.buildDirectory.file("generated/resources/journals/ltwa-list.mv"); outputs.file(ltwaListMv) - onlyIf {!ltwaListMv.get().asFile.exists()} + val ltwaListMvProv = ltwaListMv + onlyIf { !ltwaListMvProv.get().asFile.exists() } } // Adds ltwa, journal-list.mv, and citation-style-catalog.json to the resources directory @@ -323,7 +303,6 @@ sourceSets["main"].resources { srcDir(layout.buildDirectory.dir("generated/resources")) } - // region processResources abstract class JoinNonCommentedLines : DefaultTask() { diff --git a/jabls-cli/build.gradle.kts b/jabls-cli/build.gradle.kts index 16acdf46220..fae8abaeac9 100644 --- a/jabls-cli/build.gradle.kts +++ b/jabls-cli/build.gradle.kts @@ -52,12 +52,9 @@ tasks.test { } tasks.named("run") { - doFirst { - application.applicationDefaultJvmArgs = - listOf( - "--enable-native-access=com.sun.jna" - ) - } + // "assert" statements in the code should activated when running using gradle + enableAssertions = true + jvmArgs("--enable-native-access=com.sun.jna") } javaModulePackaging { diff --git a/jabsrv-cli/build.gradle.kts b/jabsrv-cli/build.gradle.kts index 58317edbd3d..20addf45662 100644 --- a/jabsrv-cli/build.gradle.kts +++ b/jabsrv-cli/build.gradle.kts @@ -102,12 +102,9 @@ tasks.test { } tasks.named("run") { - doFirst { - application.applicationDefaultJvmArgs = - listOf( - "--enable-native-access=com.sun.jna" - ) - } + // "assert" statements in the code should activated when running using gradle + enableAssertions = true + jvmArgs("--enable-native-access=com.sun.jna") } javaModulePackaging { diff --git a/settings.gradle.kts b/settings.gradle.kts index b9aed07ba92..d76f5a74693 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,6 +19,7 @@ pluginManagement { maven("https://jitpack.io") } } + plugins { id("org.jabref.gradle.build") }