From f0acfcf5f92b84c8a239a7b3935292ca107dc69f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 16 Jul 2025 18:11:48 -0500 Subject: [PATCH 01/20] Meson build for MMCoreJ --- MMCoreJ_wrap/meson.build | 157 +++++++++++++++++++++++++ MMCoreJ_wrap/src/main/java/meson.build | 18 +++ MMCoreJ_wrap/subprojects/.gitignore | 14 +++ MMCoreJ_wrap/subprojects/mmcore.wrap | 7 ++ MMCoreJ_wrap/subprojects/mmdevice.wrap | 7 ++ 5 files changed, 203 insertions(+) create mode 100644 MMCoreJ_wrap/meson.build create mode 100644 MMCoreJ_wrap/src/main/java/meson.build create mode 100644 MMCoreJ_wrap/subprojects/.gitignore create mode 100644 MMCoreJ_wrap/subprojects/mmcore.wrap create mode 100644 MMCoreJ_wrap/subprojects/mmdevice.wrap diff --git a/MMCoreJ_wrap/meson.build b/MMCoreJ_wrap/meson.build new file mode 100644 index 000000000..68c2c45d5 --- /dev/null +++ b/MMCoreJ_wrap/meson.build @@ -0,0 +1,157 @@ +# This Meson script is experimental and potentially incomplete. It is not part +# of the supported build system for Micro-Manager or mmCoreAndDevices. + +# IMPORTANT: This build script uses mmcore and mmdevice from the mirror +# repositories, not the MMCore/ and MMDevice/ in mmCoreAndDevices. This is +# because this build script is expected to be put in use when MMCoreJ is moved +# out of mmCoreAndDevices. +# The versions used are defined in mmdevice.wrap and mmcore.wrap. + +project( + 'mmcorej', + 'cpp', 'java', + # TODO version (set here and generate pom.xml) + meson_version: '>=1.3.0', + default_options: [ + 'cpp_std=c++14', + 'warning_level=3', + ], +) + +cxx = meson.get_compiler('cpp') + +if cxx.get_id() in ['gcc', 'clang'] + # SWIG Java typemaps call for -fno-strict-aliasing when compiling the + # SWIG-generated code (see SWIG docs). + add_project_arguments('-fno-strict-aliasing', language: 'cpp') +endif + +if cxx.get_id() in ['msvc', 'clang-cl'] + add_project_arguments('-DNOMINMAX', language: 'cpp') +endif + +fs = import('fs') + +swig = find_program('swig', native: true) + +mmcore_proj = subproject( + 'mmcore', + default_options: { + 'default_library': 'static', + 'tests': 'disabled', + }, +) +mmcore_dep = mmcore_proj.get_variable('mmcore') + +jni_dep = dependency('jni', version: '>= 1.8.0') + +threads_dep = dependency('threads') + +swig_include_dirs = mmcore_proj.get_variable('swig_include_dirs') +swig_incdir_args = [] +foreach abspath : swig_include_dirs + swig_incdir_args += '-I' + fs.relative_to( + abspath, + meson.project_build_root(), + ) +endforeach + +subdir('src/main/java') # Get java_sources + +# TODO Add check to ensure we don't miss any +swig_gen_java_source_names = [ + 'ActionType.java', + 'BooleanVector.java', + 'CharVector.java', + 'CMMCore.java', + 'Configuration.java', + 'DeviceDetectionStatus.java', + 'DeviceInitializationState.java', + 'DeviceNotification.java', + 'DeviceType.java', + 'DoubleVector.java', + 'FocusDirection.java', + 'LongVector.java', + 'Metadata.java', + 'MetadataArrayTag.java', + 'MetadataError.java', + 'MetadataSingleTag.java', + 'MetadataTag.java', + 'MMCoreJ.java', + 'MMCoreJConstants.java', + 'MMCoreJJNI.java', + 'MMEventCallback.java', + 'pair_ss.java', + 'PortType.java', + 'PropertySetting.java', + 'PropertyType.java', + 'StrMap.java', + 'StrVector.java', + 'SWIGTYPE_p_std__istringstream.java', + 'UnsignedVector.java', +] + +swig_gen = custom_target( + 'swig-mmcorej', + input: 'MMCoreJ.i', + output: [ + 'MMCoreJ_swig_wrap.cpp', # @OUTPUT0@, swig_gen[0] + 'MMCoreJ_swig_wrap.h', # @OUTPUT1@, swig_gen[1] + swig_gen_java_source_names, + ], + depfile: 'MMCoreJ_swig_wrap.d', + command: [ + swig, + '-c++', + '-java', + '-package', 'mmcorej', + '-module', 'MMCoreJ', + swig_incdir_args, + '-MD', '-MF', '@DEPFILE@', + '-o', '@OUTPUT0@', + '-oh', '@OUTPUT1@', + '-outdir', '@OUTDIR@', + '@INPUT@', + ], +) + +swig_gen_cpp_sources = [swig_gen[0], swig_gen[1]] + +swig_gen_java_sources = [] +foreach src : swig_gen.to_list() + if src.full_path().endswith('.h') or src.full_path().endswith('.cpp') + continue + endif + swig_gen_java_sources += src +endforeach + +# Note that JNI libraries are supposed to be dylibs, not Mach-O bundles, on +# macOS, even though they are loaded by dlopen() (other platforms don't have +# this distinction). So we use shared_library(), not shared_module(). +shared_library( + 'MMCoreJ_wrap', + swig_gen_cpp_sources, + dependencies: [ + jni_dep, + mmcore_dep, + threads_dep, + ], + gnu_symbol_visibility: 'hidden', + install: true, +) + +jar( + 'MMCoreJ', + java_sources, + swig_gen_java_sources, + java_resources: structured_sources([ + # TODO pom.xml + ]), + override_options: [ + 'warning_level=1', # Disable -Xdoclint:all, keep -Xlint:all + ], + install: true, +) + +# TODO Javadoc jar (needs parsing of Doxygen XML; see old generator) +# TODO Source jar (create externally from source dist?) diff --git a/MMCoreJ_wrap/src/main/java/meson.build b/MMCoreJ_wrap/src/main/java/meson.build new file mode 100644 index 000000000..2e4ee11eb --- /dev/null +++ b/MMCoreJ_wrap/src/main/java/meson.build @@ -0,0 +1,18 @@ +java_sources = files( + 'mmcorej/org/json/CDL.java', + 'mmcorej/org/json/Cookie.java', + 'mmcorej/org/json/CookieList.java', + 'mmcorej/org/json/HTTP.java', + 'mmcorej/org/json/HTTPTokener.java', + 'mmcorej/org/json/JSONArray.java', + 'mmcorej/org/json/JSONException.java', + 'mmcorej/org/json/JSONObject.java', + 'mmcorej/org/json/JSONStringer.java', + 'mmcorej/org/json/JSONTokener.java', + 'mmcorej/org/json/JSONWriter.java', + 'mmcorej/org/json/Test.java', + 'mmcorej/org/json/XML.java', + 'mmcorej/org/json/XMLTokener.java', + + 'mmcorej/TaggedImage.java', +) diff --git a/MMCoreJ_wrap/subprojects/.gitignore b/MMCoreJ_wrap/subprojects/.gitignore new file mode 100644 index 000000000..586e6acaf --- /dev/null +++ b/MMCoreJ_wrap/subprojects/.gitignore @@ -0,0 +1,14 @@ +/packagecache/ + +/mmcore/ +/mmdevice/ + +# Subprojects installed by meson wrap +/*-*/ + +# Ignore *.wrap by default (may be auto-installed transitive dependencies) +/*.wrap + +# Do not ignore wraps we provide +!/mmcore.wrap +!/mmdevice.wrap diff --git a/MMCoreJ_wrap/subprojects/mmcore.wrap b/MMCoreJ_wrap/subprojects/mmcore.wrap new file mode 100644 index 000000000..c0689630a --- /dev/null +++ b/MMCoreJ_wrap/subprojects/mmcore.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/micro-manager/mmcore.git +revision = 187adc00dac41b5257dc34068cc42042152dcd93 +depth = 1 + +[provide] +dependency_names = mmcore diff --git a/MMCoreJ_wrap/subprojects/mmdevice.wrap b/MMCoreJ_wrap/subprojects/mmdevice.wrap new file mode 100644 index 000000000..e87745973 --- /dev/null +++ b/MMCoreJ_wrap/subprojects/mmdevice.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/micro-manager/mmdevice.git +revision = 19efe5076245d19ccb486ee337f2330f172ce180 +depth = 1 + +[provide] +dependency_names = mmdevice From 92ea2e423bb586cf2cfb13d96823796e350291bc Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 09:08:17 -0600 Subject: [PATCH 02/20] Don't compile Java in Meson build We'll leave that for Maven. --- MMCoreJ_wrap/meson.build | 26 -------------------------- MMCoreJ_wrap/src/main/java/meson.build | 18 ------------------ 2 files changed, 44 deletions(-) delete mode 100644 MMCoreJ_wrap/src/main/java/meson.build diff --git a/MMCoreJ_wrap/meson.build b/MMCoreJ_wrap/meson.build index 68c2c45d5..efc606cfa 100644 --- a/MMCoreJ_wrap/meson.build +++ b/MMCoreJ_wrap/meson.build @@ -56,8 +56,6 @@ foreach abspath : swig_include_dirs ) endforeach -subdir('src/main/java') # Get java_sources - # TODO Add check to ensure we don't miss any swig_gen_java_source_names = [ 'ActionType.java', @@ -117,14 +115,6 @@ swig_gen = custom_target( swig_gen_cpp_sources = [swig_gen[0], swig_gen[1]] -swig_gen_java_sources = [] -foreach src : swig_gen.to_list() - if src.full_path().endswith('.h') or src.full_path().endswith('.cpp') - continue - endif - swig_gen_java_sources += src -endforeach - # Note that JNI libraries are supposed to be dylibs, not Mach-O bundles, on # macOS, even though they are loaded by dlopen() (other platforms don't have # this distinction). So we use shared_library(), not shared_module(). @@ -139,19 +129,3 @@ shared_library( gnu_symbol_visibility: 'hidden', install: true, ) - -jar( - 'MMCoreJ', - java_sources, - swig_gen_java_sources, - java_resources: structured_sources([ - # TODO pom.xml - ]), - override_options: [ - 'warning_level=1', # Disable -Xdoclint:all, keep -Xlint:all - ], - install: true, -) - -# TODO Javadoc jar (needs parsing of Doxygen XML; see old generator) -# TODO Source jar (create externally from source dist?) diff --git a/MMCoreJ_wrap/src/main/java/meson.build b/MMCoreJ_wrap/src/main/java/meson.build deleted file mode 100644 index 2e4ee11eb..000000000 --- a/MMCoreJ_wrap/src/main/java/meson.build +++ /dev/null @@ -1,18 +0,0 @@ -java_sources = files( - 'mmcorej/org/json/CDL.java', - 'mmcorej/org/json/Cookie.java', - 'mmcorej/org/json/CookieList.java', - 'mmcorej/org/json/HTTP.java', - 'mmcorej/org/json/HTTPTokener.java', - 'mmcorej/org/json/JSONArray.java', - 'mmcorej/org/json/JSONException.java', - 'mmcorej/org/json/JSONObject.java', - 'mmcorej/org/json/JSONStringer.java', - 'mmcorej/org/json/JSONTokener.java', - 'mmcorej/org/json/JSONWriter.java', - 'mmcorej/org/json/Test.java', - 'mmcorej/org/json/XML.java', - 'mmcorej/org/json/XMLTokener.java', - - 'mmcorej/TaggedImage.java', -) From 1bc40a5ab63ba58f9c2a70f3c0162ae2102ce1f6 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 09:16:57 -0600 Subject: [PATCH 03/20] Fix indentation in pom.xml --- MMCoreJ_wrap/pom.xml | 264 +++++++++++++++++++++---------------------- 1 file changed, 131 insertions(+), 133 deletions(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index a7e77cfe0..de3eb25f8 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -1,141 +1,139 @@ - 4.0.0 - org.micro-manager.mmcorej - MMCoreJ - jar - 11.11.0 - Micro-Manager Java Interface to MMCore - Micro-Manager is open source software for control of automated/motorized microscopes. This specific packages provides the Java interface to the device abstractino layer (MMCore) that is written in C++ with a C-interface - http://micro-manager.org + 4.0.0 + org.micro-manager.mmcorej + MMCoreJ + jar + 11.11.0 + Micro-Manager Java Interface to MMCore + Micro-Manager is open source software for control of automated/motorized microscopes. This specific packages provides the Java interface to the device abstractino layer (MMCore) that is written in C++ with a C-interface + http://micro-manager.org - - 1.8 - 1.8 - UTF-8 - + + 1.8 + 1.8 + UTF-8 + - - - nenada - Nenad Amodaj - Luminous Point - - - marktsuchida - Mark Tsuchida - University of Wisconsin, Madison - - - nicost - Nico Stuurman - UCSF/HHMI - - + + + nenada + Nenad Amodaj + Luminous Point + + + marktsuchida + Mark Tsuchida + University of Wisconsin, Madison + + + nicost + Nico Stuurman + UCSF/HHMI + + - - https://github.com/micro-manager/mmCoreAndDevices - scm:git:git://github.com/micro-manager/mmCoreAndDevices.git - scm:git:git@github.com:micro-manager/mmCoreAndDevices.git - + + https://github.com/micro-manager/mmCoreAndDevices + scm:git:git://github.com/micro-manager/mmCoreAndDevices.git + scm:git:git@github.com:micro-manager/mmCoreAndDevices.git + - - - LGPL-2.1 - https://github.com/micro-manager/mmCoreAndDevices/blob/main/MMCoreJ_wrap/license.txt - repo - - + + + LGPL-2.1 + https://github.com/micro-manager/mmCoreAndDevices/blob/main/MMCoreJ_wrap/license.txt + repo + + - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - add-source - generate-sources - - add-source - - - - ../build/intermediates/Swig - - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://s01.oss.sonatype.org/ - true - - - - - - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + add-source + generate-sources + + add-source + + + + ../build/intermediates/Swig + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + - From 7b2b52da324216f549b45698b7e36c56bde6a18a Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 09:20:47 -0600 Subject: [PATCH 04/20] pom.xml typos --- MMCoreJ_wrap/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index de3eb25f8..2153472a9 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -5,8 +5,8 @@ jar 11.11.0 Micro-Manager Java Interface to MMCore - Micro-Manager is open source software for control of automated/motorized microscopes. This specific packages provides the Java interface to the device abstractino layer (MMCore) that is written in C++ with a C-interface - http://micro-manager.org + Micro-Manager is open source software for control of automated/motorized microscopes. This specific packages provides the Java interface to the device abstraction layer (MMCore) that is written in C++ with a C-interface + https://micro-manager.org 1.8 From 1fffa4035502a99a7ffad3ac990248ac8477f676 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 09:30:59 -0600 Subject: [PATCH 05/20] Reorder pom.xml sections Put in more logical order. Also remove redundant packaging=jar (it's the default). --- MMCoreJ_wrap/pom.xml | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 2153472a9..d8237ad75 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -1,18 +1,24 @@ - + 4.0.0 + org.micro-manager.mmcorej MMCoreJ - jar 11.11.0 + Micro-Manager Java Interface to MMCore Micro-Manager is open source software for control of automated/motorized microscopes. This specific packages provides the Java interface to the device abstraction layer (MMCore) that is written in C++ with a C-interface https://micro-manager.org - - 1.8 - 1.8 - UTF-8 - + + + LGPL-2.1 + https://github.com/micro-manager/mmCoreAndDevices/blob/main/MMCoreJ_wrap/license.txt + repo + + @@ -38,13 +44,11 @@ scm:git:git@github.com:micro-manager/mmCoreAndDevices.git - - - LGPL-2.1 - https://github.com/micro-manager/mmCoreAndDevices/blob/main/MMCoreJ_wrap/license.txt - repo - - + + 1.8 + 1.8 + UTF-8 + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.6.2 + + + enforce-maven + + enforce + + + + + 3.6.3 + + + + + + + + org.codehaus.mojo build-helper-maven-plugin - 1.7 + 3.6.1 add-source @@ -70,16 +89,18 @@ - ../build/intermediates/Swig + builddir/generated-java + + org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.4.0 attach-sources @@ -89,10 +110,12 @@ + + org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 + 3.12.0 attach-javadocs @@ -102,10 +125,12 @@ + + org.apache.maven.plugins maven-gpg-plugin - 1.5 + 3.2.8 sign-artifacts @@ -116,28 +141,6 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://s01.oss.sonatype.org/ - true - - - - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - From 094478216bae9c2c984ce71daacad7466373e57f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 11:31:49 -0600 Subject: [PATCH 10/20] Use pom property to specify Meson builddir It's cleaner for the outer script to set builddir equally for Meson and Maven, so parameterize. --- MMCoreJ_wrap/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 05531ff7d..20dcf628f 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -48,6 +48,7 @@ 1.8 1.8 UTF-8 + builddir @@ -89,7 +90,7 @@ - builddir/generated-java + ${meson.build.dir}/generated-java From 5795ab463012b8de67ac095bfc87fd5d4d701e6f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 11:32:38 -0600 Subject: [PATCH 11/20] Disable javadoc warnings for now Until we have a proper way to address them, there're not helpful. --- MMCoreJ_wrap/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 20dcf628f..18a9e26c7 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -117,6 +117,10 @@ org.apache.maven.plugins maven-javadoc-plugin 3.12.0 + + + none + attach-javadocs From 93c7d9641597d4cd235d65306918ec6e7278d12f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 17:39:51 -0600 Subject: [PATCH 12/20] Package native libraries in jar with classifiers (Assisted by Claude Code; any errors are mine.) --- MMCoreJ_wrap/pom.xml | 218 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 216 insertions(+), 2 deletions(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 18a9e26c7..24303e4a1 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -49,18 +49,37 @@ 1.8 UTF-8 builddir + + + natives-${natives.os}-${natives.arch} + ${native.library.prefix}MMCoreJ_wrap${native.library.suffix} + ${meson.build.dir}/${native.library.name} + + + false - org.apache.maven.plugins maven-enforcer-plugin 3.6.2 + enforce-maven enforce @@ -73,6 +92,60 @@ + + enforce-platform-supported + validate + + enforce + + + ${skip.natives} + + + natives.os + +Property natives.os is not set, probably because the OS could not be detected. +Set natives.os to a supported value: linux, macos, windows. +Also set native.library.prefix and native.library.suffix appropriately. +Set -Dskip.natives=true to build only the main JAR. + + + + natives.arch + +Property natives.arch is not set, probably because it could not be detected. +Set natives.arch to a supported value: x86_64, arm64, or arm32. +Set -Dskip.natives=true to build only the main JAR. + + + + + + + enforce-native-library-exists + prepare-package + + enforce + + + ${skip.natives} + + + + ${native.library.path} + + +Native library not found: ${native.library.path} +Run the Meson build first: + meson setup ${meson.build.dir} + meson compile -C ${meson.build.dir} +Also check that native.library.prefix and native.library.suffix are correct. +Or set -Dskip.natives=true to build only the main JAR. + + + + + @@ -146,6 +219,147 @@ + + + + org.apache.maven.plugins + maven-resources-plugin + 3.4.0 + + + stage-native-library + prepare-package + + copy-resources + + + ${skip.natives} + ${project.build.directory}/natives-staging/natives/${natives.os}/${natives.arch} + + + ${meson.build.dir} + + ${native.library.name} + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + natives-jar + package + + jar + + + true + ${natives.classifier} + ${project.build.directory}/natives-staging + + natives/** + + + + + + + + + + natives-os-linux + + Linux + + + linux + lib + .so + + + + natives-os-macos + + mac + + + macos + lib + .dylib + + + + natives-os-windows + + windows + + + windows + + .dll + + + + + + + natives-arch-amd64 + + amd64 + + + x86_64 + + + + + natives-arch-x86_64 + + x86_64 + + + x86_64 + + + + + natives-arch-aarch64 + + aarch64 + + + arm64 + + + + + natives-arch-arm + + arm + + + arm32 + + + + + natives-arch-armv7l + + armv7l + + + arm32 + + + From 59275065e92112b527e241e5605374c7efdc4e7d Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 18:01:35 -0600 Subject: [PATCH 13/20] Add README; unpin mmdevice/mmcore commit There is not much point in pinning the mmdevice and mmcore commits until MMCoreJ is in its own repository and no longer in mmCoreAndDevices. --- MMCoreJ_wrap/README.md | 31 ++++++++++++++++++++++++++ MMCoreJ_wrap/meson.build | 8 +------ MMCoreJ_wrap/subprojects/mmcore.wrap | 2 +- MMCoreJ_wrap/subprojects/mmdevice.wrap | 2 +- 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 MMCoreJ_wrap/README.md diff --git a/MMCoreJ_wrap/README.md b/MMCoreJ_wrap/README.md new file mode 100644 index 000000000..f11218e8e --- /dev/null +++ b/MMCoreJ_wrap/README.md @@ -0,0 +1,31 @@ +# MMCoreJ + +MMCoreJ provides Java bindings for MMCore, Micro-Manager's hardware abstraction +layer, written in C++. + +## Building MMCoreJ + +The currently "supported" way to build MMCoreJ is to run the full Micro-Manager +build (using Ant on Windows and Autoconf/Automake elsewhere). + +However, we are working to make MMCoreJ an independent project with its own +build system using Meson for the C++ parts and Maven for the Java parts. + +You can test the new build system as follows. Note that SWIG version 2.x or 3.x +(not 4.x) must be available on the path. + +```sh +# Copy over matching sources for MMDevice and MMCore (otherwise they will be +# fetched by Meson but may not be the correct versions). +rm -rf subprojects/mmdevice subprojects/mmcore +cp -R ../MMDeivce subprojects/mmdevice +cp -R ../MMCore subprojects/mmcore + +meson setup --vsenv builddir # --vsenv recommended on Windows +meson compile -C builddir +mvn package +``` + +This should place the built JARs in target/. There is a main JAR containing the +Java classes and a separate per-OS/architecture "natives" JAR containing the +native library. diff --git a/MMCoreJ_wrap/meson.build b/MMCoreJ_wrap/meson.build index ef794f5b0..5be44414f 100644 --- a/MMCoreJ_wrap/meson.build +++ b/MMCoreJ_wrap/meson.build @@ -1,12 +1,6 @@ # This Meson script is experimental and potentially incomplete. It is not part # of the supported build system for Micro-Manager or mmCoreAndDevices. -# IMPORTANT: This build script uses mmcore and mmdevice from the mirror -# repositories, not the MMCore/ and MMDevice/ in mmCoreAndDevices. This is -# because this build script is expected to be put in use when MMCoreJ is moved -# out of mmCoreAndDevices. -# The versions used are defined in mmdevice.wrap and mmcore.wrap. - project( 'mmcorej', 'cpp', 'java', @@ -41,7 +35,7 @@ mmcore_proj = subproject( 'tests': 'disabled', }, ) -mmcore_dep = mmcore_proj.get_variable('mmcore') +mmcore_dep = mmcore_proj.get_variable('mmcore_dep') jni_dep = dependency('jni', version: '>= 1.8.0') diff --git a/MMCoreJ_wrap/subprojects/mmcore.wrap b/MMCoreJ_wrap/subprojects/mmcore.wrap index c0689630a..345cb664f 100644 --- a/MMCoreJ_wrap/subprojects/mmcore.wrap +++ b/MMCoreJ_wrap/subprojects/mmcore.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/micro-manager/mmcore.git -revision = 187adc00dac41b5257dc34068cc42042152dcd93 +revision = HEAD depth = 1 [provide] diff --git a/MMCoreJ_wrap/subprojects/mmdevice.wrap b/MMCoreJ_wrap/subprojects/mmdevice.wrap index e87745973..d3d5465d3 100644 --- a/MMCoreJ_wrap/subprojects/mmdevice.wrap +++ b/MMCoreJ_wrap/subprojects/mmdevice.wrap @@ -1,6 +1,6 @@ [wrap-git] url = https://github.com/micro-manager/mmdevice.git -revision = 19efe5076245d19ccb486ee337f2330f172ce180 +revision = HEAD depth = 1 [provide] From ed41fe6a50a4cd233f0f241bd007a87d10a30c1d Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 19:27:58 -0600 Subject: [PATCH 14/20] Check that SWIG-generated Java sources are present Without this, there is the danger of producing a jar with only the static sources. (Assisted by Claude Code; any errors are mine.) --- MMCoreJ_wrap/pom.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 24303e4a1..f54fdb760 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -146,6 +146,28 @@ Or set -Dskip.natives=true to build only the main JAR. + + enforce-generated-sources-exist + process-sources + + enforce + + + + + + ${meson.build.dir}/generated-java/mmcorej/CMMCore.java + + +Generated Java sources not found: ${meson.build.dir}/generated-java/mmcorej/*.java +Run the Meson build first: + meson setup ${meson.build.dir} + meson compile -C ${meson.build.dir} + + + + + From d37c62f85ce48b345a86681ba1f32bc7f3131734 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 19:30:13 -0600 Subject: [PATCH 15/20] Comments --- MMCoreJ_wrap/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index f54fdb760..d2982f874 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -48,6 +48,8 @@ 1.8 1.8 UTF-8 + + builddir + false From 57168b2e11e912afdf5e03431e543083e8cde32f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 10 Dec 2025 19:43:11 -0600 Subject: [PATCH 16/20] Prevent leftover native libs from being packaged (Assisted by Claude Code; any errors are mine.) --- MMCoreJ_wrap/pom.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index d2982f874..2b1cb7c92 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -244,6 +244,31 @@ Run the Meson build first: + + + org.apache.maven.plugins + maven-clean-plugin + 3.5.0 + + + clean-natives-staging + prepare-package + + clean + + + true + + + ${project.build.directory}/natives-staging + + + + + + + org.apache.maven.plugins From 31b218a944a348f4e9fb6f0fbf8fdc0259b1ab23 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Thu, 11 Dec 2025 10:12:24 -0600 Subject: [PATCH 17/20] Add full-sources jar (complete source dist) (Assisted by Claude Code; any errors are mine.) --- MMCoreJ_wrap/pom.xml | 25 +++- .../scripts/verify-full-sources-jar.sh | 124 ++++++++++++++++++ MMCoreJ_wrap/src/assembly/full-sources.xml | 67 ++++++++++ 3 files changed, 215 insertions(+), 1 deletion(-) create mode 100755 MMCoreJ_wrap/scripts/verify-full-sources-jar.sh create mode 100644 MMCoreJ_wrap/src/assembly/full-sources.xml diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 2b1cb7c92..4baee4138 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -194,7 +194,8 @@ Run the Meson build first: - + org.apache.maven.plugins maven-source-plugin @@ -209,6 +210,28 @@ Run the Meson build first: + + + org.apache.maven.plugins + maven-assembly-plugin + 3.7.1 + + + full-sources-jar + package + + single + + + + src/assembly/full-sources.xml + + + + + + org.apache.maven.plugins diff --git a/MMCoreJ_wrap/scripts/verify-full-sources-jar.sh b/MMCoreJ_wrap/scripts/verify-full-sources-jar.sh new file mode 100755 index 000000000..1241b4ae1 --- /dev/null +++ b/MMCoreJ_wrap/scripts/verify-full-sources-jar.sh @@ -0,0 +1,124 @@ +#!/bin/bash +# Verify that the full-sources JAR contains all expected source files. +# Usage: ./scripts/verify-full-sources-jar.sh [path-to-jar] +# +# Works whether MMCoreJ_wrap is its own repo (for future) or a subdirectory of +# mmCoreAndDevices. + +set -e + +JAR_FILE="${1:-target/MMCoreJ-*-full-sources.jar}" + +# Files that may be omitted from the JAR despite being in git. +ALLOWED_MISSING=( + 'Makefile.am' + 'build.xml' + '*.vcxproj' + '*.vcxproj.filters' +) + +# Subprojects to check for source files. +SUBPROJECTS=( + 'subprojects/mmcore' + 'subprojects/mmdevice' +) + +# Expand glob if needed +JAR_FILE=$(echo $JAR_FILE) + +if [[ ! -f "$JAR_FILE" ]]; then + echo "ERROR: JAR file not found: $JAR_FILE" + echo "Run 'mvn package' first." + exit 1 +fi + +echo "Verifying: $JAR_FILE" + +# Verify subprojects exist on filesystem (required as reference for JAR verification) +for subproj in "${SUBPROJECTS[@]}"; do + if [[ ! -d "$subproj" ]]; then + echo "ERROR: Required subproject directory not found: $subproj" + echo "Run 'meson setup' before 'mvn package'." + exit 1 + fi + if [[ ! -f "$subproj/meson.build" ]]; then + echo "ERROR: Subproject missing meson.build: $subproj" + echo "Subproject may be incomplete or corrupted." + exit 1 + fi +done + +# Create temp files for comparison +JAR_CONTENTS=$(mktemp) +EXPECTED_FILES=$(mktemp) +trap "rm -f $JAR_CONTENTS $EXPECTED_FILES" EXIT + +# Detect if we're in a subdirectory of a larger git repo. +# If so, we need to strip the prefix from git ls-files output. +# Empty if at root, "subdir/" if in subdir: +GIT_PREFIX=$(git rev-parse --show-prefix) + +# List JAR contents (excluding META-INF/) +jar tf "$JAR_FILE" | grep -v 'META-INF' | sort > "$JAR_CONTENTS" + +# Helper to strip the git prefix from paths +strip_prefix() { + if [[ -n "$GIT_PREFIX" ]]; then + sed "s|^${GIT_PREFIX}||" + else + cat + fi +} + +# Helper to filter out allowed missing files +filter_allowed_missing() { + local result + result=$(cat) + for pattern in "${ALLOWED_MISSING[@]}"; do + # Convert glob pattern to grep -v pattern + # e.g., *.vcxproj -> \.vcxproj$ + local regex=$(echo "$pattern" | sed 's/\./\\./g' | sed 's/\*/.*/g') + result=$(echo "$result" | grep -v "$regex" || true) + done + echo "$result" +} + +# Build expected file list from git +{ + # All files tracked by git in this directory + git ls-files --full-name | strip_prefix + + # subprojects (from submodules - have their own .git) + for subproj in "${SUBPROJECTS[@]}"; do + if [[ -d "$subproj" ]]; then + if [[ -e "$subproj/.git" ]]; then + # Submodule: query its own git + git -C "$subproj" ls-files --full-name | sed "s|^|$subproj/|" + else + # Not a git repo: enumerate all files on disk + # (meson.build existence already verified above) + find "$subproj" -type f + fi + fi + done +} | sort -u > "$EXPECTED_FILES" + +# Compare (filtering out allowed missing files) +MISSING=$(comm -23 "$EXPECTED_FILES" "$JAR_CONTENTS" | filter_allowed_missing) + +if [[ -n "$MISSING" ]]; then + echo "ERROR: The following expected source files are missing from the JAR:" + echo "$MISSING" + exit 1 +fi + +echo "OK: All expected source files are present in the JAR." +# Optionally show extra files in JAR (not an error, just informational) +# Filter out directory entries (end with /) and blank lines +EXTRA=$(comm -13 "$EXPECTED_FILES" "$JAR_CONTENTS" | grep -v '/$' | grep -v '^$' || true) +if [[ -n "$EXTRA" ]]; then + echo "Note: JAR contains additional files not in git (this is OK):" + echo "$EXTRA" +fi + +exit 0 diff --git a/MMCoreJ_wrap/src/assembly/full-sources.xml b/MMCoreJ_wrap/src/assembly/full-sources.xml new file mode 100644 index 000000000..29225af9f --- /dev/null +++ b/MMCoreJ_wrap/src/assembly/full-sources.xml @@ -0,0 +1,67 @@ + + full-sources + + + + + jar + + false + + + + + ${project.basedir} + true + + + + builddir*/** + build/** + target/** + gensrc/** + + MMCoreJ_wrap.cxx + MMCoreJ_wrap.h + + **/Makefile.am + **/build.xml + **/*.vcxproj + **/*.vcxproj.filters + + **/*.o + **/*.lo + **/*.a + **/*.la + **/*.lai + **/*.so + **/*.dylib + **/*.jnilib + **/*.jar + **/*.class + **/*.stamp + **/*.Plo + + .deps/** + .libs/** + Makefile + Makefile.in + + .vscode/** + .idea/** + + subprojects/.wraplock + **/.meson-subproject-wrap-hash.txt + + + + From 43d7b1c759b7e66b45c3113f8fd4a70b65802d25 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Thu, 18 Dec 2025 12:59:32 -0600 Subject: [PATCH 18/20] Remove GPG signing from pom.xml Signing (among other things) will most likely be handled by JReleaser. --- MMCoreJ_wrap/pom.xml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 4baee4138..3cf9efe36 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -251,22 +251,6 @@ Run the Meson build first: - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.8 - - - sign-artifacts - verify - - sign - - - - - From 9b48c181ef6b0467527ee66ad1a67957ffbdc04f Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Thu, 18 Dec 2025 15:20:51 -0600 Subject: [PATCH 19/20] Flatten the published POM This has mainly 2 advantages for us: - It removes all the built-time profile/property settings, which could make the pom appear more complicated than it is for people looking to use MMCoreJ as a dependency. So flatten it to what a dependency resolver (Maven/Gradle) will actually see. - It can allow parameterizing essential values, such as version, by templating them and passing them in on the `mvn` command line. --- MMCoreJ_wrap/.gitignore | 1 + MMCoreJ_wrap/pom.xml | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/MMCoreJ_wrap/.gitignore b/MMCoreJ_wrap/.gitignore index e3eec46cd..bc654be1e 100644 --- a/MMCoreJ_wrap/.gitignore +++ b/MMCoreJ_wrap/.gitignore @@ -1,2 +1,3 @@ .wraplock /target/ +.flattened-pom.xml diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 3cf9efe36..72c9ca65d 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -327,6 +327,33 @@ Run the Meson build first: + + + + org.codehaus.mojo + flatten-maven-plugin + 1.7.3 + + oss + + + + flatten + process-resources + + flatten + + + + flatten-clean + clean + + clean + + + + From 0c79a16c0e938c8b3f78a5c18ca36f8ca77b15e3 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Thu, 18 Dec 2025 15:55:15 -0600 Subject: [PATCH 20/20] Comment (arm32) --- MMCoreJ_wrap/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMCoreJ_wrap/pom.xml b/MMCoreJ_wrap/pom.xml index 72c9ca65d..28ae9af9f 100644 --- a/MMCoreJ_wrap/pom.xml +++ b/MMCoreJ_wrap/pom.xml @@ -435,7 +435,7 @@ Run the Meson build first: - + natives-arch-armv7l armv7l