Skip to content

Commit 790a55c

Browse files
committed
Add full-sources jar (complete source dist)
(Assisted by Claude Code; any errors are mine.)
1 parent cf41b36 commit 790a55c

File tree

3 files changed

+215
-1
lines changed

3 files changed

+215
-1
lines changed

MMCoreJ_wrap/pom.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ Run the Meson build first:
194194
</executions>
195195
</plugin>
196196

197-
<!-- Source JAR -->
197+
<!-- Source JAR (Java sources only but includes generated sources;
198+
good for IDEs to pull) -->
198199
<plugin>
199200
<groupId>org.apache.maven.plugins</groupId>
200201
<artifactId>maven-source-plugin</artifactId>
@@ -209,6 +210,28 @@ Run the Meson build first:
209210
</executions>
210211
</plugin>
211212

213+
<!-- Full source JAR (A full source distribution including mmcore
214+
and mmdevice, but excluding generated sources) -->
215+
<plugin>
216+
<groupId>org.apache.maven.plugins</groupId>
217+
<artifactId>maven-assembly-plugin</artifactId>
218+
<version>3.7.1</version>
219+
<executions>
220+
<execution>
221+
<id>full-sources-jar</id>
222+
<phase>package</phase>
223+
<goals>
224+
<goal>single</goal>
225+
</goals>
226+
<configuration>
227+
<descriptors>
228+
<descriptor>src/assembly/full-sources.xml</descriptor>
229+
</descriptors>
230+
</configuration>
231+
</execution>
232+
</executions>
233+
</plugin>
234+
212235
<!-- Javadoc JAR -->
213236
<plugin>
214237
<groupId>org.apache.maven.plugins</groupId>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
# Verify that the full-sources JAR contains all expected source files.
3+
# Usage: ./scripts/verify-full-sources-jar.sh [path-to-jar]
4+
#
5+
# Works whether MMCoreJ_wrap is its own repo (for future) or a subdirectory of
6+
# mmCoreAndDevices.
7+
8+
set -e
9+
10+
JAR_FILE="${1:-target/MMCoreJ-*-full-sources.jar}"
11+
12+
# Files that may be omitted from the JAR despite being in git.
13+
ALLOWED_MISSING=(
14+
'Makefile.am'
15+
'build.xml'
16+
'*.vcxproj'
17+
'*.vcxproj.filters'
18+
)
19+
20+
# Subprojects to check for source files.
21+
SUBPROJECTS=(
22+
'subprojects/mmcore'
23+
'subprojects/mmdevice'
24+
)
25+
26+
# Expand glob if needed
27+
JAR_FILE=$(echo $JAR_FILE)
28+
29+
if [[ ! -f "$JAR_FILE" ]]; then
30+
echo "ERROR: JAR file not found: $JAR_FILE"
31+
echo "Run 'mvn package' first."
32+
exit 1
33+
fi
34+
35+
echo "Verifying: $JAR_FILE"
36+
37+
# Verify subprojects exist on filesystem (required as reference for JAR verification)
38+
for subproj in "${SUBPROJECTS[@]}"; do
39+
if [[ ! -d "$subproj" ]]; then
40+
echo "ERROR: Required subproject directory not found: $subproj"
41+
echo "Run 'meson setup' before 'mvn package'."
42+
exit 1
43+
fi
44+
if [[ ! -f "$subproj/meson.build" ]]; then
45+
echo "ERROR: Subproject missing meson.build: $subproj"
46+
echo "Subproject may be incomplete or corrupted."
47+
exit 1
48+
fi
49+
done
50+
51+
# Create temp files for comparison
52+
JAR_CONTENTS=$(mktemp)
53+
EXPECTED_FILES=$(mktemp)
54+
trap "rm -f $JAR_CONTENTS $EXPECTED_FILES" EXIT
55+
56+
# Detect if we're in a subdirectory of a larger git repo.
57+
# If so, we need to strip the prefix from git ls-files output.
58+
# Empty if at root, "subdir/" if in subdir:
59+
GIT_PREFIX=$(git rev-parse --show-prefix)
60+
61+
# List JAR contents (excluding META-INF/)
62+
jar tf "$JAR_FILE" | grep -v 'META-INF' | sort > "$JAR_CONTENTS"
63+
64+
# Helper to strip the git prefix from paths
65+
strip_prefix() {
66+
if [[ -n "$GIT_PREFIX" ]]; then
67+
sed "s|^${GIT_PREFIX}||"
68+
else
69+
cat
70+
fi
71+
}
72+
73+
# Helper to filter out allowed missing files
74+
filter_allowed_missing() {
75+
local result
76+
result=$(cat)
77+
for pattern in "${ALLOWED_MISSING[@]}"; do
78+
# Convert glob pattern to grep -v pattern
79+
# e.g., *.vcxproj -> \.vcxproj$
80+
local regex=$(echo "$pattern" | sed 's/\./\\./g' | sed 's/\*/.*/g')
81+
result=$(echo "$result" | grep -v "$regex" || true)
82+
done
83+
echo "$result"
84+
}
85+
86+
# Build expected file list from git
87+
{
88+
# All files tracked by git in this directory
89+
git ls-files --full-name | strip_prefix
90+
91+
# subprojects (from submodules - have their own .git)
92+
for subproj in "${SUBPROJECTS[@]}"; do
93+
if [[ -d "$subproj" ]]; then
94+
if [[ -e "$subproj/.git" ]]; then
95+
# Submodule: query its own git
96+
git -C "$subproj" ls-files --full-name | sed "s|^|$subproj/|"
97+
else
98+
# Not a git repo: enumerate all files on disk
99+
# (meson.build existence already verified above)
100+
find "$subproj" -type f
101+
fi
102+
fi
103+
done
104+
} | sort -u > "$EXPECTED_FILES"
105+
106+
# Compare (filtering out allowed missing files)
107+
MISSING=$(comm -23 "$EXPECTED_FILES" "$JAR_CONTENTS" | filter_allowed_missing)
108+
109+
if [[ -n "$MISSING" ]]; then
110+
echo "ERROR: The following expected source files are missing from the JAR:"
111+
echo "$MISSING"
112+
exit 1
113+
fi
114+
115+
echo "OK: All expected source files are present in the JAR."
116+
# Optionally show extra files in JAR (not an error, just informational)
117+
# Filter out directory entries (end with /) and blank lines
118+
EXTRA=$(comm -13 "$EXPECTED_FILES" "$JAR_CONTENTS" | grep -v '/$' | grep -v '^$' || true)
119+
if [[ -n "$EXTRA" ]]; then
120+
echo "Note: JAR contains additional files not in git (this is OK):"
121+
echo "$EXTRA"
122+
fi
123+
124+
exit 0
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0
4+
https://maven.apache.org/xsd/assembly-2.2.0.xsd">
5+
<id>full-sources</id>
6+
7+
<!-- This assembly is part of the Meson/Maven build system (see
8+
full-sources-jar in pom.xml). It is not used when building with Ant or
9+
Autoconf/Automake. -->
10+
11+
<formats>
12+
<format>jar</format>
13+
</formats>
14+
<includeBaseDirectory>false</includeBaseDirectory>
15+
16+
<!-- Include all source files under Git, plus subprojects mmdevice and
17+
mmcore, for a full source package that can be built without additional LGPL
18+
dependencies. Use scripts/verify-full-sources-jar.sh to verify
19+
completeness. -->
20+
<fileSets>
21+
<fileSet>
22+
<directory>${project.basedir}</directory>
23+
<useDefaultExcludes>true</useDefaultExcludes>
24+
<excludes>
25+
<!-- These exclusions will be simpler once we've removed the
26+
legacy build systems -->
27+
<!-- Build output -->
28+
<exclude>builddir*/**</exclude>
29+
<exclude>build/**</exclude>
30+
<exclude>target/**</exclude>
31+
<exclude>gensrc/**</exclude>
32+
<!-- SWIG-generated (Autotools build) -->
33+
<exclude>MMCoreJ_wrap.cxx</exclude>
34+
<exclude>MMCoreJ_wrap.h</exclude>
35+
<!-- Legacy build system -->
36+
<exclude>**/Makefile.am</exclude>
37+
<exclude>**/build.xml</exclude>
38+
<exclude>**/*.vcxproj</exclude>
39+
<exclude>**/*.vcxproj.filters</exclude>
40+
<!-- Compiled/build artifacts -->
41+
<exclude>**/*.o</exclude>
42+
<exclude>**/*.lo</exclude>
43+
<exclude>**/*.a</exclude>
44+
<exclude>**/*.la</exclude>
45+
<exclude>**/*.lai</exclude>
46+
<exclude>**/*.so</exclude>
47+
<exclude>**/*.dylib</exclude>
48+
<exclude>**/*.jnilib</exclude>
49+
<exclude>**/*.jar</exclude>
50+
<exclude>**/*.class</exclude>
51+
<exclude>**/*.stamp</exclude>
52+
<exclude>**/*.Plo</exclude>
53+
<!-- Autotools generated -->
54+
<exclude>.deps/**</exclude>
55+
<exclude>.libs/**</exclude>
56+
<exclude>Makefile</exclude>
57+
<exclude>Makefile.in</exclude>
58+
<!-- IDE/editor files -->
59+
<exclude>.vscode/**</exclude>
60+
<exclude>.idea/**</exclude>
61+
<!-- Meson wrap lock -->
62+
<exclude>subprojects/.wraplock</exclude>
63+
<exclude>**/.meson-subproject-wrap-hash.txt</exclude>
64+
</excludes>
65+
</fileSet>
66+
</fileSets>
67+
</assembly>

0 commit comments

Comments
 (0)