Does anyone know if there is, or will be, a way to distribute different versions of a library for P3 and P4. Right now my own library, and others I use, works in P4 but are compiled for Java 8. Can we have two versions, one compiled in Java 8 and one in Java 11?
Right now it seems that if I update to Java 11 for P4 it would break the lib in P3. Does anyone have an idea of how to handle this moving forward?
So, what problem are you trying to solve that you don’t seem to have?
Incidentally, if you really wanted to target some optional things at Java 11+, you could read up on multi-release JARs, but I doubt it’s worth the hassle.
I wonder when Processing will support Java 17 that’s released next week?
Hi @neilcsmith, I guess I’m asking about backwards compatibility for libraries between P3 and P4. Was this an issue with P2 and P3? Eventually library developers will want to use Java 11 so we would have to keep either a separate repository or have two versions of our build script so P3 users could manually compile the library.
For me it’s about the speed difference in Java 11. So I guess I could build two versions and have instructions on how to manually install one or the other. I’m wondering what other developers are planning to do to stay compatible for the immediate future.
Speed difference of what?! Java 8 compatible code should run just as fast as Java 11 code on a Java 11 JVM.
I agree, at some point if you want to make use of new Java language or library features, then you might look to drop Java 8 support. But is there any reason you need to rush that now? I don’t produce any Processing libraries directly, but I do maintain libraries used in the Video library, and we’re certainly not dropping Java 8 support in the near future.
If you’re compiling on JDK 11+, make sure you’re using the new --release option to keep everything compatible with JDK 8.
After a few days twisting Gradle to build the Video Export Library I got it to work!!! Happy about it.
It seems to run in Processing 3 and Processing 4. I run the task called shadow/shadowJar to build it.
It’s now written in Kotlin. Missing still is to copy some files, documentation, examples. Maybe figure out how to write some tests which produce video files and extract metadata from the resulting mp4’s to see if the files look correct.
build.gradle.kts
plugins {
id("org.jetbrains.kotlin.jvm") version "1.5.0"
id("org.jetbrains.dokka") version "1.5.0"
id("com.github.johnrengelman.shadow") version "7.0.0"
`java-library`
}
repositories {
mavenCentral()
maven {
url = uri("https://jitpack.io")
}
}
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
// used internally, not exposed to consumers on their own compile classpath
//implementation("org.processing:core:3.3.7")
//implementation("org.processing:pde:3.3.7")
compileOnly("com.github.micycle1:processing-core-4:4.0.3")
compileOnly("net.java.dev.jna:jna:5.7.0")
compileOnly("net.java.dev.jna:jna-platform:5.7.0")
// Test
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("org.processing:core:3.3.7")
// Documentation
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.5.0")
// Exported to consumers
//api("org.apache.commons:commons-math3:3.6.1")
}
tasks.jar {
manifest {
attributes(
mapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
)
}
doLast {
copy {
from(layout.buildDirectory.dir("libs/${rootProject.name}-all.jar"))
into("/home/funpro/Desktop/edu/src/processing/libraries" +
"/videoExport/library/")
}
}
}
I’ll release it soon. I also could share the whole template to create a Processing Library with Kotlin and Gradle (and IntelliJ?). I guess using Java would require few or no changes.
Thanks @hamoid for the Maven example. I haven’t used Maven for P3 yet, but have for other things. I’ll look at it.
I have found at least for my library about 12-14% drop in performance from P3 to P4. P3 seems to run a bit faster. But if I build it using only JDK11 (no JDK8 support) in P4 that drop mostly goes away. This is what prompted my question. But perhaps others are not experiencing this with their libs.
My lib uses the JNI heavily and the backend is in C++ so perhaps that is another reason for a performance drop between versions. I really don’t know.
So I suppose unless I figure something else out, I guess I could include a JDK11 build with the distro and have instructions on how P4 users could manually implement it. Then when P3 becomes out of fashion do the opposite.
Oh interesting. I haven’t tried to compare the performance in both versions. If you don’t mind sharing, which library is it? Can one see the source code?
BTW I used Gradle instead of Maven: Gradle | Gradle vs Maven Comparison And I used the Kotlin DSL instead of the Groovy DSL because it is typed and has better autocomplete in the IDE and you can ctrl+click on the code to explore the implementation.