From 2fe15a660e5b06ce8f8a82fd453aa3875a275d77 Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Fri, 15 May 2026 03:29:27 -0400 Subject: [PATCH 1/2] ask parent project to run a goal if pasbuild is run on a module of a project in it's dir --- src/main/pascal/PasBuild.pas | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/pascal/PasBuild.pas b/src/main/pascal/PasBuild.pas index 331a36e..3fce9b7 100644 --- a/src/main/pascal/PasBuild.pas +++ b/src/main/pascal/PasBuild.pas @@ -54,6 +54,10 @@ PluginPath: string; PhaseInfo: TPluginPhaseInfo; CompilerPath: string; + ParentXml: string; + ParentConfig: TProjectConfig; + IsParentPom: Boolean; + ModuleName: string; begin // Parse command line arguments @@ -148,7 +152,7 @@ else begin try - Config := TConfigLoader.LoadProjectXML(Args.ProjectFile); + Config := TConfigLoader.LoadProjectXML(Args.ProjectFile, True); except on E: EProjectConfigError do begin @@ -163,6 +167,39 @@ Exit; end; end; + + // When a module omits (inheriting from aggregator) and the user + // ran pasbuild from that module's directory, automatically redirect to the + // parent aggregator and build only this module. + if (Config.Version = '') and (Args.SelectedModule = '') then + begin + ParentXml := ExpandFileName('../project.xml'); + if FileExists(ParentXml) then + begin + ParentConfig := nil; + IsParentPom := False; + try + ParentConfig := TConfigLoader.LoadProjectXML(ParentXml, True); + IsParentPom := ParentConfig.BuildConfig.ProjectType = ptPom; + except + // Ignore load errors; fall through to normal validation (which will + // report the missing on the current project). + end; + if IsParentPom then + begin + ModuleName := Config.Name; + Config.Free; + Config := ParentConfig; + ParentConfig := nil; + TUtils.LogInfo('No found; delegating to aggregator for module "' + ModuleName + '"'); + SetCurrentDir(ExpandFileName('..')); + Args.ProjectFile := 'project.xml'; + Args.SelectedModule := ModuleName; + end + else + ParentConfig.Free; + end; + end; end; try From 464de82aeb2d6721f524e2dbd7d4c493d2451dd3 Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Fri, 15 May 2026 03:39:03 -0400 Subject: [PATCH 2/2] and run the original error --- src/main/pascal/PasBuild.pas | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/pascal/PasBuild.pas b/src/main/pascal/PasBuild.pas index 3fce9b7..42846ee 100644 --- a/src/main/pascal/PasBuild.pas +++ b/src/main/pascal/PasBuild.pas @@ -199,6 +199,13 @@ else ParentConfig.Free; end; + // If still no version after the parent-POM check, restore the original error. + if Config.Version = '' then + begin + TUtils.LogError('Missing required field: '); + ExitCode := 1; + Exit; + end; end; end;