From de8714152b8cfa345530fae93de53b84b672b924 Mon Sep 17 00:00:00 2001 From: Flavio Soibelmann Glock Date: Wed, 22 Apr 2026 20:32:49 +0200 Subject: [PATCH] fix(MakeMaker): defer install to `make install`, fix `cpan -t` installing The PerlOnJava MakeMaker previously did the real install into INSTALLSITELIB from the `all::` target (via `pm_to_blib::`), so `make` alone was enough to populate ~/.perlonjava/lib. Because CPAN.pm runs `make` before `make test`, this caused `jcpan -t Module` (test-only) to silently install the module as a side effect of building it, violating the standard `cpan -t` contract. Realign the generated Makefile with standard ExtUtils::MakeMaker: - `pm_to_blib::` now stages module/data files into `./blib/lib` only (it used to copy straight to INSTALLSITELIB). - `pure_all::` becomes an alias that depends on `pm_to_blib` (kept so File::ShareDir::Install / Alien::Build postambles keep working). - `all::` just builds ./blib. Its echo says "built" instead of "installed". - `install::` depends on `all install_scripts` and now actually runs the `@install_cmds` copying ./lib -> INSTALLSITELIB, plus the "installed" echo. Behavior now matches `perl Makefile.PL` output: jcpan -t OpenAPI -> builds + tests, does NOT populate ~/.perlonjava/lib jcpan -i OpenAPI -> builds + tests + installs jcpan -t Tie::RegexpHash on a failing test -> test harness finds the module via blib/lib (tests actually run), and because `make test` exits non-zero CPAN skips `make install`, so nothing is installed. Also updates the Makefile.PL post-config banner from "when 'make' runs" to "when 'make install' runs" to reflect the new semantics. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../org/perlonjava/core/Configuration.java | 4 +- src/main/perl/lib/ExtUtils/MakeMaker.pm | 40 ++++++++++++------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/perlonjava/core/Configuration.java b/src/main/java/org/perlonjava/core/Configuration.java index e61177f82..a42508320 100644 --- a/src/main/java/org/perlonjava/core/Configuration.java +++ b/src/main/java/org/perlonjava/core/Configuration.java @@ -33,7 +33,7 @@ public final class Configuration { * Automatically populated by Gradle/Maven during build. * DO NOT EDIT MANUALLY - this value is replaced at build time. */ - public static final String gitCommitId = "00cdd0b3a"; + public static final String gitCommitId = "00a6d786f"; /** * Git commit date of the build (ISO format: YYYY-MM-DD). @@ -48,7 +48,7 @@ public final class Configuration { * Parsed by App::perlbrew and other tools via: perl -V | grep "Compiled at" * DO NOT EDIT MANUALLY - this value is replaced at build time. */ - public static final String buildTimestamp = "Apr 23 2026 07:38:18"; + public static final String buildTimestamp = "Apr 23 2026 08:15:23"; // Prevent instantiation private Configuration() { diff --git a/src/main/perl/lib/ExtUtils/MakeMaker.pm b/src/main/perl/lib/ExtUtils/MakeMaker.pm index 044cc106c..0781d6a5c 100644 --- a/src/main/perl/lib/ExtUtils/MakeMaker.pm +++ b/src/main/perl/lib/ExtUtils/MakeMaker.pm @@ -371,7 +371,7 @@ sub _install_pure_perl { my $total = scalar(keys %pm) + scalar(keys %scripts); print "=" x 60, "\n"; - print "Configured! $total files will be installed when 'make' runs.\n"; + print "Configured! $total files will be installed when 'make install' runs.\n"; print "=" x 60, "\n\n"; return $mm; @@ -454,9 +454,11 @@ sub _extract_version { sub _create_install_makefile { my ($name, $version, $args, $pm, $scripts, $mm) = @_; - # Create a Makefile that actually installs files when 'make' runs. - # This defers installation to after CPAN.pm has resolved and installed - # dependencies, enabling proper dependency resolution for any CPAN module. + # Create a Makefile that builds into ./blib when 'make' runs, runs tests + # against ./blib when 'make test' runs, and copies files to INSTALLSITELIB + # only when 'make install' runs. This matches standard ExtUtils::MakeMaker + # semantics so that 'cpan -t' (test-only) does not install the module, + # and lets CPAN.pm resolve/install dependencies before the install step. # Respect custom MAKEFILE name if provided my $makefile = $args->{MAKEFILE} || 'Makefile'; @@ -604,8 +606,11 @@ sub _create_install_makefile { print $fh <<"MAKEFILE"; # Makefile generated by PerlOnJava MakeMaker -# Files are installed during 'make' (not during Makefile.PL) -# This enables CPAN.pm to resolve dependencies before installation +# 'make' builds into ./blib (no files installed to site libdir) +# 'make test' runs the test harness against ./blib +# 'make install' copies ./blib files to INSTALLSITELIB +# This matches standard ExtUtils::MakeMaker semantics so that 'cpan -t' +# (test only) does not install, while 'cpan -i' (install) does. $prereq_comment NAME = $name DISTNAME = $distname @@ -618,18 +623,20 @@ NOECHO = \@ RM_RF = rm -rf all:: pm_to_blib pure_all pl_files blib_scripts config -\t\@echo "PerlOnJava: $name v$version installed ($file_count files)" +\t\@echo "PerlOnJava: $name v$version built ($file_count files in ./blib)" -# Copy module and data files to installation directory +# pm_to_blib: stage module/data files into ./blib/lib (matches standard +# ExtUtils::MakeMaker). Files are NOT copied to INSTALLSITELIB here; +# that happens in the 'install' target. +# Also create blib/arch so that "use blib" / "-Mblib" works (blib.pm requires both). pm_to_blib:: -$install_cmds_str - -# Copy to blib/lib for test compatibility (make test uses PERL5LIB=./blib/lib) -# Also create blib/arch so that "use blib" / "-Mblib" works (blib.pm requires both) -pure_all:: \t\@mkdir -p blib/arch $blib_cmds_str +# pure_all is an alias target some postambles (File::ShareDir::Install, +# Alien::Build) hook to add extra blib-staging steps. Depends on pm_to_blib. +pure_all:: pm_to_blib + # Stage EXE_FILES into blib/script/ so tests can invoke them via the blib tree blib_scripts:: $blib_script_cmds_str @@ -638,7 +645,7 @@ $blib_script_cmds_str pl_files:: $pl_cmds_str -# Install executable scripts +# Install executable scripts (called only from 'install') install_scripts:: $script_cmds_str @@ -651,8 +658,11 @@ config:: test:: \t$test_cmd +# install: copy staged files from ./lib to INSTALLSITELIB, plus scripts. +# Depends on 'all' to ensure blib is built first (matches standard MakeMaker). install:: all install_scripts -\t\@echo "PerlOnJava: $name installed to \$(INSTALLSITELIB)" +$install_cmds_str +\t\@echo "PerlOnJava: $name v$version installed ($file_count files) to \$(INSTALLSITELIB)" clean:: \t\$(RM_RF) blib pm_to_blib