I want to enable Java Bindings for V8 ("J2V8") in a Java project. The reasons for this are because (i) the JavaScript V8 engine is much faster than the JavaScript engine that comes with the JRE, and (ii) the library used is only available in JavaScript, and the port for Java is a lot of effort.
The problem is that J2V8 is compiled for different platforms : linux 64bit, macos 64bit, windows 64 bit, windows 32 bit.
Now I want to generate different JAR files containing all the dependencies ( thick jars ):
jabref-linux_x86_64.jarjabref-macosx_x86_64.jarjabref-windows_x86_32.jarjabref-windows_x86_64.jarjabref-all.jar - independent JAR platform without v8 engine
I am currently creating thick jars using a shadow plugin .
Please note that the project is not an Android project. There, with the Android plugin, it seems like it's straightforward.
The first idea is to introduce configurations and dependencies, depending on the configuration:
configurations { linux_x86_64Compile.extendsFrom compile macosx_x86_64Compile.extendsFrom compile windows_x86_32Compile.extendsFrom compile windows_x86_64Compile.extendsFrom compile } dependencies { compile configuration: 'linux_x86_64', group: 'com.eclipsesource.j2v8', name: 'j2v8_linux_x86_x64', version: '4.6.0' compile configuration: 'macosx_x86_64', group: 'com.eclipsesource.j2v8', name: 'j2v8_macosx_x86_x64', version: '4.6.0' compile configuration: 'windows_x86_32', group: 'com.eclipsesource.j2v8', name: 'j2v8_win32_x86', version: '4.6.0' compile configuration: 'windows_x86_64', group: 'com.eclipsesource.j2v8', name: 'j2v8_win32_x86_x64', version: '4.6.0' ... }
But now I'm stuck. In pseudo code, I would like to:
task releaseSingleJar(dependsOn: "shadowJar", name) { doLast { copy { from("$buildDir/libs/JabRef-${project.version}-fat.jar") into("$buildDir/releases/") rename { String fileName -> fileName.replace('-fat', '-$name') } } } } task releaseJars() { forEach name in "linux_x86_64", "macosx_x86_64", "windows_x86_32", "windows_x86_64", "all": if (name != "all") activate configuration $name releaseSingleJar($name)
shadowJar from the shadow plugin.
Background Information
Related Questions
Question Using Gradle to control a Java web application with tastes like Android has a similar name, but it asks for the source directories, while I am requesting the dependencies. Also, I want to create a thick JAR, and there is enough JAR there, it seems, enough. However, it may turn out that the solution is similar. The hint was to use the gradle -java-flavors plugin with the main source JavaFlavoursExtension.groovy .
The following questions are similar to this. However, the setup is related to Android applications, not regular Java applications.