diff --git a/.gitignore b/.gitignore index 207bc8a..1b892d9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,10 @@ # ignore "current" directories /**/current +# Gradle +/.gradle +/build +/.gradle/build-cache + # Qodo /.qodo diff --git a/.gradle-docs/INDEX.md b/.gradle-docs/INDEX.md new file mode 100644 index 0000000..b2367fb --- /dev/null +++ b/.gradle-docs/INDEX.md @@ -0,0 +1,187 @@ +# Documentation Index - phpPgAdmin Module + +Complete documentation index for the Bearsampp phpPgAdmin module Gradle build system. + +## Core Documentation + +### [README.md](README.md) +Main documentation covering: +- Overview and project information +- Quick start guide +- Installation instructions +- Build tasks overview +- Configuration details +- Architecture and build process +- Troubleshooting guide + +### [TASKS.md](TASKS.md) +Complete task reference including: +- Build tasks (`release`, `releaseAll`) +- Verification tasks (`verify`, `validateProperties`, `checkModulesUntouched`) +- Information tasks (`info`, `listVersions`, `listReleases`) +- Cleanup tasks (`clean`, `cleanAll`) +- Task execution examples +- Common task combinations + +--- + +## Quick Reference + +### Essential Commands + +```bash +# Get build information +gradle info + +# List all tasks +gradle tasks + +# Verify environment +gradle verify + +# Build a release +gradle release -PbundleVersion=7.14.7 + +# Build all versions +gradle releaseAll + +# Clean build artifacts +gradle clean +gradle cleanAll +``` + +### Key Files + +| File | Purpose | +|-----------------------|----------------------------------------------| +| `build.gradle` | Main Gradle build script | +| `settings.gradle` | Gradle project settings | +| `build.properties` | Build configuration (bundle info) | +| `gradle.properties` | Gradle-specific configuration | +| `releases.properties` | Local phpPgAdmin release URLs (fallback) | + +### Directory Structure + +``` +module-phppgadmin/ +├── .gradle-docs/ # Documentation +│ ├── INDEX.md # This file +│ ├── README.md # Main documentation +│ └── TASKS.md # Task reference +├── bin/ # phpPgAdmin version bundles +│ ├── phpPgAdmin7.14.7/ +│ └── archived/ # Archived versions +├── build.gradle # Gradle build script +├── settings.gradle # Gradle settings +├── build.properties # Build configuration +└── releases.properties # Release URLs +``` + +--- + +## Documentation by Topic + +### Getting Started +- [Quick Start](README.md#quick-start) - Get up and running quickly +- [Installation](README.md#installation) - Step-by-step setup +- [Prerequisites](README.md#prerequisites) - Required software + +### Building +- [Build Tasks](TASKS.md#build-tasks) - Core build tasks +- [Release Process](README.md#architecture) - How releases are built +- [Build Output](README.md#packaging-details) - Where files are created + +### Configuration +- [build.properties](README.md#buildproperties) - Main configuration +- [gradle.properties](README.md#gradleproperties) - Gradle settings +- [Directory Structure](README.md#directory-structure) - Project layout + +### Verification +- [Verification Tasks](TASKS.md#verification-tasks) - Environment checks +- [Verify Command](TASKS.md#verify) - Check build environment +- [Validate Properties](TASKS.md#validateproperties) - Check configuration + +### Information +- [Information Tasks](TASKS.md#information-tasks) - Get build info +- [List Versions](TASKS.md#listversions) - Available versions +- [List Releases](TASKS.md#listreleases) - Remote releases + +### Troubleshooting +- [Common Issues](README.md#troubleshooting) - Solutions to problems +- [Debug Mode](README.md#debug-mode) - Verbose output +- [Clean Build](README.md#clean-build) - Start fresh + +--- + +## Build System Features + +### Pure Gradle +- No Gradle Wrapper (install Gradle 8+ locally) +- No Ant dependencies (pure Gradle implementation) +- Modern Groovy DSL +- Incremental builds and caching + +### Automatic Downloads +- Downloads phpPgAdmin sources from modules-untouched +- Fallback to local releases.properties +- Automatic extraction and preparation + +### Version Management +- Interactive version selection +- Non-interactive mode with `-PbundleVersion` +- Support for archived versions +- Build all versions at once + +### Hash Generation +- Automatic hash file generation +- MD5, SHA1, SHA256, SHA512 +- Sidecar files for each archive + +### Integration +- modules-untouched repository integration +- Automatic version resolution +- Remote and local fallback + +--- + +## Task Groups + +### Build +- `release` - Build a single version +- `releaseAll` - Build all versions +- `clean` - Clean build artifacts +- `cleanAll` - Clean everything + +### Verification +- `verify` - Verify environment +- `validateProperties` - Validate configuration +- `checkModulesUntouched` - Check integration + +### Help +- `info` - Display build information +- `listVersions` - List local versions +- `listReleases` - List remote releases +- `tasks` - List all tasks + +--- + +## External Resources + +- [Gradle Documentation](https://docs.gradle.org/) +- [Bearsampp Project](https://github.com/bearsampp/bearsampp) +- [phpPgAdmin Project](http://phppgadmin.sourceforge.net/) +- [Bearsampp Module Documentation](https://bearsampp.com/module/phppgadmin) + +--- + +## Support + +For issues and questions: +- **GitHub Issues**: https://github.com/bearsampp/module-phppgadmin/issues +- **Bearsampp Issues**: https://github.com/bearsampp/bearsampp/issues + +--- + +**Last Updated**: 2025-01-31 +**Version**: 2025.10.31 +**Build System**: Pure Gradle (no wrapper, no Ant) diff --git a/.gradle-docs/README.md b/.gradle-docs/README.md new file mode 100644 index 0000000..673c328 --- /dev/null +++ b/.gradle-docs/README.md @@ -0,0 +1,393 @@ +# Bearsampp Module phpPgAdmin - Gradle Build Documentation + +## Table of Contents + +- [Overview](#overview) +- [Quick Start](#quick-start) +- [Installation](#installation) +- [Build Tasks](#build-tasks) +- [Configuration](#configuration) +- [Architecture](#architecture) +- [Troubleshooting](#troubleshooting) + +--- + +## Overview + +The Bearsampp Module phpPgAdmin project uses a **pure Gradle build system** (no wrapper, no Ant). This provides: + +- **Modern Build System** - Native Gradle tasks and conventions +- **Better Performance** - Incremental builds and caching +- **Simplified Maintenance** - Pure Groovy/Gradle DSL +- **Enhanced Tooling** - IDE integration and dependency management +- **Cross-Platform Support** - Works on Windows, Linux, and macOS + +### Project Information + +| Property | Value | +|-------------------|------------------------------------------| +| **Project Name** | module-phppgadmin | +| **Group** | com.bearsampp.modules | +| **Type** | phpPgAdmin Module Builder | +| **Build Tool** | Gradle 8.x+ | +| **Language** | Groovy (Gradle DSL) | + +--- + +## Quick Start + +### Prerequisites + +| Requirement | Version | Purpose | +|-------------------|---------------|------------------------------------------| +| **Java** | 8+ | Required for Gradle execution | +| **Gradle** | 8.0+ | Build automation tool | +| **7-Zip** | Latest | Archive compression | + +### Basic Commands + +```bash +# Display build information +gradle info + +# List all available tasks +gradle tasks + +# Verify build environment +gradle verify + +# Build a release (interactive) +gradle release + +# Build a specific version (non-interactive) +gradle release -PbundleVersion=7.14.7 + +# Clean build artifacts +gradle clean +``` + +--- + +## Installation + +### 1. Clone the Repository + +```bash +git clone https://github.com/bearsampp/module-phppgadmin.git +cd module-phppgadmin +``` + +### 2. Verify Environment + +```bash +gradle verify +``` + +This will check: +- Java version (8+) +- Required files (build.properties) +- Directory structure (bin/) +- Build dependencies (7-Zip) + +### 3. List Available Versions + +```bash +gradle listVersions +``` + +### 4. Build Your First Release + +```bash +# Interactive mode (prompts for version) +gradle release + +# Or specify version directly +gradle release -PbundleVersion=7.14.7 +``` + +--- + +## Build Tasks + +### Core Build Tasks + +| Task | Description | Example | +|-----------------------|--------------------------------------------------|------------------------------------------| +| `release` | Build and package release (interactive/non-interactive) | `gradle release -PbundleVersion=7.14.7` | +| `releaseAll` | Build all available versions | `gradle releaseAll` | +| `clean` | Clean build artifacts | `gradle clean` | +| `cleanAll` | Clean all including downloads | `gradle cleanAll` | + +### Verification Tasks + +| Task | Description | Example | +|---------------------------|----------------------------------------------|----------------------------------------------| +| `verify` | Verify build environment and dependencies | `gradle verify` | +| `validateProperties` | Validate build.properties configuration | `gradle validateProperties` | + +### Information Tasks + +| Task | Description | Example | +|---------------------|--------------------------------------------------|----------------------------| +| `info` | Display build configuration information | `gradle info` | +| `listVersions` | List available bundle versions in bin/ | `gradle listVersions` | +| `listReleases` | List all available releases from modules-untouched | `gradle listReleases` | +| `checkModulesUntouched` | Check modules-untouched integration | `gradle checkModulesUntouched` | + +### Task Groups + +| Group | Purpose | +|------------------|--------------------------------------------------| +| **build** | Build and package tasks | +| **verification** | Verification and validation tasks | +| **help** | Help and information tasks | + +--- + +## Configuration + +### build.properties + +The main configuration file for the build: + +```properties +bundle.name = phpPgAdmin +bundle.release = 2025.10.31 +bundle.type = apps +bundle.format = 7z +``` + +| Property | Description | Example Value | +|-------------------|--------------------------------------|----------------| +| `bundle.name` | Name of the bundle | `phpPgAdmin` | +| `bundle.release` | Release version | `2025.10.31` | +| `bundle.type` | Type of bundle | `apps` | +| `bundle.format` | Archive format | `7z` | + +### gradle.properties + +Gradle-specific configuration: + +```properties +# Gradle daemon configuration +org.gradle.daemon=true +org.gradle.parallel=true +org.gradle.caching=true + +# JVM settings +org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m +``` + +### Directory Structure + +``` +module-phppgadmin/ +├── .gradle-docs/ # Gradle documentation +│ ├── README.md # Main documentation +│ └── TASKS.md # Task reference +├── bin/ # phpPgAdmin version bundles +│ ├── phpPgAdmin7.14.7/ +│ └── ... +├── bearsampp-build/ # External build directory (outside repo) +│ ├── tmp/ # Temporary build files +│ │ ├── bundles_prep/apps/phpPgAdmin/ # Prepared bundles +│ │ ├── bundles_build/apps/phpPgAdmin/ # Build staging +│ │ ├── downloads/phpPgAdmin/ # Downloaded sources +��� │ └── extract/phpPgAdmin/ # Extracted archives +│ └── apps/phpPgAdmin/ # Final packaged archives +│ └── 2025.10.31/ # Release version +│ ├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z +│ ├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.md5 +│ └── ... +├── build.gradle # Main Gradle build script +├── settings.gradle # Gradle settings +├── build.properties # Build configuration +└── releases.properties # Available phpPgAdmin releases +``` + +--- + +## Architecture + +### Build Process Flow + +``` +1. User runs: gradle release -PbundleVersion=7.14.7 + ↓ +2. Validate environment and version + ↓ +3. Download phpPgAdmin source from modules-untouched + ↓ +4. Extract to temporary directory + ↓ +5. Copy configuration files from bin/phpPgAdmin7.14.7/ + ↓ +6. Prepare bundle in tmp/bundles_prep/ + ↓ +7. Copy to tmp/bundles_build/ (non-zip version) + ↓ +8. Package into archive in bearsampp-build/apps/phpPgAdmin/{bundle.release}/ + - The archive includes the top-level folder: phpPgAdmin{version}/ + ↓ +9. Generate hash files (MD5, SHA1, SHA256, SHA512) +``` + +### Packaging Details + +- **Archive name format**: `bearsampp-phpPgAdmin-{version}-{bundle.release}.{7z|zip}` +- **Location**: `bearsampp-build/apps/phpPgAdmin/{bundle.release}/` + - Example: `bearsampp-build/apps/phpPgAdmin/2025.10.31/bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z` +- **Content root**: The top-level folder inside the archive is `phpPgAdmin{version}/` (e.g., `phpPgAdmin7.14.7/`) +- **Structure**: The archive contains the phpPgAdmin version folder at the root with all files inside + +**Archive Structure Example**: +``` +bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z +└── phpPgAdmin7.14.7/ ← Version folder at root + ├── index.php + ├── conf/ + │ └── config.inc.php + ├── classes/ + ├── lang/ + └── ... +``` + +**Verification Commands**: + +```bash +# List archive contents with 7z +7z l bearsampp-build/apps/phpPgAdmin/2025.10.31/bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z | more + +# You should see entries beginning with: +# phpPgAdmin7.14.7/index.php +# phpPgAdmin7.14.7/conf/config.inc.php +# phpPgAdmin7.14.7/... +``` + +**Hash Files**: Each archive is accompanied by hash sidecar files: +- `.md5` - MD5 checksum +- `.sha1` - SHA-1 checksum +- `.sha256` - SHA-256 checksum +- `.sha512` - SHA-512 checksum + +Example: +``` +bearsampp-build/apps/phpPgAdmin/2025.10.31/ +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.md5 +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.sha1 +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.sha256 +└── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.sha512 +``` + +### Version Resolution + +The build system resolves download URLs in the following order: + +1. **modules-untouched** - Remote phpPgAdmin.properties from GitHub +2. **releases.properties** - Local fallback file +3. **Standard URL format** - Constructed URL as last resort + +--- + +## Troubleshooting + +### Common Issues + +#### Issue: "Dev path not found" + +**Symptom:** +``` +Dev path not found: E:/Bearsampp-development/dev +``` + +**Solution:** +This is a warning only. The dev path is optional for most tasks. If you need it, ensure the `dev` project exists in the parent directory. + +--- + +#### Issue: "Bundle version not found" + +**Symptom:** +``` +Bundle version not found in bin/ or bin/archived/ +``` + +**Solution:** +1. List available versions: `gradle listVersions` +2. Use an existing version: `gradle release -PbundleVersion=7.14.7` + +--- + +#### Issue: "7-Zip not found" + +**Symptom:** +``` +7-Zip not found. Please install 7-Zip or set 7Z_HOME environment variable. +``` + +**Solution:** +1. Install 7-Zip from https://www.7-zip.org/ +2. Or set `7Z_HOME` environment variable to your 7-Zip installation directory + +--- + +#### Issue: "Java version too old" + +**Symptom:** +``` +Java 8+ required +``` + +**Solution:** +1. Check Java version: `java -version` +2. Install Java 8 or higher +3. Update JAVA_HOME environment variable + +--- + +### Debug Mode + +Run Gradle with debug output: + +```bash +gradle release -PbundleVersion=7.14.7 --info +gradle release -PbundleVersion=7.14.7 --debug +``` + +### Clean Build + +If you encounter issues, try a clean build: + +```bash +gradle cleanAll +gradle release -PbundleVersion=7.14.7 +``` + +--- + +## Additional Resources + +- [Gradle Documentation](https://docs.gradle.org/) +- [Bearsampp Project](https://github.com/bearsampp/bearsampp) +- [phpPgAdmin Project](http://phppgadmin.sourceforge.net/) + +--- + +## Support + +For issues and questions: + +- **GitHub Issues**: https://github.com/bearsampp/module-phppgadmin/issues +- **Bearsampp Issues**: https://github.com/bearsampp/bearsampp/issues +- **Documentation**: https://bearsampp.com/module/phppgadmin + +--- + +**Last Updated**: 2025-01-31 +**Version**: 2025.10.31 +**Build System**: Pure Gradle (no wrapper, no Ant) + +**Notes**: +- This project deliberately does not ship the Gradle Wrapper. Install Gradle 8+ locally and run with `gradle ...`. +- Legacy Ant files have been removed. The build system is pure Gradle. diff --git a/.gradle-docs/TASKS.md b/.gradle-docs/TASKS.md new file mode 100644 index 0000000..cba94d8 --- /dev/null +++ b/.gradle-docs/TASKS.md @@ -0,0 +1,533 @@ +# Gradle Tasks Reference - phpPgAdmin Module + +Complete reference for all available Gradle tasks in the Bearsampp phpPgAdmin module. + +## Task Groups + +- [Build Tasks](#build-tasks) +- [Verification Tasks](#verification-tasks) +- [Information Tasks](#information-tasks) +- [Cleanup Tasks](#cleanup-tasks) + +--- + +## Build Tasks + +### `release` + +Build and package a release for a specific phpPgAdmin version. + +**Group**: `build` + +**Usage**: +```bash +# Interactive mode (prompts for version selection) +gradle release + +# Non-interactive mode (specify version) +gradle release -PbundleVersion=7.14.7 +``` + +**Parameters**: +- `-PbundleVersion=X.X.X` - Specify the phpPgAdmin version to build + +**Process**: +1. Validates the specified version exists in `bin/` or `bin/archived/` +2. Downloads phpPgAdmin source from modules-untouched +3. Extracts the source to temporary directory +4. Copies configuration files from `bin/phpPgAdmin{version}/` +5. Prepares the bundle in `tmp/bundles_prep/` +6. Creates a non-zip copy in `tmp/bundles_build/` +7. Compresses to archive in `bearsampp-build/apps/phpPgAdmin/{bundle.release}/` +8. Generates hash files (MD5, SHA1, SHA256, SHA512) + +**Output**: +- Archive: `bearsampp-build/apps/phpPgAdmin/{bundle.release}/bearsampp-phpPgAdmin-{version}-{bundle.release}.7z` +- Hash files: `.md5`, `.sha1`, `.sha256`, `.sha512` +- Non-zip copy: `tmp/bundles_build/apps/phpPgAdmin/phpPgAdmin{version}/` + +**Example**: +```bash +gradle release -PbundleVersion=7.14.7 +``` + +--- + +### `releaseAll` + +Build releases for all available phpPgAdmin versions found in the `bin/` directory. + +**Group**: `build` + +**Usage**: +```bash +gradle releaseAll +``` + +**Process**: +1. Scans `bin/` and `bin/archived/` for all phpPgAdmin versions +2. Builds each version sequentially +3. Reports success/failure for each version +4. Provides a summary at the end + +**Output**: +- Multiple archives in `bearsampp-build/apps/phpPgAdmin/{bundle.release}/` +- Build summary with success/failure counts + +**Example**: +```bash +gradle releaseAll +``` + +--- + +## Verification Tasks + +### `verify` + +Verify the build environment and dependencies. + +**Group**: `verification` + +**Usage**: +```bash +gradle verify +``` + +**Checks**: +- Java version (8+) +- `build.properties` file exists +- `bin/` directory exists +- 7-Zip installation (if format is 7z) + +**Output**: +``` +Environment Check Results: +------------------------------------------------------------ + [PASS] Java 8+ + [PASS] build.properties + [PASS] bin directory + [PASS] 7-Zip +------------------------------------------------------------ + +[SUCCESS] All checks passed! Build environment is ready. +``` + +**Example**: +```bash +gradle verify +``` + +--- + +### `validateProperties` + +Validate the `build.properties` configuration file. + +**Group**: `verification` + +**Usage**: +```bash +gradle validateProperties +``` + +**Validates**: +- `bundle.name` - Must be present and non-empty +- `bundle.release` - Must be present and non-empty +- `bundle.type` - Must be present and non-empty +- `bundle.format` - Must be present and non-empty + +**Output**: +``` +[SUCCESS] All required properties are present: + bundle.name = phpPgAdmin + bundle.release = 2025.10.31 + bundle.type = apps + bundle.format = 7z +``` + +**Example**: +```bash +gradle validateProperties +``` + +--- + +### `checkModulesUntouched` + +Check integration with the modules-untouched repository. + +**Group**: `verification` + +**Usage**: +```bash +gradle checkModulesUntouched +``` + +**Process**: +1. Fetches `phpPgAdmin.properties` from modules-untouched GitHub repository +2. Lists all available versions +3. Displays version resolution strategy + +**Output**: +``` +================================================================== +Modules-Untouched Integration Check +================================================================== + +Repository URL: + https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/phpPgAdmin.properties + +Available Versions in modules-untouched +================================================================== + 7.14.7 + ... +================================================================== +Total versions: X + +[SUCCESS] modules-untouched integration is working + +Version Resolution Strategy: + 1. Check modules-untouched phpPgAdmin.properties (remote) + 2. Check releases.properties (local) + 3. Construct standard URL format (fallback) +``` + +**Example**: +```bash +gradle checkModulesUntouched +``` + +--- + +## Information Tasks + +### `info` + +Display comprehensive build configuration information. + +**Group**: `help` + +**Usage**: +```bash +gradle info +``` + +**Output**: +``` +================================================================ + Bearsampp Module phpPgAdmin - Build Info +================================================================ + +Project: module-phppgadmin +Version: 2025.10.31 +Description: Bearsampp Module - phpPgAdmin + +Bundle Properties: + Name: phpPgAdmin + Release: 2025.10.31 + Type: apps + Format: 7z + +Paths: + Project Dir: E:/Bearsampp-development/module-phppgadmin + Root Dir: E:/Bearsampp-development + Dev Path: E:/Bearsampp-development/dev + Build Base: E:/Bearsampp-development/bearsampp-build + +Build Paths: + Tmp: E:/Bearsampp-development/bearsampp-build/tmp + Build: E:/Bearsampp-development/bearsampp-build/tmp/bundles_build/apps/phpPgAdmin + Prep: E:/Bearsampp-development/bearsampp-build/tmp/bundles_prep/apps/phpPgAdmin + Src: E:/Bearsampp-development/bearsampp-build/tmp/bundles_src + Download: E:/Bearsampp-development/bearsampp-build/tmp/downloads/phpPgAdmin + Extract: E:/Bearsampp-development/bearsampp-build/tmp/extract/phpPgAdmin + +Java: + Version: 17 + Home: C:\Program Files\Java\jdk-17 + +Gradle: + Version: 8.12 + Home: C:\Gradle\gradle-8.12 + +Quick Start: + gradle tasks - List all available tasks + gradle info - Show this information + gradle release -PbundleVersion=7.14.7 - Build release for version + gradle releaseAll - Build all versions + gradle clean - Clean build artifacts + gradle verify - Verify build environment +``` + +**Example**: +```bash +gradle info +``` + +--- + +### `listVersions` + +List all available phpPgAdmin versions in the `bin/` and `bin/archived/` directories. + +**Group**: `help` + +**Usage**: +```bash +gradle listVersions +``` + +**Output**: +``` +Available phpPgAdmin versions: +------------------------------------------------------------ + 7.14.7 [bin] + ... +------------------------------------------------------------ +Total versions: X + +To build a specific version: + gradle release -PbundleVersion=7.14.7 +``` + +**Example**: +```bash +gradle listVersions +``` + +--- + +### `listReleases` + +List all available phpPgAdmin releases from the modules-untouched repository. + +**Group**: `help` + +**Usage**: +```bash +gradle listReleases +``` + +**Output**: +``` +Available phpPgAdmin Releases: +-------------------------------------------------------------------------------- + 7.14.7 -> https://github.com/phppgadmin/phppgadmin/archive/refs/tags/REL_7-14-7.zip + ... +-------------------------------------------------------------------------------- +Total releases: X +``` + +**Example**: +```bash +gradle listReleases +``` + +--- + +## Cleanup Tasks + +### `clean` + +Clean build artifacts and temporary files. + +**Group**: `build` + +**Usage**: +```bash +gradle clean +``` + +**Removes**: +- `build/` directory (Gradle build directory) + +**Output**: +``` +[SUCCESS] Build artifacts cleaned +``` + +**Example**: +```bash +gradle clean +``` + +--- + +### `cleanAll` + +Clean all build artifacts, downloads, and temporary files. + +**Group**: `build` + +**Usage**: +```bash +gradle cleanAll +``` + +**Removes**: +- `build/` directory (Gradle build directory) +- `tmp/` directory (downloads, extracts, prep, build) +- Final output directory (`bearsampp-build/apps/phpPgAdmin/`) + +**Output**: +``` +Cleaned: + - Gradle build directory + - Tmp directory (E:/Bearsampp-development/bearsampp-build/tmp) + - Output directory (E:/Bearsampp-development/bearsampp-build/apps/phpPgAdmin) + +[SUCCESS] All build artifacts and temporary files cleaned +``` + +**Example**: +```bash +gradle cleanAll +``` + +--- + +## Task Execution Examples + +### Build a Single Version + +```bash +# Interactive mode +gradle release + +# Non-interactive mode +gradle release -PbundleVersion=7.14.7 +``` + +### Build All Versions + +```bash +gradle releaseAll +``` + +### Verify Environment Before Building + +```bash +gradle verify +gradle release -PbundleVersion=7.14.7 +``` + +### Clean and Rebuild + +```bash +gradle cleanAll +gradle release -PbundleVersion=7.14.7 +``` + +### Check Available Versions + +```bash +# Local versions (in bin/) +gradle listVersions + +# Remote versions (modules-untouched) +gradle listReleases +``` + +### Debug Build Issues + +```bash +# Run with info logging +gradle release -PbundleVersion=7.14.7 --info + +# Run with debug logging +gradle release -PbundleVersion=7.14.7 --debug +``` + +--- + +## Task Dependencies + +``` +release + └── (no dependencies) + +releaseAll + └── (calls release internally for each version) + +clean + └── (no dependencies) + +cleanAll + └── (no dependencies) + +verify + └── (no dependencies) + +validateProperties + └── (no dependencies) + +checkModulesUntouched + └── (no dependencies) + +info + └── (no dependencies) + +listVersions + └── (no dependencies) + +listReleases + └── (no dependencies) +``` + +--- + +## Common Task Combinations + +### Initial Setup + +```bash +gradle verify +gradle listVersions +``` + +### Development Workflow + +```bash +# Build and test a single version +gradle release -PbundleVersion=7.14.7 + +# Clean and rebuild +gradle clean +gradle release -PbundleVersion=7.14.7 +``` + +### Release Workflow + +```bash +# Verify environment +gradle verify + +# Build all versions +gradle releaseAll + +# Verify output +ls bearsampp-build/apps/phpPgAdmin/2025.10.31/ +``` + +### Troubleshooting + +```bash +# Check configuration +gradle info +gradle validateProperties + +# Check modules-untouched integration +gradle checkModulesUntouched + +# Clean everything and start fresh +gradle cleanAll +gradle verify +gradle release -PbundleVersion=7.14.7 --info +``` + +--- + +**Last Updated**: 2025-01-31 +**Version**: 2025.10.31 +**Build System**: Pure Gradle (no wrapper, no Ant) diff --git a/README.md b/README.md index 11040d4..f82e658 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,102 @@ [![GitHub release](https://img.shields.io/github/release/bearsampp/module-phppgadmin.svg?style=flat-square)](https://github.com/bearsampp/module-phppgadmin/releases/latest) ![Total downloads](https://img.shields.io/github/downloads/bearsampp/module-phppgadmin/total.svg?style=flat-square) -This is a module of [Bearsampp project](https://github.com/bearsampp/bearsampp) involving phpPgAdmin. +# Bearsampp Module - phpPgAdmin -## Documentation and downloads +This is a module of [Bearsampp project](https://github.com/bearsampp/bearsampp) involving phpPgAdmin, a web-based administration tool for PostgreSQL. + +## Build System + +This module uses a **pure Gradle build system** (no wrapper, no Ant) for building and packaging phpPgAdmin releases. + +### Prerequisites + +| Requirement | Version | Purpose | +|-------------------|---------------|------------------------------------------| +| **Java** | 8+ | Required for Gradle execution | +| **Gradle** | 8.0+ | Build automation tool | +| **7-Zip** | Latest | Archive compression | + +### Quick Start + +```bash +# Display build information +gradle info + +# List all available tasks +gradle tasks + +# Verify build environment +gradle verify + +# Build a release (interactive) +gradle release + +# Build a specific version (non-interactive) +gradle release -PbundleVersion=7.14.7 + +# Build all versions +gradle releaseAll + +# Clean build artifacts +gradle clean +``` + +### Available Tasks + +| Task | Description | +|---------------------------|--------------------------------------------------| +| `release` | Build release package (interactive/non-interactive) | +| `releaseAll` | Build all available versions | +| `clean` | Clean build artifacts | +| `cleanAll` | Clean all including downloads | +| `info` | Display build configuration | +| `verify` | Verify build environment | +| `listVersions` | List available bundle versions | +| `listReleases` | List all available releases | +| `validateProperties` | Validate build.properties | +| `checkModulesUntouched` | Check modules-untouched integration | + +### Configuration + +The build is configured through `build.properties`: + +```properties +bundle.name = phpPgAdmin +bundle.release = 2025.10.31 +bundle.type = apps +bundle.format = 7z +``` + +### Build Output + +Archives are created in: `bearsampp-build/apps/phpPgAdmin/{bundle.release}/` + +Example: +``` +bearsampp-build/apps/phpPgAdmin/2025.10.31/ +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.md5 +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.sha1 +├── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.sha256 +└── bearsampp-phpPgAdmin-7.14.7-2025.10.31.7z.sha512 +``` + +## Documentation + +Complete build documentation is available in [.gradle-docs/](.gradle-docs/): + +- [README.md](.gradle-docs/README.md) - Main documentation +- [TASKS.md](.gradle-docs/TASKS.md) - Task reference + +## Module Information https://bearsampp.com/module/phppgadmin ## Issues Issues must be reported on [Bearsampp repository](https://github.com/bearsampp/bearsampp/issues). + +## License + +This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details. diff --git a/bin/phppgadmin7.13.0/bearsampp.conf b/bin/archived/phppgadmin7.13.0/bearsampp.conf similarity index 96% rename from bin/phppgadmin7.13.0/bearsampp.conf rename to bin/archived/phppgadmin7.13.0/bearsampp.conf index fcc0a07..34d487e 100644 --- a/bin/phppgadmin7.13.0/bearsampp.conf +++ b/bin/archived/phppgadmin7.13.0/bearsampp.conf @@ -1,4 +1,4 @@ -phppgadminVersion = "7.13.0" -phppgadminConf = "conf/config.inc.php" - -bundleRelease = "@RELEASE_VERSION@" +phppgadminVersion = "7.13.0" +phppgadminConf = "conf/config.inc.php" + +bundleRelease = "@RELEASE_VERSION@" diff --git a/bin/phppgadmin7.13.0/conf/config.inc.php b/bin/archived/phppgadmin7.13.0/conf/config.inc.php similarity index 100% rename from bin/phppgadmin7.13.0/conf/config.inc.php rename to bin/archived/phppgadmin7.13.0/conf/config.inc.php diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ff84d19 --- /dev/null +++ b/build.gradle @@ -0,0 +1,978 @@ +/* + * Bearsampp Module phpPgAdmin - Gradle Build + * + * Pure Gradle implementation for building phpPgAdmin module releases. + * + * DOCUMENTATION: + * All build documentation is located in /.gradle-docs/ + * See /.gradle-docs/README.md for complete documentation index + * + * Usage: + * gradle tasks - List all available tasks + * gradle release - Build release (interactive mode) + * gradle release -PbundleVersion=5.2.1 - Build release for specific version + * gradle releaseAll - Build all available versions + * gradle clean - Clean build artifacts + * gradle cleanAll - Clean all including downloads + * gradle info - Display build information + * gradle verify - Verify build environment + */ + +plugins { + id 'base' +} + +// Load build properties +def buildProps = new Properties() +file('build.properties').withInputStream { buildProps.load(it) } + +// Project information +group = 'com.bearsampp.modules' +version = buildProps.getProperty('bundle.release', '1.0.0') +description = "Bearsampp Module - ${buildProps.getProperty('bundle.name', 'phpPgAdmin')}" + +// Define project paths +ext { + projectBasedir = projectDir.absolutePath + rootDir = projectDir.parent + devPath = file("${rootDir}/dev").absolutePath + + // Bundle properties from build.properties + bundleName = buildProps.getProperty('bundle.name', 'phpPgAdmin') + bundleRelease = buildProps.getProperty('bundle.release', '1.0.0') + bundleType = buildProps.getProperty('bundle.type', 'apps') + bundleFormat = buildProps.getProperty('bundle.format', '7z') + + // Build paths - with configurable base path + // Priority: 1) build.properties, 2) Environment variable, 3) Default + def buildPathFromProps = buildProps.getProperty('build.path', '').trim() + def buildPathFromEnv = System.getenv('BEARSAMPP_BUILD_PATH') ?: '' + def defaultBuildPath = "${rootDir}/bearsampp-build" + + buildBasePath = buildPathFromProps ?: (buildPathFromEnv ?: defaultBuildPath) + + // Use shared bearsampp-build/tmp directory structure (same as Ant builds) + buildTmpPath = file("${buildBasePath}/tmp").absolutePath + bundleTmpBuildPath = file("${buildTmpPath}/bundles_build/${bundleType}/${bundleName}").absolutePath + bundleTmpPrepPath = file("${buildTmpPath}/bundles_prep/${bundleType}/${bundleName}").absolutePath + bundleTmpSrcPath = file("${buildTmpPath}/bundles_src").absolutePath + + // Download and extract paths - use bearsampp-build/tmp instead of local build/ + bundleTmpDownloadPath = file("${buildTmpPath}/downloads/${bundleName}").absolutePath + bundleTmpExtractPath = file("${buildTmpPath}/extract/${bundleName}").absolutePath +} + +// Verify dev path exists +if (!file(ext.devPath).exists()) { + logger.warn("Dev path not found: ${ext.devPath}. Some features may not be available.") +} + +// Configure repositories for dependencies +repositories { + mavenCentral() +} + +// ============================================================================ +// HELPER FUNCTIONS +// ============================================================================ + +// Helper function to fetch modules-untouched properties +def fetchModulesUntouchedProperties() { + def propsUrl = "https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/phpPgAdmin.properties" + + try { + def connection = new URL(propsUrl).openConnection() + connection.setRequestProperty("User-Agent", "Bearsampp-Gradle-Build") + connection.setConnectTimeout(10000) + connection.setReadTimeout(10000) + + def props = new Properties() + connection.inputStream.withCloseable { stream -> + props.load(stream) + } + return props + } catch (Exception e) { + logger.warn("Could not fetch modules-untouched properties: ${e.message}") + return null + } +} + +// Helper function to resolve download URL for a version +def resolveDownloadUrl(String version) { + // First try modules-untouched + def untouchedProps = fetchModulesUntouchedProperties() + if (untouchedProps && untouchedProps.containsKey(version)) { + return untouchedProps.getProperty(version) + } + + // Fallback to releases.properties + def releasesFile = file('releases.properties') + if (releasesFile.exists()) { + def releases = new Properties() + releasesFile.withInputStream { releases.load(it) } + if (releases.containsKey(version)) { + return releases.getProperty(version) + } + } + + // Fallback to standard URL format + return "https://files.phpPgAdmin.net/phpPgAdmin/${version}/phpPgAdmin-${version}-zip" +} + +// Helper function to download and extract phpPgAdmin +def downloadAndExtractphpPgAdmin(String version, File destDir, String tmpPath) { + def downloadUrl = resolveDownloadUrl(version) + println "Download URL: ${downloadUrl}" + + def fileName = downloadUrl.substring(downloadUrl.lastIndexOf('/') + 1) + def downloadFile = file("${bundleTmpDownloadPath}/${fileName}") + + // Create temp directory + downloadFile.parentFile.mkdirs() + + // Download if not already present + if (!downloadFile.exists()) { + println "Downloading phpPgAdmin ${version}..." + def connection = new URL(downloadUrl).openConnection() + connection.setRequestProperty("User-Agent", "Bearsampp-Gradle-Build") + + downloadFile.withOutputStream { out -> + connection.inputStream.withCloseable { input -> + out << input + } + } + println "Downloaded: ${downloadFile.name}" + } else { + println "Using cached download: ${downloadFile.name}" + } + + // Extract archive + println "Extracting phpPgAdmin ${version}..." + def sevenZip = find7ZipExecutable() + if (!sevenZip) { + throw new GradleException("7-Zip not found. Please install 7-Zip or set 7Z_HOME environment variable.") + } + + def extractDir = file("${bundleTmpExtractPath}/${version}") + if (extractDir.exists()) { + delete extractDir + } + extractDir.mkdirs() + + def extractCmd = [sevenZip, 'x', downloadFile.absolutePath, "-o${extractDir.absolutePath}", '-y'] + def extractProcess = extractCmd.execute() + extractProcess.consumeProcessOutput(System.out, System.err) + def extractExitCode = extractProcess.waitFor() + + if (extractExitCode != 0) { + throw new GradleException("Failed to extract phpPgAdmin archive") + } + + // Find the extracted directory (should be phpPgAdmin-X.X.X-all-languages) + def extractedDirs = extractDir.listFiles().findAll { it.isDirectory() } + if (extractedDirs.isEmpty()) { + throw new GradleException("No directory found after extraction") + } + + def sourceDir = extractedDirs[0] + println "Extracted to: ${sourceDir.name}" + + // Copy to destination + copy { + from sourceDir + into destDir + exclude 'config.sample.inc.php' + } + + println "phpPgAdmin ${version} prepared successfully" +} + +// ============================================================================ +// GRADLE TASKS +// ============================================================================ + +// Task: Display build information +tasks.register('info') { + group = 'help' + description = 'Display build configuration information' + + doLast { + def projectName = project.name + def projectVersion = project.version + def projectDescription = project.description + def projectBasedirValue = projectBasedir + def rootDirValue = rootDir + def devPathValue = devPath + def bundleNameValue = bundleName + def bundleReleaseValue = bundleRelease + def bundleTypeValue = bundleType + def bundleFormatValue = bundleFormat + def buildBasePathValue = buildBasePath + def buildTmpPathValue = buildTmpPath + def bundleTmpBuildPathValue = bundleTmpBuildPath + def bundleTmpPrepPathValue = bundleTmpPrepPath + def bundleTmpSrcPathValue = bundleTmpSrcPath + def bundleTmpDownloadPathValue = bundleTmpDownloadPath + def bundleTmpExtractPathValue = bundleTmpExtractPath + + println """ + ================================================================ + Bearsampp Module phpPgAdmin - Build Info + ================================================================ + + Project: ${projectName} + Version: ${projectVersion} + Description: ${projectDescription} + + Bundle Properties: + Name: ${bundleNameValue} + Release: ${bundleReleaseValue} + Type: ${bundleTypeValue} + Format: ${bundleFormatValue} + + Paths: + Project Dir: ${projectBasedirValue} + Root Dir: ${rootDirValue} + Dev Path: ${devPathValue} + Build Base: ${buildBasePathValue} + + Build Paths: + Tmp: ${buildTmpPathValue} + Build: ${bundleTmpBuildPathValue} + Prep: ${bundleTmpPrepPathValue} + Src: ${bundleTmpSrcPathValue} + Download: ${bundleTmpDownloadPathValue} + Extract: ${bundleTmpExtractPathValue} + + Java: + Version: ${JavaVersion.current()} + Home: ${System.getProperty('java.home')} + + Gradle: + Version: ${gradle.gradleVersion} + Home: ${gradle.gradleHomeDir} + + Available Task Groups: + * build - Build and package tasks + * help - Help and information tasks + * verification - Verification tasks + + Quick Start: + gradle tasks - List all available tasks + gradle info - Show this information + gradle release -PbundleVersion=5.2.1 - Build release for version + gradle releaseAll - Build all versions + gradle clean - Clean build artifacts + gradle verify - Verify build environment + """.stripIndent() + } +} + +// Task: Main release task +tasks.register('release') { + group = 'build' + description = 'Build release package for a specific version (use -PbundleVersion=X.X.X or run interactively)' + + // Capture property at configuration time to avoid deprecation warning + def versionProperty = findProperty('bundleVersion') + + doLast { + def versionToBuild = versionProperty + + if (!versionToBuild) { + // Interactive mode - prompt for version + def availableVersions = getAvailableVersions() + + if (availableVersions.isEmpty()) { + throw new GradleException("No versions found in bin/ directory") + } + + println "" + println "=".multiply(70) + println "Interactive Release Mode" + println "=".multiply(70) + println "" + println "Available versions:" + + // Show versions with location tags + def binDir = file("${projectDir}/bin") + def archivedDir = file("${projectDir}/bin/archived") + + availableVersions.eachWithIndex { version, index -> + def location = "" + if (binDir.exists() && file("${binDir}/${bundleName}${version}").exists()) { + location = "[bin]" + } else if (archivedDir.exists() && file("${archivedDir}/${bundleName}${version}").exists()) { + location = "[bin/archived]" + } + println " ${(index + 1).toString().padLeft(2)}. ${version.padRight(15)} ${location}" + } + println "" + println "Enter version to build (index or version string):" + println "" + + // Read input using Gradle's standard input + def input = null + try { + def reader = new BufferedReader(new InputStreamReader(System.in)) + input = reader.readLine() + } catch (Exception e) { + throw new GradleException(""" + Failed to read input. Please use non-interactive mode: + gradle release -PbundleVersion=X.X.X + + Available versions: ${availableVersions.join(', ')} + """.stripIndent()) + } + + if (!input || input.trim().isEmpty()) { + throw new GradleException(""" + No version selected. Please use non-interactive mode: + gradle release -PbundleVersion=X.X.X + + Available versions: ${availableVersions.join(', ')} + """.stripIndent()) + } + + def cleaned = input.trim() + + // Accept either an index (1..N) or an explicit version string + if (cleaned.isInteger()) { + def idx = cleaned.toInteger() + if (idx < 1 || idx > availableVersions.size()) { + throw new GradleException(""" + Invalid selection index: ${cleaned} + + Please choose a number between 1 and ${availableVersions.size()} or enter a version string. + """.stripIndent()) + } + versionToBuild = availableVersions[idx - 1] + } else { + versionToBuild = cleaned + // Validate the entered version string exists + if (!availableVersions.contains(versionToBuild)) { + throw new GradleException(""" + Invalid version: ${versionToBuild} + + Please choose from available versions: + ${availableVersions.collect { " - ${it}" }.join('\n')} + """.stripIndent()) + } + } + + println "" + println "Selected version: ${versionToBuild}" + } + + println "" + println "=".multiply(70) + println "Building release for ${bundleName} version ${versionToBuild}" + println "=".multiply(70) + println "" + + // Check if version folder exists - check both bin and bin/archived directories + def bundlePath = file("${projectDir}/bin/${bundleName}${versionToBuild}") + if (!bundlePath.exists()) { + bundlePath = file("${projectDir}/bin/archived/${bundleName}${versionToBuild}") + if (!bundlePath.exists()) { + def availableVersions = getAvailableVersions() + def versionList = availableVersions.isEmpty() ? " (none found)" : availableVersions.collect { " - ${it}" }.join('\n') + + throw new GradleException("Bundle version not found in bin/ or bin/archived/\n\nAvailable versions:\n${versionList}") + } + } + + println "Bundle path: ${bundlePath}" + println "" + + // Get the bundle folder and version + def bundleFolder = bundlePath.name + def bundleVersion = bundleFolder.replace(bundleName, '') + + // Prepare output directory + def phpPgAdminPrepPath = file("${bundleTmpPrepPath}/${bundleName}${bundleVersion}") + if (phpPgAdminPrepPath.exists()) { + delete phpPgAdminPrepPath + } + phpPgAdminPrepPath.mkdirs() + + // Download and extract phpPgAdmin + println "Downloading and extracting phpPgAdmin ${bundleVersion}..." + downloadAndExtractphpPgAdmin(bundleVersion, phpPgAdminPrepPath, buildTmpPath) + println "" + + // Copy configuration files from bin folder + println "Copying configuration files..." + copy { + from bundlePath + into phpPgAdminPrepPath + } + println "" + + // Copy to bundles_build directory (non-zip version for development/testing) + println "Copying to bundles_build directory..." + def phpPgAdminBuildPath = file("${bundleTmpBuildPath}/${bundleName}${bundleVersion}") + if (phpPgAdminBuildPath.exists()) { + delete phpPgAdminBuildPath + } + phpPgAdminBuildPath.mkdirs() + + copy { + from phpPgAdminPrepPath + into phpPgAdminBuildPath + } + println "Non-zip version available at: ${phpPgAdminBuildPath}" + + println "" + println "Preparing archive..." + + // Determine build output path following Apache pattern + // bearsampp-build/apps/phpPgAdmin/{bundleRelease} for apps + def buildPath = file(buildBasePath) + def buildBinsPath = file("${buildPath}/${bundleType}/${bundleName}/${bundleRelease}") + buildBinsPath.mkdirs() + + // Build archive filename + def destFile = file("${buildBinsPath}/bearsampp-${bundleName}-${bundleVersion}-${bundleRelease}") + def archiveFile = file("${destFile}.${bundleFormat}") + + if (archiveFile.exists()) { + delete archiveFile + } + + println "Compressing ${bundleName}${bundleVersion} to ${archiveFile.name}..." + + def sevenZip = find7ZipExecutable() + if (!sevenZip) { + throw new GradleException("7-Zip not found. Please install 7-Zip or set 7Z_HOME environment variable.") + } + + println "Using 7-Zip: ${sevenZip}" + + // Create archive with version folder included + // Run 7z from the parent directory and add the folder name, so the + // archive root contains `${bundleName}${bundleVersion}` directory. + def folderName = phpPgAdminPrepPath.name + def command = [ + sevenZip, + 'a', + '-t7z', + archiveFile.absolutePath.toString(), + folderName + ] + + def process = new ProcessBuilder(command as String[]) + .directory(file(bundleTmpPrepPath)) + .redirectErrorStream(true) + .start() + + process.inputStream.eachLine { line -> + if (line.trim()) println " ${line}" + } + + def exitCode = process.waitFor() + if (exitCode != 0) { + throw new GradleException("7zip compression failed with exit code: ${exitCode}") + } + + println "Archive created: ${archiveFile}" + + // Generate hash files + println "Generating hash files..." + generateHashFiles(archiveFile) + + println "" + println "=".multiply(70) + println "[SUCCESS] Release build completed successfully for version ${versionToBuild}" + println "Output directory: ${phpPgAdminBuildPath}" + println "Archive: ${archiveFile}" + println "=".multiply(70) + } +} + +// Helper function to find 7-Zip executable +def find7ZipExecutable() { + // Check environment variable + def sevenZipHome = System.getenv('7Z_HOME') + if (sevenZipHome) { + def exe = file("${sevenZipHome}/7z.exe") + if (exe.exists()) { + return exe.absolutePath + } + } + + // Check common installation paths + def commonPaths = [ + 'C:/Program Files/7-Zip/7z.exe', + 'C:/Program Files (x86)/7-Zip/7z.exe', + 'D:/Program Files/7-Zip/7z.exe', + 'D:/Program Files (x86)/7-Zip/7z.exe' + ] + + for (path in commonPaths) { + def exe = file(path) + if (exe.exists()) { + return exe.absolutePath + } + } + + // Try to find in PATH + try { + def process = ['where', '7z.exe'].execute() + process.waitFor() + if (process.exitValue() == 0) { + def output = process.text.trim() + if (output) { + return output.split('\n')[0].trim() + } + } + } catch (Exception e) { + // Ignore + } + + return null +} + +// Helper function to generate hash files +def generateHashFiles(File file) { + if (!file.exists()) { + throw new GradleException("File not found for hashing: ${file}") + } + + // Generate MD5 + def md5File = new File("${file.absolutePath}.md5") + def md5Hash = calculateHash(file, 'MD5') + md5File.text = "${md5Hash} ${file.name}\n" + println " Created: ${md5File.name}" + + // Generate SHA1 + def sha1File = new File("${file.absolutePath}.sha1") + def sha1Hash = calculateHash(file, 'SHA-1') + sha1File.text = "${sha1Hash} ${file.name}\n" + println " Created: ${sha1File.name}" + + // Generate SHA256 + def sha256File = new File("${file.absolutePath}.sha256") + def sha256Hash = calculateHash(file, 'SHA-256') + sha256File.text = "${sha256Hash} ${file.name}\n" + println " Created: ${sha256File.name}" + + // Generate SHA512 + def sha512File = new File("${file.absolutePath}.sha512") + def sha512Hash = calculateHash(file, 'SHA-512') + sha512File.text = "${sha512Hash} ${file.name}\n" + println " Created: ${sha512File.name}" +} + +// Helper function to calculate hash +def calculateHash(File file, String algorithm) { + def digest = java.security.MessageDigest.getInstance(algorithm) + file.withInputStream { stream -> + def buffer = new byte[8192] + def bytesRead + while ((bytesRead = stream.read(buffer)) != -1) { + digest.update(buffer, 0, bytesRead) + } + } + return digest.digest().collect { String.format('%02x', it) }.join('') +} + +// Helper function to get available versions +def getAvailableVersions() { + def versions = [] + + // Check bin directory + def binDir = file("${projectDir}/bin") + if (binDir.exists()) { + def binVersions = binDir.listFiles() + ?.findAll { it.isDirectory() && it.name.startsWith(bundleName) && it.name != 'archived' } + ?.collect { it.name.replace(bundleName, '') } ?: [] + versions.addAll(binVersions) + } + + // Check bin/archived subdirectory + def archivedDir = file("${projectDir}/bin/archived") + if (archivedDir.exists()) { + def archivedVersions = archivedDir.listFiles() + ?.findAll { it.isDirectory() && it.name.startsWith(bundleName) } + ?.collect { it.name.replace(bundleName, '') } ?: [] + versions.addAll(archivedVersions) + } + + // Remove duplicates and sort + return versions.unique().sort() +} + +// Task: Build all available versions +tasks.register('releaseAll') { + group = 'build' + description = 'Build release packages for all available versions in bin/ directory' + + doLast { + def versions = getAvailableVersions() + + if (versions.isEmpty()) { + throw new GradleException("No versions found in bin/ directory") + } + + println "" + println "=".multiply(70) + println "Building releases for ${versions.size()} ${bundleName} versions" + println "=".multiply(70) + println "" + + def successCount = 0 + def failedVersions = [] + + versions.each { version -> + println "=".multiply(70) + println "[${successCount + 1}/${versions.size()}] Building ${bundleName} ${version}..." + println "=".multiply(70) + + try { + // Call release task for this version + project.ext.bundleVersion = version + tasks.getByName('release').actions.each { action -> + action.execute(tasks.getByName('release')) + } + + println "" + println "[SUCCESS] ${bundleName} ${version} completed" + successCount++ + + } catch (Exception e) { + println "" + println "[FAILED] ${bundleName} ${version}: ${e.message}" + failedVersions.add(version) + } + + println "" + } + + // Summary + println "=".multiply(70) + println "Build Summary" + println "=".multiply(70) + println "Total versions: ${versions.size()}" + println "Successful: ${successCount}" + println "Failed: ${failedVersions.size()}" + + if (!failedVersions.isEmpty()) { + println "" + println "Failed versions:" + failedVersions.each { v -> + println " - ${v}" + } + } + + println "=".multiply(70) + + if (failedVersions.isEmpty()) { + println "[SUCCESS] All versions built successfully!" + } else { + throw new GradleException("${failedVersions.size()} version(s) failed to build") + } + } +} + +// Task: Enhanced clean task +tasks.named('clean') { + group = 'build' + description = 'Clean build artifacts and temporary files' + + doLast { + // Clean Gradle build directory + def buildDir = file("${projectDir}/build") + if (buildDir.exists()) { + delete buildDir + } + + println "[SUCCESS] Build artifacts cleaned" + } +} + +// Task: Clean all including downloads and tmp files +tasks.register('cleanAll') { + group = 'build' + description = 'Clean all build artifacts, downloads, and temporary files' + + doLast { + println "Cleaning all build artifacts and temporary files..." + + def itemsToClean = [] + + // Clean Gradle build directory + def buildDir = file("${projectDir}/build") + if (buildDir.exists()) { + itemsToClean.add("Gradle build directory") + delete buildDir + } + + // Clean tmp directory (downloads, extracts, prep, build) + def tmpDir = file(buildTmpPath) + if (tmpDir.exists()) { + itemsToClean.add("Tmp directory (${tmpDir})") + delete tmpDir + } + + // Clean final output directory + def outputDir = file("${buildBasePath}/${bundleType}/${bundleName}") + if (outputDir.exists()) { + itemsToClean.add("Output directory (${outputDir})") + delete outputDir + } + + if (itemsToClean.isEmpty()) { + println " Nothing to clean - all directories already clean" + } else { + println " Cleaned:" + itemsToClean.each { item -> + println " - ${item}" + } + } + + println "" + println "[SUCCESS] All build artifacts and temporary files cleaned" + } +} + +// Task: Verify build environment +tasks.register('verify') { + group = 'verification' + description = 'Verify build environment and dependencies' + + doLast { + println "Verifying build environment for module-phpPgAdmin..." + + def checks = [:] + + // Check Java version + def javaVersion = JavaVersion.current() + checks['Java 8+'] = javaVersion >= JavaVersion.VERSION_1_8 + + // Check required files + checks['build.properties'] = file('build.properties').exists() + + // Check bin directory + checks['bin directory'] = file("${projectDir}/bin").exists() + + // Check 7-Zip if format is 7z + if (bundleFormat == '7z') { + checks['7-Zip'] = find7ZipExecutable() != null + } + + println "\nEnvironment Check Results:" + println "-".multiply(60) + checks.each { name, passed -> + def status = passed ? "[PASS]" : "[FAIL]" + println " ${status.padRight(10)} ${name}" + } + println "-".multiply(60) + + def allPassed = checks.values().every { it } + if (allPassed) { + println "\n[SUCCESS] All checks passed! Build environment is ready." + println "\nYou can now run:" + println " gradle release -PbundleVersion=5.2.1 - Build release for version" + println " gradle listVersions - List available versions" + } else { + println "\n[WARNING] Some checks failed. Please review the requirements." + throw new GradleException("Build environment verification failed") + } + } +} + +// Task: List all bundle versions from modules-untouched phpPgAdmin.properties +tasks.register('listReleases') { + group = 'help' + description = 'List all available releases from modules-untouched phpPgAdmin.properties' + + doLast { + def props = fetchModulesUntouchedProperties() + if (!props) { + println "\n[WARNING] Could not fetch modules-untouched phpPgAdmin.properties." + println "Checking releases.properties instead..." + + def releasesFile = file('releases.properties') + if (releasesFile.exists()) { + props = new Properties() + releasesFile.withInputStream { props.load(it) } + } else { + println "No release information available." + return + } + } + + println "\nAvailable phpPgAdmin Releases:" + println "-".multiply(80) + props.sort { a, b -> a.key <=> b.key }.each { version, url -> + println " ${version.padRight(10)} -> ${url}" + } + println "-".multiply(80) + println "Total releases: ${props.size()}" + } +} + +// Task: List available bundle versions in bin and bin/archived directories +tasks.register('listVersions') { + group = 'help' + description = 'List all available bundle versions in bin/ and bin/archived/ directories' + + doLast { + def versions = getAvailableVersions() + + if (versions.isEmpty()) { + println "\nNo versions found in bin/ or bin/archived/ directories" + return + } + + println "\nAvailable ${bundleName} versions:" + println "-".multiply(60) + + // Show which directory each version is in + def binDir = file("${projectDir}/bin") + def archivedDir = file("${projectDir}/bin/archived") + + versions.each { version -> + def location = "" + if (binDir.exists() && file("${binDir}/${bundleName}${version}").exists()) { + location = "[bin]" + } else if (archivedDir.exists() && file("${archivedDir}/${bundleName}${version}").exists()) { + location = "[bin/archived]" + } + println " ${version.padRight(15)} ${location}" + } + println "-".multiply(60) + println "Total versions: ${versions.size()}" + + if (!versions.isEmpty()) { + println "\nTo build a specific version:" + println " gradle release -PbundleVersion=${versions.last()}" + } + } +} + +// Task: Validate build.properties +tasks.register('validateProperties') { + group = 'verification' + description = 'Validate build.properties configuration' + + doLast { + println "Validating build.properties..." + + def required = ['bundle.name', 'bundle.release', 'bundle.type', 'bundle.format'] + def missing = [] + + required.each { prop -> + if (!buildProps.containsKey(prop) || buildProps.getProperty(prop).trim().isEmpty()) { + missing.add(prop) + } + } + + if (missing.isEmpty()) { + println "[SUCCESS] All required properties are present:" + required.each { prop -> + println " ${prop} = ${buildProps.getProperty(prop)}" + } + } else { + println "[ERROR] Missing required properties:" + missing.each { prop -> + println " - ${prop}" + } + throw new GradleException("build.properties validation failed") + } + } +} + +// Task: Check modules-untouched integration +tasks.register('checkModulesUntouched') { + group = 'verification' + description = 'Check modules-untouched repository integration and available versions' + + doLast { + println "" + println "=".multiply(70) + println "Modules-Untouched Integration Check" + println "=".multiply(70) + println "" + + def propsUrl = "https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/phpPgAdmin.properties" + println "Repository URL:" + println " ${propsUrl}" + println "" + + println "Fetching phpPgAdmin.properties from modules-untouched..." + def untouchedProps = fetchModulesUntouchedProperties() + + if (untouchedProps) { + println "" + println "=".multiply(70) + println "Available Versions in modules-untouched" + println "=".multiply(70) + + def sortedVersions = untouchedProps.sort { a, b -> + // Simple version comparison + def aParts = a.key.tokenize('.') + def bParts = b.key.tokenize('.') + for (int i = 0; i < Math.min(aParts.size(), bParts.size()); i++) { + def aNum = aParts[i].toInteger() + def bNum = bParts[i].toInteger() + if (aNum != bNum) return aNum <=> bNum + } + return aParts.size() <=> bParts.size() + } + + sortedVersions.each { version, url -> + println " ${version.padRight(10)}" + } + + println "=".multiply(70) + println "Total versions: ${untouchedProps.size()}" + println "" + + println "" + println "=".multiply(70) + println "[SUCCESS] modules-untouched integration is working" + println "=".multiply(70) + println "" + println "Version Resolution Strategy:" + println " 1. Check modules-untouched phpPgAdmin.properties (remote)" + println " 2. Check releases.properties (local)" + println " 3. Construct standard URL format (fallback)" + + } else { + println "" + println "=".multiply(70) + println "[WARNING] Could not fetch phpPgAdmin.properties from modules-untouched" + println "=".multiply(70) + println "" + println "This may be due to:" + println " - Network connectivity issues" + println " - Repository access problems" + println " - File not available at expected location" + println "" + println "The build system will fall back to:" + println " 1. releases.properties (local)" + println " 2. Standard URL format construction" + } + } +} + +// ============================================================================ +// BUILD LIFECYCLE HOOKS +// ============================================================================ + +gradle.taskGraph.whenReady { graph -> + println """ + ================================================================ + Bearsampp Module phpPgAdmin - Gradle Build + ================================================================ + """.stripIndent() +} + +// ============================================================================ +// DEFAULT TASK +// ============================================================================ + +defaultTasks 'info' + diff --git a/build.xml b/build.xml deleted file mode 100644 index 312eaa7..0000000 --- a/build.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..495f74a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,19 @@ +# Gradle Build Properties for Bearsampp Module phpPgAdmin + +# Gradle daemon configuration +org.gradle.daemon=true +org.gradle.parallel=true +org.gradle.caching=true + +# JVM settings for Gradle +org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError + +# Configure console output +org.gradle.console=auto +org.gradle.warning.mode=all + +# Build performance +org.gradle.configureondemand=false + +# Gradle version compatibility +# This project is compatible with Gradle 7.0+ diff --git a/module-phppgadmin.RELEASE.launch b/module-phppgadmin.RELEASE.launch deleted file mode 100644 index b3d4d72..0000000 --- a/module-phppgadmin.RELEASE.launch +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..7913743 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,25 @@ +/* + * Bearsampp Module phpPgAdmin - Gradle Settings + */ + +rootProject.name = 'module-phppgadmin' + +// Enable Gradle features for better performance +enableFeaturePreview('STABLE_CONFIGURATION_CACHE') + +// Configure build cache for faster builds +buildCache { + local { + enabled = true + directory = file("${rootDir}/.gradle/build-cache") + } +} + +// Display initialization message +gradle.rootProject { + println """ + ================================================================ + Initializing Bearsampp Module phpPgAdmin Build + ================================================================ + """.stripIndent() +}