diff --git a/py/jpy-integration/build.gradle b/py/jpy-integration/build.gradle index 97832b65589..885958f22f5 100644 --- a/py/jpy-integration/build.gradle +++ b/py/jpy-integration/build.gradle @@ -110,6 +110,50 @@ Task pythonToJava = tasks.create 'unittestPythonToJava', { } if (!PyEnv.pythonEnabled(project)) { + Closure> gradleTestInDocker = { String taskName, SourceSet sourceSet -> + + def gradleWrapper = tasks.register("${taskName}GradleInit", Wrapper.class) { wrapper -> + wrapper.scriptFile "${buildDir}/template-project/gradlew" + wrapper.jarFile "${buildDir}/template-project/gradle/wrapper/gradle-wrapper.jar" + } + return Docker.registerDockerTask(project, taskName) { + copyIn { + dependsOn gradleWrapper + from ("${buildDir}/template-project") { + into 'project' + } + from(project.file('src/javaToPython/build.gradle.template')) { + into 'project' + rename { file -> 'build.gradle' } + } + from (sourceSet.runtimeClasspath) { + into 'classpath' + } + from (sourceSet.output.getClassesDirs()) { + into 'classes' + } + } + dockerfile { + // base image with default java, python, wheels + from 'deephaven/runtime-base' + + // set up the project + copyFile 'project', '/project' + workingDir '/project' + // run once with no actual classes, so that gradle is preinstalled and cached + runCommand '/project/gradlew' + copyFile 'classpath', '/classpath' + copyFile 'classes', '/classes' + } + entrypoint = ['/project/gradlew', 'test', '--info'] + containerOutPath = '/project/build/test-results/test/' + copyOut { + into "${buildDir}/test-results/${taskName}" + } + } + } + testJavaToPython.dependsOn gradleTestInDocker('java-to-python-test', sourceSets.javaToPython) + // Task testTask = venvTest.javaTest(project, "java-to-python-test-${pv.name}", installWheels, sourceSets.javaToPython) // testJavaToPython.dependsOn testTask diff --git a/py/jpy-integration/src/javaToPython/build.gradle.template b/py/jpy-integration/src/javaToPython/build.gradle.template new file mode 100644 index 00000000000..52bc2960906 --- /dev/null +++ b/py/jpy-integration/src/javaToPython/build.gradle.template @@ -0,0 +1,18 @@ +plugins { + id 'java-library' +} + +// Classpath is already built, just need to pass to the test task +test.classpath = fileTree('/classpath/').plus(files('/classpath')) +test.testClassesDirs = files('/classes') + +test.systemProperties([ + 'jpy.jpyLib':'/usr/local/lib/python3.7/dist-packages/jpy.cpython-37m-x86_64-linux-gnu.so', + 'jpy.jdlLib':'/usr/local/lib/python3.7/dist-packages/jdl.cpython-37m-x86_64-linux-gnu.so', + 'jpy.pythonLib':'/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0', + // Cleaning up on a dedicated thread has some issues when there is frequent starting + // and stopping of the python virtual environment. We'll rely on cleaning up inline + // when necessary. + 'PyObject.cleanup_on_thread':'false', +// 'jpy.debug':'true' +])