From 426c47013cd3e12397227a857e72690ca35b9435 Mon Sep 17 00:00:00 2001 From: reger24 Date: Tue, 18 Jan 2022 16:02:19 +0100 Subject: [PATCH] Prepare to use Gradle dependencies while mimic current config with jars/dependencies in lib directory (w/o overwriting existing jars) --- build.gradle | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 2d2677791..0735eee9c 100644 --- a/build.gradle +++ b/build.gradle @@ -71,7 +71,10 @@ tasks.withType(JavaCompile) { } dependencies { - implementation(fileTree("lib")) + implementation(fileTree(dir : "lib", include : "*.jar")) + + // need at least one entry to make references to configuragtion.xxxx work in combination with local lib directory + implementation 'com.ibm.icu:icu4j:63.1' testImplementation('junit:junit:4.13.2') } @@ -85,8 +88,24 @@ jar { FileTree libdir = fileTree("lib").include ("*.jar").exclude("yacycore.jar") manifest { attributes( - "Main-Class": "net.yacy.yacy" , - "Class-Path": libdir.collect { it.name }.join(' ') + "Main-Class": mainClassName , + "Class-Path": configurations.compileClasspath.collect { it.name }.join(' ') ) } -} \ No newline at end of file +} + +shadowJar.zip64 = true // saw build error: Execution failed for task ':shadowJar'. shadow.org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries. + +// mimic current config with dependencies in lib directory +// @TODO: maybe removed after complete Gradle migration +task copyDependenciesToLib(type: Copy) { + def destination = project.file("lib") + into destination + from configurations.compileClasspath + eachFile { // prevent overwriting existing files + if (it.getRelativePath().getFile(destination).exists()) { + it.exclude() + } + } + build.dependsOn(copyDependenciesToLib) +}