diff --git a/.gitignore b/.gitignore index 207bc8a7..6182c491 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,10 @@ # ignore "current" directories /**/current +# Gradle +.gradle/ +build/ +.gradle-cache/ + # Qodo /.qodo diff --git a/.gradle-docs/CHANGELOG.md b/.gradle-docs/CHANGELOG.md new file mode 100644 index 00000000..fb432a7d --- /dev/null +++ b/.gradle-docs/CHANGELOG.md @@ -0,0 +1,157 @@ +# Gradle Build Changelog + +## 2025-01-XX - Removal of releases.properties + +### Removed + +| Component | Reason | +|----------------------------------|------------------------------------------------------------------------------| +| `releases.properties` | Replaced by centralized modules-untouched apache.properties | + +### Changed + +| Component | Change | +|----------------------------------|------------------------------------------------------------------------------| +| Version Resolution | Now uses only remote apache.properties (no local fallback) | +| `fetchModulesUntouchedProperties()` | Primary version source (was secondary) | +| `downloadFromModulesUntouched()` | Enhanced to check remote properties first | +| `listReleases` task | Now fetches from modules-untouched instead of local file | +| Documentation | Updated to reflect removal of releases.properties | + +### Version Resolution Strategy (Updated) + +| Priority | Source | Description | +|----------|-------------------------------------------|----------------------------------------------| +| 1 | Remote `apache.properties` | Fetch from modules-untouched (PRIMARY) | +| 2 | Direct repository download | Download from `apache{version}/` directory | + +**Note:** Local `releases.properties` is no longer used. + +### Benefits + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Centralized Management | Single source of truth for all Apache versions | +| No Local Maintenance | No need to maintain local releases.properties file | +| Consistency | Matches module-bruno and other Bearsampp modules | +| Always Current | Automatically uses latest version information | +| Simplified Workflow | One less file to maintain and keep in sync | + +### Migration Notes + +- **No action required** for existing builds +- Version information now fetched dynamically from modules-untouched +- All previously available versions remain accessible +- New versions automatically available when added to remote apache.properties + +### Files Modified + +| File/Directory | Action | Description | +|----------------------------------|---------|--------------------------------------------------------------| +| `releases.properties` | Deleted | No longer needed | +| `build.gradle` | Updated | Removed references to releases.properties | +| `/.gradle-docs/REMOTE_PROPERTIES_SUPPORT.md` | Updated | Reflects removal of releases.properties | +| `/.gradle-docs/CHANGELOG.md` | Updated | This changelog entry | + +### Testing + +| Test | Status | Description | +|----------------------------------|--------|--------------------------------------------------------------| +| Build with remote version | ✅ | Successfully fetches from modules-untouched | +| Build without network | ✅ | Shows appropriate error message | +| `listReleases` task | ✅ | Displays versions from remote apache.properties | +| `checkModulesUntouched` task | ✅ | Verifies integration with modules-untouched | + +--- + +## 2024-11-12 - Remote Properties Support & Documentation Organization + +### Added + +| Feature | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Remote apache.properties Support | Fetches version info from modules-untouched repository | +| `loadRemoteApacheProperties()` | New function to load and parse remote properties file | +| Documentation Directory | Created `/.gradle-docs` for all Gradle documentation | +| REMOTE_PROPERTIES_SUPPORT.md | Comprehensive guide for remote properties feature | + +### Changed + +| Component | Change | +|----------------------------------|------------------------------------------------------------------------------| +| Version Resolution | Updated `downloadAndExtractApache()` to check remote properties | +| Error Messages | Enhanced to include all three version resolution options | +| Documentation Location | Moved all Gradle docs to `/.gradle-docs/` | + +### Version Resolution Priority + +| Priority | Source | Description | +|----------|-------------------------------------------|----------------------------------------------| +| 1 | Local `releases.properties` | Check local file first | +| 2 | Remote `apache.properties` | Fetch from modules-untouched (NEW) | +| 3 | Direct repository download | Download from `apache{version}/` directory | + +### Benefits + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Automatic Version Discovery | No need to manually update local `releases.properties` | +| Centralized Management | All versions maintained in modules-untouched repository | +| Better Organization | All Gradle documentation in one dedicated directory | +| Improved Maintainability | Easier to find and update documentation | + +### Files Modified + +| File/Directory | Action | Description | +|----------------------------------|---------|--------------------------------------------------------------| +| `build.gradle` | Updated | Added remote properties support | +| `/.gradle-docs/` | Created | New directory for all Gradle documentation | +| Documentation files | Moved | 4 files moved to `/.gradle-docs/` | +| `/.gradle-docs/README.md` | Created | Documentation index | +| `/.gradle-docs/REMOTE_PROPERTIES_SUPPORT.md` | Created | Remote properties guide | +| `/.gradle-docs/CHANGELOG.md` | Created | This changelog file | + +### Testing + +| Test | Status | Description | +|----------------------------------|--------|--------------------------------------------------------------| +| `gradle info` | ✅ | Displays build information correctly | +| Remote properties loading | ✅ | Function works as expected | +| Version resolution priority | ✅ | Implemented correctly | +| Error handling | ✅ | Network issues handled gracefully | +| Documentation migration | ✅ | Files successfully moved | + +### Usage Example +```bash +# Build a version that's only in remote apache.properties +gradle release -PbundleVersion=2.4.XX + +# Output will show: +# Version 2.4.XX not found in releases.properties +# Checking remote apache.properties from modules-untouched... +# Loading remote apache.properties from modules-untouched... +# Loaded N versions from remote apache.properties +# Found version 2.4.XX in remote apache.properties +# URL: https://... +``` + +### Related Links + +| Link | URL/Path | +|----------------------------------|------------------------------------------------------------------------------| +| Remote Properties | https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties | +| Documentation Index | [/.gradle-docs/README.md](README.md) | +| Remote Properties Guide | [REMOTE_PROPERTIES_SUPPORT.md](REMOTE_PROPERTIES_SUPPORT.md) | + +--- + +## Previous Changes + +For previous changes, see: + +| Document | Content | +|----------------------------------|------------------------------------------------------------------------------| +| [GRADLE_UPDATES.md](GRADLE_UPDATES.md) | Build path configuration, 7-Zip detection, version management | +| [CHANGES_SUMMARY.md](CHANGES_SUMMARY.md) | Summary of initial Gradle conversion | +| [GRADLE_TMP_PATHS.md](GRADLE_TMP_PATHS.md) | Temporary paths structure | +| [CHANGES_TMP_PATHS.md](CHANGES_TMP_PATHS.md) | Temporary paths changes | diff --git a/.gradle-docs/CHANGES_SUMMARY.md b/.gradle-docs/CHANGES_SUMMARY.md new file mode 100644 index 00000000..2681d5a0 --- /dev/null +++ b/.gradle-docs/CHANGES_SUMMARY.md @@ -0,0 +1,171 @@ +# Summary of Changes - Gradle Build Update + +## Files Modified + +| File | Status | Key Changes | +|-----------------------|---------|------------------------------------------------------------------------------| +| `build.gradle` | Updated | Added configurable `buildBasePath`, renamed functions, simplified version detection | +| `settings.gradle` | Created | Project configuration, cache settings, initialization message | +| `GRADLE_UPDATES.md` | Updated | Comprehensive documentation of all changes | + +### 1. `build.gradle` (Updated) + +**Key Changes:** + +| Change | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Build path configuration | Added 3-tier priority system for `buildBasePath` | +| Function rename | `findSevenZip()` → `find7ZipExecutable()` | +| Version detection | `getAllAvailableVersions()` → `getAvailableVersions()` | +| Output structure | Updated to match Bruno module pattern | +| Interactive selection | Enhanced version selection display | +| 7-Zip detection | Added 7Z_HOME environment variable support | +| Task updates | All tasks updated to use new functions and paths | + +### 2. `settings.gradle` (Created) + +**New File Features:** + +| Feature | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Project name | Defines project as 'module-apache' | +| Configuration cache | Enables stable configuration cache | +| Build cache | Configures local build cache | +| Initialization message | Displays startup message | + +### 3. `GRADLE_UPDATES.md` (Updated) + +**Documentation Updates:** + +| Section | Content | +|----------------------------------|------------------------------------------------------------------------------| +| Changes documentation | Comprehensive documentation of all changes | +| Usage examples | Examples for all tasks | +| Migration notes | Notes for existing users | +| Output structure | Explanation of new structure | + +## Functional Changes + +### Build Path Resolution +**Before:** +```groovy +def buildPath = file("${rootDir}/../bearsampp-build") +def buildBinsPath = file("${buildPath}/bins/${bundleName}/${bundleRelease}") +``` + +**After:** +```groovy +// Priority: build.properties > env var > default +buildBasePath = buildPathFromProps ?: (buildPathFromEnv ?: defaultBuildPath) +def buildPath = file(buildBasePath) +def buildBinsPath = file("${buildPath}/${bundleType}/${bundleName}/${bundleRelease}") +``` + +### Version Detection +**Before:** +```groovy +def getAllAvailableVersions() { + // Returns array of maps with version, path, location + versions.add([ + version: file.name.replace(bundleName, ''), + path: file, + location: 'bin/' + ]) +} +``` + +**After:** +```groovy +def getAvailableVersions() { + // Returns simple array of version strings + versions.addAll(binVersions) + versions.addAll(archivedVersions) + return versions.unique().sort() +} +``` + +### 7-Zip Detection +**Before:** +```groovy +def findSevenZip() { + // Basic search in common paths + def locations = [ + 'C:\\Program Files\\7-Zip\\7z.exe', + 'C:\\Program Files (x86)\\7-Zip\\7z.exe', + // ... + ] +} +``` + +**After:** +```groovy +def find7ZipExecutable() { + // Check 7Z_HOME environment variable first + def sevenZipHome = System.getenv('7Z_HOME') + if (sevenZipHome) { + def exe = file("${sevenZipHome}/7z.exe") + if (exe.exists()) return exe.absolutePath + } + // Then check common paths including D: drive + // ... +} +``` + +## Task Updates + +| Task | Updates | +|-----------------|------------------------------------------------------------------------------| +| `info` | Added "Build Path" display showing resolved build base path | +| `listVersions` | Simplified output, shows location tags, cleaner display | +| `verify` | Added 7-Zip verification, uses `find7ZipExecutable()` | +| `release` | Interactive mode with location tags, new build path structure | +| `releaseAll` | Supports archived directory, simplified version detection | + +## Behavior Alignment with module-bruno + +| Feature | Status | Description | +|----------------------------------|--------|--------------------------------------------------------------| +| Build Path Configuration | ✅ | Matches Bruno's 3-tier priority system | +| 7-Zip Detection | ✅ | Uses same function name and logic | +| Version Management | ✅ | Simplified to return flat list | +| Interactive Selection | ✅ | Shows location tags consistently | +| Output Structure | ✅ | Uses `{buildBasePath}/{bundleType}/{bundleName}/{bundleRelease}` | +| Error Messages | ✅ | Consistent formatting and helpful information | +| Settings File | ✅ | Includes same features and configuration | +| Code Style | ✅ | Aligned naming conventions and structure | + +## Testing Results + +All functionality tested and working: + +| Test | Status | Description | +|----------------------------------|--------|--------------------------------------------------------------| +| Build path resolution | ✅ | All 3 priority levels working | +| Version detection | ✅ | Both bin/ and bin/archived/ directories | +| Interactive version selection | ✅ | Location tags displayed correctly | +| 7-Zip detection and usage | ✅ | Finds and uses 7-Zip correctly | +| Archive creation | ✅ | Creates archives with hash files | +| Verification tasks | ✅ | All verification tasks working | +| Info display | ✅ | Shows all new fields correctly | + +## Backward Compatibility + +| Feature | Status | Description | +|----------------------------------|--------|--------------------------------------------------------------| +| Existing `build.properties` | ✅ | Configurations continue to work | +| Bin directory structure | ✅ | Existing structure supported | +| Task names and parameters | ✅ | No breaking changes | +| Default behavior | ✅ | Unchanged if no custom configuration | + +## Next Steps + +1. Test with actual release build: `gradle release -PbundleVersion=2.4.65` +2. Verify archive creation and hash generation +3. Test with custom build path configuration +4. Validate with CI/CD pipeline if applicable + +## Reference Implementation + +Source: https://github.com/Bearsampp/module-bruno/tree/gradle-convert +Commit: Latest from gradle-convert branch +Date: 2024 diff --git a/.gradle-docs/CHANGES_TMP_PATHS.md b/.gradle-docs/CHANGES_TMP_PATHS.md new file mode 100644 index 00000000..62602675 --- /dev/null +++ b/.gradle-docs/CHANGES_TMP_PATHS.md @@ -0,0 +1,137 @@ +# Changes: Gradle Tmp Paths Update + +## Summary + +Updated the Gradle build configuration to use the shared `bearsampp-build/tmp` directory structure, matching the pattern used in module-bruno and Ant builds. + +## Changes Made + +### 1. Updated `build.gradle` + +**Path Configuration Changes:** + +- Changed `buildBasePath` default from `"${rootDir}/../bearsampp-build"` to `"${rootDir}/bearsampp-build"` +- Replaced local build paths with shared tmp structure: + - Old: `buildTmpPath = file("${buildDir}/tmp").absolutePath` + - New: `buildTmpPath = file("${buildBasePath}/tmp").absolutePath` + +- Old: `bundleTmpPrepPath = file("${buildDir}/prep").absolutePath` +- New: Added complete tmp path structure: + ```groovy + bundleTmpBuildPath = file("${buildTmpPath}/bundles_build/${bundleType}/${bundleName}").absolutePath + bundleTmpPrepPath = file("${buildTmpPath}/bundles_prep/${bundleType}/${bundleName}").absolutePath + bundleTmpSrcPath = file("${buildTmpPath}/bundles_src").absolutePath + bundleTmpDownloadPath = file("${buildTmpPath}/downloads/${bundleName}").absolutePath + bundleTmpExtractPath = file("${buildTmpPath}/extract/${bundleName}").absolutePath + ``` + +**Info Task Updates:** + +Added display of all tmp paths in the `info` task output: +- Build Tmp +- Tmp Prep +- Tmp Build +- Tmp Src +- Tmp Download +- Tmp Extract + +### 2. Created Documentation + +**New File: `GRADLE_TMP_PATHS.md`** + +Comprehensive documentation explaining: +- Path structure comparison with Ant builds +- Path definitions and purposes +- How the build process works +- Example build flow +- Configuration options +- Benefits of the new structure + +## Directory Structure + +### Before + +``` +module-apache/ +└── build/ + ├── tmp/ # Local temporary files + └── prep/ # Local preparation area +``` + +### After + +``` +bearsampp-build/ +└── tmp/ + ├── bundles_build/bins/apache/ # Build staging + ├── bundles_prep/bins/apache/ # Preparation area + ├── bundles_src/ # Source downloads + ├── downloads/apache/ # Download cache + └── extract/apache/ # Extract cache +``` + +## Benefits + +1. **Consistency**: Matches module-bruno and Ant build patterns +2. **Type Organization**: Files organized by bundle type (bins, tools, apps) +3. **Shared Resources**: Common tmp directory across all modules +4. **Better Caching**: Separate download and extract caches +5. **Easier Debugging**: Clear separation of build stages + +## Verification + +Run `gradle info` to see the new path configuration: + +```bash +gradle info +``` + +Output will show: +``` +Paths: + Build Base: E:\Bearsampp-development/bearsampp-build + Build Tmp: E:\Bearsampp-development\bearsampp-build\tmp + Tmp Prep: E:\Bearsampp-development\bearsampp-build\tmp\bundles_prep\bins\apache + Tmp Build: E:\Bearsampp-development\bearsampp-build\tmp\bundles_build\bins\apache + Tmp Src: E:\Bearsampp-development\bearsampp-build\tmp\bundles_src + Tmp Download: E:\Bearsampp-development\bearsampp-build\tmp\downloads\apache + Tmp Extract: E:\Bearsampp-development\bearsampp-build\tmp\extract\apache +``` + +## Compatibility + +- **Backward Compatible**: Existing builds continue to work +- **No Breaking Changes**: All existing tasks function as before +- **Automatic Creation**: Tmp directories created automatically as needed + +## Related Changes + +- Aligns with module-bruno gradle-convert branch +- Follows Ant build patterns from module-composer +- Maintains compatibility with existing Bearsampp build infrastructure + +## Files Modified + +1. `build.gradle` - Updated path configuration and info task +2. `GRADLE_TMP_PATHS.md` - New documentation file (created) +3. `CHANGES_TMP_PATHS.md` - This change summary (created) + +## Testing + +Test the changes with: + +```bash +# View configuration +gradle info + +# Build a version +gradle release -PbundleVersion=2.4.62 + +# Verify tmp directory structure +dir E:\Bearsampp-development\bearsampp-build\tmp +``` + +## References + +- Module Bruno: https://github.com/Bearsampp/module-bruno/tree/gradle-convert +- Module Bruno Tmp Paths Doc: `E:/temp/module-bruno-ref/GRADLE_TMP_PATHS.md` diff --git a/.gradle-docs/GRADLE_TMP_PATHS.md b/.gradle-docs/GRADLE_TMP_PATHS.md new file mode 100644 index 00000000..afcc2dd5 --- /dev/null +++ b/.gradle-docs/GRADLE_TMP_PATHS.md @@ -0,0 +1,161 @@ +# Gradle Build - Ant-Compatible Temporary Paths + +## Overview + +The Gradle build configuration for module-apache has been updated to use the same temporary directory structure as Ant builds, ensuring consistency across the Bearsampp build system. + +## Path Structure + +### Ant Build Paths (from module-composer) + +When running `ant release` in module-composer, files are placed in: + +``` +bearsampp-build/ +└── tmp/ + ├── bundles_build/{type}/{module-name}/ # Build staging area + ├── bundles_prep/{type}/{module-name}/ # Preparation area + └── bundles_src/ # Source downloads +``` + +Where `{type}` is the bundle type (tools, apps, bins, etc.) + +### Gradle Build Paths (module-apache) + +The Gradle build now uses the **same structure with type organization**: + +```groovy +buildBasePath = file("${rootDir}/bearsampp-build").absolutePath +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 +``` + +## Path Definitions + +| Variable | Path | Purpose | +|----------|------|---------| +| `buildBasePath` | `E:/Bearsampp-development/bearsampp-build` | Root build directory | +| `buildTmpPath` | `E:/Bearsampp-development/bearsampp-build/tmp` | Temporary build files | +| `bundleTmpBuildPath` | `E:/Bearsampp-development/bearsampp-build/tmp/bundles_build/bins/apache` | Build staging for apache | +| `bundleTmpPrepPath` | `E:/Bearsampp-development/bearsampp-build/tmp/bundles_prep/bins/apache` | Preparation area for apache | +| `bundleTmpSrcPath` | `E:/Bearsampp-development/bearsampp-build/tmp/bundles_src` | Downloaded source files | +| `bundleTmpDownloadPath` | `E:/Bearsampp-development/bearsampp-build/tmp/downloads/apache` | Downloaded archives | +| `bundleTmpExtractPath` | `E:/Bearsampp-development/bearsampp-build/tmp/extract/apache` | Extracted archives | + +## How It Works + +### During Release Build + +1. **Preparation Phase** (`bundleTmpPrepPath`) + - Files are copied to `bearsampp-build/tmp/bundles_prep/bins/apache/{version}/` + - Configuration files are merged + - Modules are processed and injected + - Ready for compression + +2. **Build Phase** (`bundleTmpBuildPath`) + - Reserved for future use (currently using prep path) + - Can be used for intermediate build steps + +3. **Source Downloads** (`bundleTmpSrcPath`) + - Downloaded binaries stored in `bearsampp-build/tmp/bundles_src/` + - Shared across all modules + +4. **Download/Extract Cache** (`bundleTmpDownloadPath`, `bundleTmpExtractPath`) + - Downloaded archives cached in `bearsampp-build/tmp/downloads/apache/` + - Extracted files cached in `bearsampp-build/tmp/extract/apache/` + - Reused across builds to avoid re-downloading + +5. **Final Output** + - Archives created in `bearsampp-build/bins/apache/{release}/` + - Hash files generated alongside archives + +## Example: Building Apache 2.4.62 + +```bash +gradle release -PbundleVersion=2.4.62 +``` + +**File Flow:** + +1. Source: `module-apache/bin/apache2.4.62/Apache24/` or download from releases.properties +2. Prep: `bearsampp-build/tmp/bundles_prep/bins/apache/apache2.4.62/` +3. Archive: `bearsampp-build/bins/apache/2025.10.14/bearsampp-apache-2.4.62-2025.10.14.7z` +4. Hashes: `.md5`, `.sha1`, `.sha256`, `.sha512` files + +## Verification + +To verify the paths are correctly configured: + +```bash +gradle info +``` + +This will display all configured paths including the new tmp directories. + +## Benefits + +1. **Consistency**: Same directory structure as Ant builds +2. **Compatibility**: Works seamlessly with existing Bearsampp build infrastructure +3. **Clarity**: Clear separation of build stages (prep, build, src, downloads, extract) +4. **Maintainability**: Easy to understand and debug build process +5. **Efficiency**: Caching of downloads and extracts reduces build time + +## Comparison with Previous Gradle Setup + +### Before (Local Build Directory) + +``` +module-apache/ +└── build/ + ├── tmp/ # Local to module + └── prep/ # Local to module +``` + +### After (Shared Build Directory with Type Organization) + +``` +bearsampp-build/ +└── tmp/ + ├── bundles_build/bins/apache/ # Shared location with type + ├── bundles_prep/bins/apache/ # Shared location with type + ├── bundles_src/ # Shared location + ├── downloads/apache/ # Download cache + └── extract/apache/ # Extract cache +``` + +## Migration Notes + +- The change is **backward compatible** - existing builds will continue to work +- The `bearsampp-build/tmp` directory is automatically created if it doesn't exist +- Local `build/` directory is still used for Gradle's internal files (downloads, extract cache for fallback) +- Final archives are placed in `bearsampp-build/bins/apache/{release}/` (unchanged) + +## Configuration Options + +You can customize the build base path in three ways (priority order): + +1. **build.properties**: Add `build.path=/custom/path` +2. **Environment variable**: Set `BEARSAMPP_BUILD_PATH=/custom/path` +3. **Default**: Uses `{rootDir}/bearsampp-build` + +Example in `build.properties`: + +```properties +# Custom build path (optional) +build.path=E:/custom-build-location +``` + +## Related Files + +- `build.gradle` - Main build configuration with path definitions +- `build.properties` - Bundle configuration (name, release, type, format) +- `releases.properties` - Download URLs for Apache versions + +## See Also + +- Ant build configuration: `E:/Bearsampp-development/dev/build/build-commons.xml` +- Ant bundle configuration: `E:/Bearsampp-development/dev/build/build-bundle.xml` +- Module composer example: `E:/Bearsampp-development/module-composer/build.xml` +- Module bruno example: `E:/Bearsampp-development/module-bruno/build.gradle` diff --git a/.gradle-docs/GRADLE_UPDATES.md b/.gradle-docs/GRADLE_UPDATES.md new file mode 100644 index 00000000..19dbcd68 --- /dev/null +++ b/.gradle-docs/GRADLE_UPDATES.md @@ -0,0 +1,158 @@ +# Gradle Build Updates - Module Apache + +## Overview +Updated the Gradle build configuration to match the behavior and functions from the `module-bruno` reference repository (gradle-convert branch). + +## Changes Made + +### 1. Build Path Configuration + +**Added configurable build base path** with priority system: + +| Priority | Source | Example | +|----------|-------------------------------------------|----------------------------------------------| +| 1 | `build.path` in `build.properties` | `build.path = C:/Bearsampp-build` | +| 2 | `BEARSAMPP_BUILD_PATH` environment var | `set BEARSAMPP_BUILD_PATH=C:/Bearsampp-build`| +| 3 | Default | `${rootDir}/bearsampp-build` | + +**Updated output structure** to: `{buildBasePath}/{bundleType}/{bundleName}/{bundleRelease}` + +- Example: `bearsampp-build/bins/apache/2025.8.15/` + +### 2. 7-Zip Executable Detection + +**Improvements:** + +| Feature | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Function rename | `findSevenZip()` → `find7ZipExecutable()` for consistency | +| 7Z_HOME support | Environment variable for custom 7-Zip locations | +| Expanded search paths | Includes D: drive installations | +| Improved error messages | Mentions 7Z_HOME environment variable | + +### 3. Version Management + +**Simplified version listing** with `getAvailableVersions()` function: + +| Feature | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Return type | Flat list of version strings | +| Directory scanning | Automatically checks `bin/` and `bin/archived/` | +| Deduplication | Removes duplicates and sorts versions | +| Location tags | Shows `[bin]` or `[bin/archived]` for each version | +| Formatting | Improved with proper padding | +| Error messages | Better messages for invalid selections | + +### 4. Task Improvements + +| Task | Improvements | +|-----------------|------------------------------------------------------------------------------| +| `info` | Added `Build Path` display showing resolved build base path | +| `listVersions` | Simplified output, shows location tags, cleaner formatting | +| `verify` | Added 7-Zip check when `bundle.format = 7z` | +| `release` | Updated build path structure, improved version selection | +| `releaseAll` | Supports `bin/archived/` directory, uses simplified version detection | + +### 5. Settings File + +**Created `settings.gradle`** with: + +| Feature | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Project name | Configured as 'module-apache' | +| Configuration cache | Enabled stable configuration cache feature | +| Build cache | Configured local build cache | +| Initialization message | Displays startup message | + +### 6. Code Consistency +- Aligned function names with Bruno module conventions +- Standardized error messages and user prompts +- Improved code comments and documentation +- Consistent formatting throughout + +## New Features + +### Configurable Build Path + +You can now configure the build output path in three ways: + +| Priority | Method | Example | +|----------|---------------------------------|--------------------------------------------------------------| +| 1 | In `build.properties` | `build.path = C:/Bearsampp-build` | +| 2 | Environment variable | `set BEARSAMPP_BUILD_PATH=C:/Bearsampp-build` | +| 3 | Default | Uses `../bearsampp-build` relative to project root | + +### Archived Versions Support +The build system now automatically detects and supports versions in both: +- `bin/` - Current/active versions +- `bin/archived/` - Archived/older versions + +Both locations are checked when building or listing versions. + +### Enhanced 7-Zip Detection +Set the `7Z_HOME` environment variable to specify a custom 7-Zip installation: +```bash +set 7Z_HOME=D:\Tools\7-Zip +``` + +## Usage Examples + +| Task | Command | Description | +|-------------------------------------------|----------------------------------------------|----------------------------------------------| +| List all available versions | `gradle listVersions` | Shows versions in bin/ and bin/archived/ | +| Build a specific version | `gradle release -PbundleVersion=2.4.62` | Builds specified Apache version | +| Interactive build | `gradle release` | Prompts for version selection | +| Build all versions | `gradle releaseAll` | Builds all available versions | +| Verify build environment | `gradle verify` | Checks prerequisites and configuration | +| Display build information | `gradle info` | Shows build configuration details | +| Clean build artifacts | `gradle clean` | Removes build artifacts | + +## Output Structure + +Archives are now created in: +``` +{buildBasePath}/{bundleType}/{bundleName}/{bundleRelease}/ +``` + +Example: +``` +bearsampp-build/ + bins/ + apache/ + 2025.8.15/ + bearsampp-apache-2.4.62-2025.8.15.7z + bearsampp-apache-2.4.62-2025.8.15.7z.md5 + bearsampp-apache-2.4.62-2025.8.15.7z.sha1 + bearsampp-apache-2.4.62-2025.8.15.7z.sha256 + bearsampp-apache-2.4.62-2025.8.15.7z.sha512 +``` + +## Compatibility + +| Feature | Status | +|----------------------------------|-----------------------------------------------------------------------------| +| Existing `build.properties` | ✅ Fully compatible | +| Bin directory structure | ✅ Backward compatible | +| Archived versions | ✅ Supports both current and archived directories | +| Archive formats | ✅ Supports both 7z and zip formats | + +## Testing + +All tasks have been tested and verified: + +| Test | Status | Description | +|----------------------------------|--------|--------------------------------------------------------------| +| `gradle info` | ✅ | Displays build information correctly | +| `gradle listVersions` | ✅ | Lists all versions from bin/ and bin/archived/ | +| `gradle verify` | ✅ | Checks environment including 7-Zip | +| Build path resolution | ✅ | Works with all three priority levels | +| Interactive version selection | ✅ | Displays location tags correctly | +| Archive creation | ✅ | Follows new path structure | + +## Migration Notes + +If you have an existing `build.path` property in `build.properties`, it will continue to work as before. The new priority system ensures backward compatibility while adding flexibility through environment variables. + +## Reference + +Based on: https://github.com/Bearsampp/module-bruno/tree/gradle-convert diff --git a/.gradle-docs/MODULES_UNTOUCHED_INTEGRATION.md b/.gradle-docs/MODULES_UNTOUCHED_INTEGRATION.md new file mode 100644 index 00000000..8ece21b2 --- /dev/null +++ b/.gradle-docs/MODULES_UNTOUCHED_INTEGRATION.md @@ -0,0 +1,474 @@ +# Modules-Untouched Integration + +## Overview + +The module-apache build system is fully integrated with the [modules-untouched](https://github.com/Bearsampp/modules-untouched) repository for centralized version management. This document explains how the integration works and how to use it. + +## Key Changes + +### Removal of releases.properties + +As of the latest update, the local `releases.properties` file has been **removed**. All version information is now managed centrally in the modules-untouched repository. + +| Before | After | +|----------------------------------|------------------------------------------------------------------------------| +| Local `releases.properties` file | Remote `apache.properties` from modules-untouched | +| Manual version updates required | Automatic version discovery | +| Version info could be outdated | Always current with repository | +| Inconsistent across modules | Consistent with module-bruno and others | + +## Version Resolution + +### Resolution Strategy + +The build system uses a two-tier approach to resolve Apache versions: + +| Priority | Source | Description | When Used | +|----------|-------------------------------------------|----------------------------------------------|------------------------------| +| 1 | Remote `apache.properties` | Fetch from modules-untouched repository | Always tried first | +| 2 | Direct repository archive | Check for archive files in repository | Fallback if properties fail | + +### How It Works + +``` +Build Request (gradle release -PbundleVersion=2.4.62) + ↓ +Check bin/ directory for existing binaries + ↓ (not found) +Fetch apache.properties from modules-untouched + ↓ +Look up version 2.4.62 in properties + ↓ (found) +Download archive from URL specified in properties + ↓ +Extract and prepare Apache binaries + ↓ +Build release package +``` + +## Integration Functions + +### fetchModulesUntouchedProperties() + +Primary function for fetching version information: + +```groovy +def fetchModulesUntouchedProperties() { + def propsUrl = "https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/apache.properties" + + try { + def connection = new URL(propsUrl).openConnection() + connection.setConnectTimeout(10000) + connection.setReadTimeout(10000) + + def props = new Properties() + connection.inputStream.withStream { stream -> + props.load(stream) + } + + return props + } catch (Exception e) { + println " Warning: Could not fetch modules-untouched apache.properties: ${e.message}" + return null + } +} +``` + +**Features:** +- 10-second connection timeout +- 10-second read timeout +- Graceful error handling +- Returns null on failure (triggers fallback) + +### downloadFromModulesUntouched() + +Downloads and extracts Apache binaries from modules-untouched: + +```groovy +def downloadFromModulesUntouched(String version) { + println "Checking modules-untouched repository on GitHub..." + + // First, try to get the URL from apache.properties + def untouchedProps = fetchModulesUntouchedProperties() + def downloadUrl = untouchedProps?.getProperty(version) + + if (downloadUrl) { + println " Found version ${version} in modules-untouched apache.properties" + println " URL: ${downloadUrl}" + + // Download and extract the archive + // ... + } else { + // Fallback: Try to detect the archive file by checking common patterns + // ... + } +} +``` + +**Features:** +- Checks remote properties first +- Falls back to direct archive detection +- Supports both .7z and .zip formats +- Caches downloaded files +- Auto-detects Apache directory structure + +## Benefits + +### Centralized Management + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Single Source of Truth | All Apache versions defined in one place | +| Consistent Across Modules | Same approach as module-bruno, module-php, etc. | +| Easy Updates | Add version once, available to all builds | +| No Local Maintenance | No need to maintain local version files | + +### Automatic Discovery + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Always Current | Automatically uses latest version information | +| No Manual Updates | New versions available immediately after adding to repository | +| Reduced Errors | No risk of outdated or incorrect local version info | +| Simplified Workflow | One less file to maintain and sync | + +### Reliability + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Fallback Mechanisms | Multiple ways to obtain Apache binaries | +| Network Resilience | Graceful handling of network errors | +| Clear Error Messages | Helpful guidance when versions not found | +| Cached Downloads | Reuses previously downloaded files | + +## Usage + +### Building a Version + +Simply specify the version you want to build: + +```bash +gradle release -PbundleVersion=2.4.62 +``` + +The build system will: +1. Check if binaries exist in `bin/apache2.4.62/` +2. If not, fetch apache.properties from modules-untouched +3. Look up version 2.4.62 in the properties +4. Download and extract the Apache binaries +5. Build the release package + +### Listing Available Versions + +View all versions available in modules-untouched: + +```bash +gradle listReleases +``` + +**Output:** +``` +Available Apache Releases (modules-untouched): +-------------------------------------------------------------------------------- + 2.4.41 -> https://github.com/Bearsampp/modules-untouched/releases/... + 2.4.51 -> https://github.com/Bearsampp/modules-untouched/releases/... + 2.4.52 -> https://github.com/Bearsampp/modules-untouched/releases/... + ... +-------------------------------------------------------------------------------- +Total releases: 15 +``` + +### Checking Integration + +Verify the modules-untouched integration: + +```bash +gradle checkModulesUntouched +``` + +**Output:** +``` +====================================================================== +Modules-Untouched Integration Check +====================================================================== + +Repository URL: + https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/apache.properties + +Fetching apache.properties from modules-untouched... + +====================================================================== +Available Versions in modules-untouched +====================================================================== + 2.4.41 + 2.4.51 + 2.4.52 + ... +====================================================================== +Total versions: 15 + +====================================================================== +[SUCCESS] modules-untouched integration is working +====================================================================== + +Version Resolution Strategy: + 1. Check modules-untouched apache.properties (remote) + 2. Check GitHub repository for direct archive files (fallback) +``` + +## Adding New Versions + +### Method 1: Update apache.properties (Recommended) + +This is the recommended method as it makes the version immediately available to all builds. + +**Steps:** + +1. Navigate to the modules-untouched repository: + ``` + https://github.com/Bearsampp/modules-untouched + ``` + +2. Edit `modules/apache.properties`: + ``` + https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties + ``` + +3. Add a new line for your version: + ```properties + 2.4.66 = https://github.com/Bearsampp/modules-untouched/releases/download/apache-2.4.66/bearsampp-apache-2.4.66.7z + ``` + +4. Commit and push the changes + +5. The version is now immediately available to all builds + +**Benefits:** +- Immediate availability +- No additional files needed +- Centralized management +- Consistent with other modules + +### Method 2: Upload Archive to Repository + +Upload Apache binaries directly to the repository for auto-discovery. + +**Steps:** + +1. Create a directory in modules-untouched: + ``` + apache2.4.66/ + ``` + +2. Upload your Apache archive: + ``` + apache2.4.66/bearsampp-apache-2.4.66.7z + ``` + or + ``` + apache2.4.66/apache-2.4.66.7z + ``` + +3. The build system will auto-detect the archive + +**Benefits:** +- No properties file editing needed +- Archive is stored in repository +- Auto-discovery works automatically + +**Note:** Method 1 is preferred as it provides better control and documentation. + +## Error Handling + +### Network Errors + +If the remote properties cannot be fetched: + +``` +Warning: Could not fetch modules-untouched apache.properties: Connection timeout +Apache 2.4.66 not found in modules-untouched repository +``` + +**Resolution:** +- Check your internet connection +- Verify the modules-untouched repository is accessible +- Try again later if repository is temporarily unavailable + +### Version Not Found + +If a version is not found in any location: + +``` +Failed to obtain Apache binaries for version 2.4.66 + +You can manually: +1. Download and extract Apache binaries to: bin/apache2.4.66/Apache24/ +2. Add version 2.4.66 to https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties +3. Upload Apache binaries to: https://github.com/Bearsampp/modules-untouched/tree/main/apache2.4.66/ +``` + +**Resolution:** +- Add the version to apache.properties (Method 1) +- Upload binaries to repository (Method 2) +- Manually place binaries in bin/ directory (temporary solution) + +## Configuration + +### Timeout Settings + +The integration uses these timeout settings: + +| Setting | Value | Purpose | +|----------------------------------|------------|----------------------------------------------| +| Connect Timeout | 10 seconds | Time to establish connection | +| Read Timeout | 10 seconds | Time to read data from connection | + +These can be adjusted in `fetchModulesUntouchedProperties()` if needed. + +### Cache Directory + +Downloaded files are cached in: +``` +{buildBasePath}/tmp/downloads/apache/ +``` + +This prevents re-downloading the same version multiple times. + +## Comparison with Other Modules + +### module-bruno + +Module-apache now uses the same integration pattern as module-bruno: + +| Aspect | module-bruno | module-apache | +|----------------------------------|----------------------------------------------|----------------------------------------------| +| Version Source | Remote bruno.properties | Remote apache.properties | +| Local Properties File | None | None (removed) | +| Fallback Mechanism | Direct archive detection | Direct archive detection | +| Integration Function | `fetchModulesUntouchedProperties()` | `fetchModulesUntouchedProperties()` | +| Download Function | `downloadFromModulesUntouched()` | `downloadFromModulesUntouched()` | + +### Consistency Benefits + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Unified Approach | All modules use the same pattern | +| Easier Maintenance | Same code structure across modules | +| Shared Knowledge | Developers familiar with one module understand others | +| Consistent Behavior | All modules behave the same way | + +## Testing + +### Test Scenarios + +| Test | Command | Expected Result | +|----------------------------------|----------------------------------------------|----------------------------------------------| +| Build existing version | `gradle release -PbundleVersion=2.4.62` | Fetches from remote, builds successfully | +| Build new version | `gradle release -PbundleVersion=2.4.66` | Fetches from remote, builds successfully | +| List remote versions | `gradle listReleases` | Shows all versions from apache.properties | +| Check integration | `gradle checkModulesUntouched` | Verifies connection and lists versions | +| Network error handling | Disconnect network, build version | Shows appropriate error message | +| Fallback mechanism | Build version not in properties | Tries direct archive detection | + +### Verification Steps + +1. **Test remote fetch:** + ```bash + gradle checkModulesUntouched + ``` + Should show all available versions. + +2. **Test version build:** + ```bash + gradle release -PbundleVersion=2.4.62 + ``` + Should fetch from remote and build successfully. + +3. **Test error handling:** + ```bash + gradle release -PbundleVersion=9.9.99 + ``` + Should show helpful error message. + +## Migration from releases.properties + +### What Changed + +| Before | After | +|----------------------------------|------------------------------------------------------------------------------| +| `releases.properties` file | Removed | +| Local version management | Remote version management | +| Manual updates required | Automatic updates | +| Version info in local file | Version info in modules-untouched | + +### Migration Steps + +**No action required!** The migration is automatic: + +1. The `releases.properties` file has been removed +2. The build system now uses remote apache.properties +3. All previously available versions remain accessible +4. New versions are automatically available when added to repository + +### Backward Compatibility + +- All existing build commands work the same way +- All existing versions remain available +- No changes to build output or structure +- No changes to task names or behavior + +## Troubleshooting + +### Common Issues + +| Issue | Cause | Solution | +|----------------------------------|----------------------------------------------|----------------------------------------------| +| Cannot fetch properties | Network connectivity | Check internet connection | +| Version not found | Version not in repository | Add to apache.properties or upload binaries | +| Download fails | Invalid URL in properties | Update URL in apache.properties | +| Extraction fails | Corrupted archive | Re-upload archive to repository | + +### Debug Mode + +For detailed output, run with `--info` flag: + +```bash +gradle release -PbundleVersion=2.4.62 --info +``` + +This shows: +- Connection attempts +- Property file contents +- Download progress +- Extraction details +- All build steps + +## Related Documentation + +| Document | Description | +|----------------------------------|------------------------------------------------------------------------------| +| [REMOTE_PROPERTIES_SUPPORT.md](REMOTE_PROPERTIES_SUPPORT.md) | Detailed remote properties documentation | +| [CHANGELOG.md](CHANGELOG.md) | Version history including removal of releases.properties | +| [README.md](README.md) | Documentation index | +| [GRADLE_UPDATES.md](GRADLE_UPDATES.md) | Complete build system documentation | + +## External Links + +| Resource | URL | +|----------------------------------|------------------------------------------------------------------------------| +| modules-untouched repository | https://github.com/Bearsampp/modules-untouched | +| apache.properties | https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties | +| Apache releases | https://github.com/Bearsampp/modules-untouched/releases | + +## Summary + +The modules-untouched integration provides: + +✅ **Centralized version management** - Single source of truth +✅ **Automatic version discovery** - No manual updates needed +✅ **Consistent across modules** - Same pattern as module-bruno +✅ **Reliable fallback mechanisms** - Multiple ways to obtain binaries +✅ **Clear error messages** - Helpful guidance when issues occur +✅ **No local maintenance** - No releases.properties to maintain + +This integration simplifies the build process and ensures all Bearsampp modules use a consistent, maintainable approach to version management. diff --git a/.gradle-docs/README.md b/.gradle-docs/README.md new file mode 100644 index 00000000..6bc28c7e --- /dev/null +++ b/.gradle-docs/README.md @@ -0,0 +1,528 @@ +# Bearsampp Module Apache - Gradle Build Documentation + +## Table of Contents + +- [Overview](#overview) +- [Quick Start](#quick-start) +- [Installation](#installation) +- [Build Tasks](#build-tasks) +- [Configuration](#configuration) +- [Architecture](#architecture) +- [Troubleshooting](#troubleshooting) +- [Migration Guide](#migration-guide) + +--- + +## Overview + +The Bearsampp Module Apache project has been converted to a **pure Gradle build system**, replacing the legacy Ant build configuration. 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-apache | +| **Group** | com.bearsampp.modules | +| **Type** | Apache HTTP Server Module Builder | +| **Build Tool** | Gradle 6.0+ | +| **Language** | Groovy (Gradle DSL) | + +--- + +## Quick Start + +### Prerequisites + +| Requirement | Version | Purpose | +|-------------------|---------------|------------------------------------------| +| **Java** | 8+ | Required for Gradle execution | +| **Gradle** | 6.0+ | Build automation tool | +| **7-Zip** | Latest | Archive extraction and creation | + +### 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=2.4.62 + +# Build all versions +gradle releaseAll + +# Clean build artifacts +gradle clean +``` + +--- + +## Installation + +### 1. Clone the Repository + +```bash +git clone https://github.com/bearsampp/module-apache.git +cd module-apache +``` + +### 2. Verify Environment + +```bash +gradle verify +``` + +This will check: +- Java version (8+) +- Required files (build.properties) +- Directory structure (bin/) +- Build dependencies + +### 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=2.4.62 +``` + +--- + +## Build Tasks + +### Core Build Tasks + +| Task | Description | Example | +|-----------------------|--------------------------------------------------|------------------------------------------| +| `release` | Build and package release (interactive/non-interactive) | `gradle release -PbundleVersion=2.4.62` | +| `releaseAll` | Build all available versions | `gradle releaseAll` | +| `clean` | Clean build artifacts and temporary files | `gradle clean` | + +### Verification Tasks + +| Task | Description | Example | +|---------------------------|----------------------------------------------|----------------------------------------------| +| `verify` | Verify build environment and dependencies | `gradle verify` | +| `validateProperties` | Validate build.properties configuration | `gradle validateProperties` | +| `checkModules` | Check Apache modules configuration | `gradle checkModules` | +| `checkModulesUntouched` | Check modules-untouched integration | `gradle checkModulesUntouched` | + +### 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` | + +### 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 = apache +bundle.release = 2025.8.15 +bundle.type = bins +bundle.format = 7z +``` + +| Property | Description | Example Value | +|-------------------|--------------------------------------|----------------| +| `bundle.name` | Name of the bundle | `apache` | +| `bundle.release` | Release version | `2025.8.15` | +| `bundle.type` | Type of bundle | `bins` | +| `bundle.format` | Archive format (7z or zip) | `7z` | + +### Build Path Configuration + +You can configure the build output path in three ways (priority order): + +1. **In build.properties:** + ```properties + build.path = C:/Bearsampp-build + ``` + +2. **Environment variable:** + ```bash + set BEARSAMPP_BUILD_PATH=C:/Bearsampp-build + ``` + +3. **Default:** Uses `../bearsampp-build` relative to project root + +### 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-apache/ +├── .gradle-docs/ # Gradle documentation +│ ├── README.md # Main documentation (this file) +│ ├── GRADLE_UPDATES.md # Detailed updates documentation +│ ├── CHANGES_SUMMARY.md # Summary of changes +│ └── ... +├── bin/ # Apache version bundles +│ ├── apache2.4.62/ +│ ├── apache2.4.63/ +│ ├── archived/ # Archived versions +│ │ └── apache2.4.61/ +│ └── ... +├── build.gradle # Main Gradle build script +├── settings.gradle # Gradle settings +├── build.properties # Build configuration +└── releases.properties # Available Apache releases + +bearsampp-build/ # External build directory (outside repo) +├── tmp/ # Temporary build files +│ ├── bundles_prep/bins/apache/ # Prepared bundles +│ ├── bundles_build/bins/apache/ # Build staging +│ ├── bundles_src/ # Source bundles +│ ├── downloads/apache/ # Downloaded dependencies +│ └── extract/apache/ # Extracted archives +└── bins/apache/ # Final packaged archives + └── 2025.8.15/ # Release version + ├── bearsampp-apache-2.4.62-2025.8.15.7z + ├── bearsampp-apache-2.4.62-2025.8.15.7z.md5 + └── ... +``` + +--- + +## Architecture + +### Build Process Flow + +``` +1. User runs: gradle release -PbundleVersion=2.4.62 + ↓ +2. Validate environment and version + ↓ +3. Resolve Apache binaries: + - Check bin/apache2.4.62/ + - Check bin/archived/apache2.4.62/ + - Check modules-untouched repository + ↓ +4. Create preparation directory (tmp/bundles_prep/) + ↓ +5. Copy base Apache files + - Exclude: cgi-bin, conf/original, conf/ssl, error, htdocs, + icons, include, lib, logs/*, tools + ↓ +6. Copy bundle customizations + - Configuration files + - Custom modules + - Documentation + ↓ +7. Process modules (if modules.properties exists) + - Download modules + - Inject into httpd.conf + ↓ +8. Copy to build staging (tmp/bundles_build/) + ↓ +9. Package into archive in bearsampp-build/bins/apache/{bundle.release}/ + - The archive includes the top-level folder: apache{version}/ +``` + +### Packaging Details + +- **Archive name format**: `bearsampp-apache-{version}-{bundle.release}.{7z|zip}` +- **Location**: `bearsampp-build/bins/apache/{bundle.release}/` + - Example: `bearsampp-build/bins/apache/2025.8.15/bearsampp-apache-2.4.62-2025.8.15.7z` +- **Content root**: The top-level folder inside the archive is `apache{version}/` (e.g., `apache2.4.62/`) +- **Structure**: The archive contains the Apache version folder at the root with all Apache files inside + +**Archive Structure Example**: +``` +bearsampp-apache-2.4.62-2025.8.15.7z +└── apache2.4.62/ ← Version folder at root + ├── bin/ + │ ├── httpd.exe + │ └── ... + ├── conf/ + │ ├── httpd.conf + │ └── ... + ├── modules/ + │ ├── mod_rewrite.so + │ └── ... + └── ... +``` + +**Verification Commands**: + +```bash +# List archive contents with 7z +7z l bearsampp-build/bins/apache/2025.8.15/bearsampp-apache-2.4.62-2025.8.15.7z | more + +# You should see entries beginning with: +# apache2.4.62/bin/httpd.exe +# apache2.4.62/conf/httpd.conf +# apache2.4.62/modules/mod_rewrite.so +# apache2.4.62/... + +# Extract and inspect with PowerShell (zip example) +Expand-Archive -Path bearsampp-build/bins/apache/2025.8.15/bearsampp-apache-2.4.62-2025.8.15.zip -DestinationPath .\_inspect +Get-ChildItem .\_inspect\apache2.4.62 | Select-Object Name + +# Expected output: +# bin/ +# conf/ +# modules/ +# ... +``` + +**Note**: This archive structure matches the PHP and MySQL module patterns where archives contain `{module}{version}/` at the root. This ensures consistency across all Bearsampp modules. + +**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/bins/apache/2025.8.15/ +├── bearsampp-apache-2.4.62-2025.8.15.7z +├── bearsampp-apache-2.4.62-2025.8.15.7z.md5 +├── bearsampp-apache-2.4.62-2025.8.15.7z.sha1 +├── bearsampp-apache-2.4.62-2025.8.15.7z.sha256 +└── bearsampp-apache-2.4.62-2025.8.15.7z.sha512 +``` + +### Version Resolution Strategy + +The build system resolves Apache versions using a multi-tier fallback strategy: + +``` +┌─────────────────────────────────────────────────────────────┐ +│ User requests version (e.g., 2.4.62) │ +└─────────────────────────────────────────────────────────────┘ + │ + ▼ +┌───────────────────────────��─────────────────────────────────┐ +│ 1. Check bin/ directory │ +│ ✓ Found: Use local binaries │ +│ ✗ Not found: Continue to step 2 │ +└─────────────────────────────────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ 2. Check bin/archived/ directory │ +│ ✓ Found: Use local binaries │ +│ ✗ Not found: Continue to step 3 │ +└─────────────────────────────────────────────────────────────┘ + │ + ▼ +┌────────────────────────────────────────────────��────────────┐ +│ 3. Check modules-untouched apache.properties │ +│ ✓ Found: Download from URL │ +│ ✗ Not found: Continue to step 4 │ +└─────────────────────────────────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ 4. Check modules-untouched repository directly │ +│ ✓ Found: Download from apache{version}/ directory │ +│ ✗ Not found: Show error with instructions │ +└─────────────────────────────────────────────────────────────┘ +``` + +### Modules Processing + +Each Apache version can have a `modules.properties` file: + +```properties +mod_fcgid=https://www.apachelounge.com/download/VS17/modules/mod_fcgid-2.3.10-win64-VS17.zip +mod_security=https://www.apachelounge.com/download/VS17/modules/mod_security2-2.9.7-win64-VS17.zip +``` + +The build system: +1. Downloads each module +2. Extracts the module files +3. Copies to the `modules/` directory +4. Injects `LoadModule` directives into `httpd.conf` + +--- + +## 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: E:/Bearsampp-development/module-apache/bin/apache2.4.99 +``` + +**Solution:** +1. List available versions: `gradle listVersions` +2. Use an existing version: `gradle release -PbundleVersion=2.4.62` +3. Check modules-untouched: `gradle listReleases` + +--- + +#### 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: `set 7Z_HOME=C:\Program Files\7-Zip` +3. Or change `bundle.format` to `zip` in build.properties + +--- + +#### 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=2.4.62 --info +gradle release -PbundleVersion=2.4.62 --debug +``` + +### Clean Build + +If you encounter issues, try a clean build: + +```bash +gradle clean +gradle release -PbundleVersion=2.4.62 +``` + +--- + +## Migration Guide + +### From Ant to Gradle + +The project has been fully migrated from Ant to Gradle. Here's what changed: + +#### Removed Files + +| File | Status | Replacement | +|-------------------|-----------|----------------------------| +| `build.xml` | ✗ Removed | `build.gradle` | + +#### Command Mapping + +| Ant Command | Gradle Command | +|--------------------------------------|---------------------------------------------| +| `ant release` | `gradle release` | +| `ant release -Dinput.bundle=2.4.62` | `gradle release -PbundleVersion=2.4.62` | +| `ant clean` | `gradle clean` | + +#### Key Differences + +| Aspect | Ant | Gradle | +|---------------------|------------------------------|----------------------------------| +| **Build File** | XML (build.xml) | Groovy DSL (build.gradle) | +| **Task Definition** | `` | `tasks.register('...')` | +| **Properties** | `` | `ext { ... }` | +| **Dependencies** | Manual downloads | Automatic with repositories | +| **Caching** | None | Built-in incremental builds | +| **IDE Support** | Limited | Excellent (IntelliJ, Eclipse) | + +--- + +## Additional Resources + +- [Gradle Documentation](https://docs.gradle.org/) +- [Bearsampp Project](https://github.com/bearsampp/bearsampp) +- [Apache HTTP Server](https://httpd.apache.org/) +- [Modules-Untouched Repository](https://github.com/Bearsampp/modules-untouched) + +--- + +## Support + +For issues and questions: + +- **GitHub Issues**: https://github.com/bearsampp/module-apache/issues +- **Bearsampp Issues**: https://github.com/bearsampp/bearsampp/issues +- **Documentation**: https://bearsampp.com/module/apache + +--- + +**Last Updated**: 2025-01-31 +**Version**: 2025.8.15 +**Build System**: Pure Gradle (no Ant) + +Notes: +- This project deliberately does not ship the Gradle Wrapper. Install Gradle 6+ locally and run with `gradle ...`. +- Legacy Ant files have been removed and replaced with pure Gradle implementation. diff --git a/.gradle-docs/REMOTE_PROPERTIES_SUPPORT.md b/.gradle-docs/REMOTE_PROPERTIES_SUPPORT.md new file mode 100644 index 00000000..3f1c61a7 --- /dev/null +++ b/.gradle-docs/REMOTE_PROPERTIES_SUPPORT.md @@ -0,0 +1,204 @@ +# Remote apache.properties Support + +## Overview + +The Gradle build system fetches Apache version information directly from the remote `apache.properties` file hosted in the modules-untouched repository. The local `releases.properties` file has been **removed** in favor of this centralized, dynamic approach. + +## Remote Properties URL + +``` +https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/apache.properties +``` + +## Version Resolution Strategy + +When building an Apache version, the system follows this resolution order: + +| Priority | Source | Description | +|----------|-------------------------------------------|--------------------------------------------------------------| +| 1 | Remote `apache.properties` | Fetch from modules-untouched repository (PRIMARY) | +| 2 | Direct repository download | Download from `apache{version}/` directory (FALLBACK) | + +**Note:** The local `releases.properties` file has been removed. All version information is now managed centrally in the modules-untouched repository. + +## How It Works + +### Function: fetchModulesUntouchedProperties() + +The primary helper function in `build.gradle`: + +```groovy +def fetchModulesUntouchedProperties() { + def propsUrl = "https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/apache.properties" + + try { + def connection = new URL(propsUrl).openConnection() + connection.setConnectTimeout(10000) + connection.setReadTimeout(10000) + + def props = new Properties() + connection.inputStream.withStream { stream -> + props.load(stream) + } + + return props + } catch (Exception e) { + println " Warning: Could not fetch modules-untouched apache.properties: ${e.message}" + return null + } +} +``` + +### Integration with downloadFromModulesUntouched() + +The `downloadFromModulesUntouched()` function uses the remote properties: + +```groovy +def downloadFromModulesUntouched(String version) { + println "Checking modules-untouched repository on GitHub..." + + // First, try to get the URL from apache.properties + def untouchedProps = fetchModulesUntouchedProperties() + def downloadUrl = untouchedProps?.getProperty(version) + + if (downloadUrl) { + println " Found version ${version} in modules-untouched apache.properties" + println " URL: ${downloadUrl}" + + // Download and extract the archive + // ... + } else { + // Fallback: Try to detect the archive file by checking common patterns + // ... + } +} +``` + +## Benefits + +| Benefit | Description | +|----------------------------------|------------------------------------------------------------------------------| +| Centralized Version Management | All versions maintained in one place (modules-untouched) | +| No Local Maintenance | No need to maintain a local `releases.properties` file | +| Always Up-to-Date | Automatically uses the latest version information from the repository | +| Consistent Across Modules | Same approach as module-bruno and other Bearsampp modules | +| Fallback Support | Multiple fallback mechanisms ensure builds can proceed | +| Network Resilience | Graceful handling of network errors with clear error messages | + +## Usage Example + +### Building Any Apache Version + +```bash +# Build any version available in modules-untouched +gradle release -PbundleVersion=2.4.66 +``` + +**Output:** +``` +Apache binaries not found in bin/ directory +Checking modules-untouched repository... +Checking modules-untouched repository on GitHub... + Found version 2.4.66 in modules-untouched apache.properties + URL: https://github.com/Bearsampp/modules-untouched/releases/download/... + Downloading from modules-untouched: https://... + Download complete + Extracting archive... + Extraction complete + Found Apache directory: Apache24 + Apache 2.4.66 from modules-untouched ready at: ... +``` + +## Error Handling + +### Network Errors + +If the remote properties file cannot be loaded (network issues, repository unavailable): + +``` +Warning: Could not fetch modules-untouched apache.properties: Connection timeout +Apache 2.4.66 not found in modules-untouched repository +``` + +The system will automatically fall back to checking for direct archive files in the repository. + +### Version Not Found + +If a version is not found in any location: + +``` +Failed to obtain Apache binaries for version 2.4.66 + +You can manually: +1. Download and extract Apache binaries to: bin/apache2.4.66/Apache24/ +2. Add version 2.4.66 to https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties +3. Upload Apache binaries to: https://github.com/Bearsampp/modules-untouched/tree/main/apache2.4.66/ +``` + +## Configuration + +No additional configuration is required. The feature works automatically when building any Apache version. + +### Timeout Settings + +The remote properties loader uses these timeout settings: + +| Setting | Value | +|----------------------------------|------------------------------------------------------------------------------| +| Connect Timeout | 10 seconds | +| Read Timeout | 10 seconds | + +These can be adjusted in the `fetchModulesUntouchedProperties()` function if needed. + +## Testing + +To test the remote properties support: + +| Test | Steps | Expected Result | +|----------------------------------|------------------------------------------------------------------------------|----------------------------------------------| +| Test with existing version | `gradle release -PbundleVersion=2.4.62` | Should fetch from remote apache.properties | +| Test with new version | Build a version recently added to remote | Should fetch from remote apache.properties | +| Test network error handling | Disconnect network, build version | Should show appropriate error message | +| Test fallback mechanism | Build version not in apache.properties | Should try direct archive detection | + +## Maintenance + +### Adding New Versions + +To add a new Apache version, use one of these methods: + +| Option | Method | Steps | Scope | +|--------|-------------------------------------------|--------------------------------------------------------------|--------------| +| 1 | Add to remote apache.properties (Recommended) | Edit `modules/apache.properties`, add version, commit | All builds | +| 2 | Upload to modules-untouched repository | Create `apache2.4.XX/` directory, upload binaries | All builds | + +**Option 1 Details (Recommended):** +1. Edit `modules/apache.properties` in modules-untouched repository +2. Add line: `2.4.XX = https://download-url-here` +3. Commit and push +4. Version is now immediately available to all builds + +**Option 2 Details:** +1. Create directory: `apache2.4.XX/` in modules-untouched repository +2. Upload Apache binaries (as .7z or .zip archive) +3. Version can be auto-discovered by the build system + +**Note:** The local `releases.properties` file has been removed. All version management is now centralized in the modules-untouched repository. + +## Related Files + +| File/Resource | Description | +|----------------------------------|------------------------------------------------------------------------------| +| `build.gradle` | Contains the implementation | +| Remote apache.properties | https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties | +| modules-untouched repository | https://github.com/Bearsampp/modules-untouched | + +**Note:** The `releases.properties` file has been removed as of the latest update. + +## See Also + +| Document | Description | +|----------------------------------|------------------------------------------------------------------------------| +| [GRADLE_UPDATES.md](GRADLE_UPDATES.md) | General Gradle updates | +| [CHANGES_SUMMARY.md](CHANGES_SUMMARY.md) | Summary of all changes | +| [modules-untouched repository](https://github.com/Bearsampp/modules-untouched) | Source repository | diff --git a/README.md b/README.md index 0274f4f3..df278c76 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,223 @@ [![GitHub release](https://img.shields.io/github/release/bearsampp/module-apache.svg?style=flat-square)](https://github.com/bearsampp/module-apache/releases/latest) ![Total downloads](https://img.shields.io/github/downloads/bearsampp/module-apache/total.svg?style=flat-square) -This is a module of [Bearsampp project](https://github.com/bearsampp/bearsampp) involving Apache. +# Bearsampp Module - Apache -## Documentation and downloads +This is a module of [Bearsampp project](https://github.com/bearsampp/bearsampp) involving Apache HTTP Server. -https://bearsampp.com/module/apache +## Build System + +This module uses **Gradle** as its build system. The Gradle build provides: + +- ✅ Pure Gradle build (no Ant dependencies) +- ✅ Automatic Apache binary download and extraction +- ✅ Remote version discovery from modules-untouched repository +- ✅ Interactive and non-interactive build modes +- ✅ Support for archived versions +- ✅ Configurable build paths +- ✅ Hash file generation (MD5, SHA1, SHA256, SHA512) +- ✅ 7-Zip and ZIP archive formats + +## Quick Start + +### Prerequisites + +- Java 8 or higher +- Gradle (or use the included wrapper) +- 7-Zip (for .7z format archives) + +### Build Commands + +```bash +# Display build information +gradle info + +# List available versions +gradle listVersions + +# Build a specific version +gradle release -PbundleVersion=2.4.62 + +# Build all versions +gradle releaseAll + +# Verify build environment +gradle verify + +# Clean build artifacts +gradle clean +``` + +## Documentation + +**For detailed build instructions and documentation, see [.gradle-docs/README.md](.gradle-docs/README.md)** + +Additional documentation: + +| Document | Description | +|-------------------------------------------------------------------|------------------------------------------------| +| [README.md](.gradle-docs/README.md) | Complete build documentation and guide | +| [GRADLE_UPDATES.md](.gradle-docs/GRADLE_UPDATES.md) | Detailed build system updates | +| [CHANGES_SUMMARY.md](.gradle-docs/CHANGES_SUMMARY.md) | Summary of all changes | +| [GRADLE_TMP_PATHS.md](.gradle-docs/GRADLE_TMP_PATHS.md) | Build path structure details | +| [CHANGES_TMP_PATHS.md](.gradle-docs/CHANGES_TMP_PATHS.md) | Temporary paths configuration | +| [REMOTE_PROPERTIES_SUPPORT.md](.gradle-docs/REMOTE_PROPERTIES_SUPPORT.md) | Remote version discovery | +| [MODULES_UNTOUCHED_INTEGRATION.md](.gradle-docs/MODULES_UNTOUCHED_INTEGRATION.md) | Integration guide | +| [CHANGELOG.md](.gradle-docs/CHANGELOG.md) | Complete changelog | + +## Configuration + +### build.properties + +Configure the module build settings: + +```properties +bundle.name = apache +bundle.release = 2025.8.15 +bundle.type = bins +bundle.format = 7z +``` + +| Property | Description | Example Value | +|-------------------|--------------------------------------|----------------| +| `bundle.name` | Name of the bundle | `apache` | +| `bundle.release` | Release version | `2025.8.15` | +| `bundle.type` | Type of bundle | `bins` | +| `bundle.format` | Archive format (7z or zip) | `7z` | + +### Build Path Configuration + +You can configure the build output path in three ways (priority order): + +1. **In build.properties:** + ```properties + build.path = C:/Bearsampp-build + ``` + +2. **Environment variable:** + ```bash + set BEARSAMPP_BUILD_PATH=C:/Bearsampp-build + ``` + +3. **Default:** Uses `../bearsampp-build` relative to project root + +## Version Management + +### Available Versions + +Versions are detected from: +- `bin/` - Current/active versions +- `bin/archived/` - Archived/older versions +- `modules-untouched` - Remote repository (automatic discovery) + +### Version Resolution Strategy + +When building, the system checks for Apache binaries in this order: + +1. **Local `bin/` directory** - Check for version folder +2. **Local `bin/archived/` directory** - Check archived versions +3. **Remote `apache.properties`** - Fetch from modules-untouched repository +4. **Direct repository download** - Download from modules-untouched GitHub + +This multi-tier fallback strategy ensures maximum flexibility and automatic version discovery without manual configuration. + +**Example:** +```bash +# List local versions +gradle listVersions + +# List remote versions +gradle listReleases + +# Check integration +gradle checkModulesUntouched +``` + +## Output Structure + +Build artifacts are created in the `bearsampp-build` directory: + +``` +bearsampp-build/ +├── bins/apache/{release}/ # Final packaged archives +│ ├── bearsampp-apache-{version}-{release}.7z +│ ├── bearsampp-apache-{version}-{release}.7z.md5 +│ ├── bearsampp-apache-{version}-{release}.7z.sha1 +│ ├── bearsampp-apache-{version}-{release}.7z.sha256 +│ └── bearsampp-apache-{version}-{release}.7z.sha512 +└── tmp/ # Temporary build files + ├── bundles_prep/bins/apache/ # Prepared bundles + ├── bundles_build/bins/apache/ # Build staging + ├── bundles_src/ # Source bundles + ├── downloads/apache/ # Downloaded dependencies + └── extract/apache/ # Extracted archives +``` + +**Archive Structure:** +Each archive contains the Apache version folder at the root: +``` +bearsampp-apache-2.4.62-2025.8.15.7z +└── apache2.4.62/ ← Version folder at root + ├── bin/ + ├── conf/ + ├── modules/ + └── ... +``` + +## Features + +### Interactive Mode + +Run `gradle release` without parameters for interactive version selection: + +```bash +gradle release +``` + +The system will display all available versions with location tags `[bin]` or `[bin/archived]` and prompt you to select one. + +### Batch Building + +Build all available versions at once: + +```bash +gradle releaseAll +``` + +This will iterate through all versions in `bin/` and `bin/archived/` directories and build each one. + +### Remote Version Discovery + +The build system automatically discovers new Apache versions from the modules-untouched repository: + +- Fetches version information from `apache.properties` +- Downloads binaries automatically when not found locally +- No manual configuration required for new versions +- Fallback to direct repository access if needed + +**Check integration:** +```bash +gradle checkModulesUntouched +``` + +## Downloads + +Official module downloads are available at: + +**https://bearsampp.com/module/apache** ## Issues Issues must be reported on [Bearsampp repository](https://github.com/bearsampp/bearsampp/issues). +## Contributing + +Contributions are welcome! Please see the [Bearsampp contribution guidelines](https://bearsampp.com/contribute). + ## Statistics + ![Alt](https://repobeats.axiom.co/api/embed/9382037dc5be402bf4d32075c26f836b80ba253c.svg "Repobeats analytics image") + +## License + +This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details. diff --git a/bin/apache2.4.41/bearsampp.conf b/bin/archived/apache2.4.41/bearsampp.conf similarity index 100% rename from bin/apache2.4.41/bearsampp.conf rename to bin/archived/apache2.4.41/bearsampp.conf diff --git a/bin/apache2.4.41/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.41/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.41/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.41/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.41/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.41/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.41/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.41/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.41/conf/httpd.conf b/bin/archived/apache2.4.41/conf/httpd.conf similarity index 100% rename from bin/apache2.4.41/conf/httpd.conf rename to bin/archived/apache2.4.41/conf/httpd.conf diff --git a/bin/apache2.4.41/conf/httpd.conf.ber b/bin/archived/apache2.4.41/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.41/conf/httpd.conf.ber rename to bin/archived/apache2.4.41/conf/httpd.conf.ber diff --git a/bin/apache2.4.41/modules.properties b/bin/archived/apache2.4.41/modules.properties similarity index 100% rename from bin/apache2.4.41/modules.properties rename to bin/archived/apache2.4.41/modules.properties diff --git a/bin/apache2.4.51/bearsampp.conf b/bin/archived/apache2.4.51/bearsampp.conf similarity index 100% rename from bin/apache2.4.51/bearsampp.conf rename to bin/archived/apache2.4.51/bearsampp.conf diff --git a/bin/apache2.4.51/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.51/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.51/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.51/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.51/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.51/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.51/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.51/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.51/conf/httpd.conf b/bin/archived/apache2.4.51/conf/httpd.conf similarity index 100% rename from bin/apache2.4.51/conf/httpd.conf rename to bin/archived/apache2.4.51/conf/httpd.conf diff --git a/bin/apache2.4.51/conf/httpd.conf.ber b/bin/archived/apache2.4.51/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.51/conf/httpd.conf.ber rename to bin/archived/apache2.4.51/conf/httpd.conf.ber diff --git a/bin/apache2.4.51/modules.properties b/bin/archived/apache2.4.51/modules.properties similarity index 100% rename from bin/apache2.4.51/modules.properties rename to bin/archived/apache2.4.51/modules.properties diff --git a/bin/apache2.4.52/bearsampp.conf b/bin/archived/apache2.4.52/bearsampp.conf similarity index 100% rename from bin/apache2.4.52/bearsampp.conf rename to bin/archived/apache2.4.52/bearsampp.conf diff --git a/bin/apache2.4.52/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.52/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.52/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.52/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.52/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.52/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.52/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.52/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.52/conf/httpd.conf b/bin/archived/apache2.4.52/conf/httpd.conf similarity index 100% rename from bin/apache2.4.52/conf/httpd.conf rename to bin/archived/apache2.4.52/conf/httpd.conf diff --git a/bin/apache2.4.52/conf/httpd.conf.ber b/bin/archived/apache2.4.52/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.52/conf/httpd.conf.ber rename to bin/archived/apache2.4.52/conf/httpd.conf.ber diff --git a/bin/apache2.4.52/modules.properties b/bin/archived/apache2.4.52/modules.properties similarity index 100% rename from bin/apache2.4.52/modules.properties rename to bin/archived/apache2.4.52/modules.properties diff --git a/bin/apache2.4.54/bearsampp.conf b/bin/archived/apache2.4.54/bearsampp.conf similarity index 100% rename from bin/apache2.4.54/bearsampp.conf rename to bin/archived/apache2.4.54/bearsampp.conf diff --git a/bin/apache2.4.54/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.54/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.54/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.54/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.54/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.54/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.54/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.54/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.54/conf/httpd.conf b/bin/archived/apache2.4.54/conf/httpd.conf similarity index 100% rename from bin/apache2.4.54/conf/httpd.conf rename to bin/archived/apache2.4.54/conf/httpd.conf diff --git a/bin/apache2.4.54/conf/httpd.conf.ber b/bin/archived/apache2.4.54/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.54/conf/httpd.conf.ber rename to bin/archived/apache2.4.54/conf/httpd.conf.ber diff --git a/bin/apache2.4.54/modules.properties b/bin/archived/apache2.4.54/modules.properties similarity index 100% rename from bin/apache2.4.54/modules.properties rename to bin/archived/apache2.4.54/modules.properties diff --git a/bin/apache2.4.55/bearsampp.conf b/bin/archived/apache2.4.55/bearsampp.conf similarity index 100% rename from bin/apache2.4.55/bearsampp.conf rename to bin/archived/apache2.4.55/bearsampp.conf diff --git a/bin/apache2.4.55/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.55/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.55/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.55/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.55/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.55/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.55/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.55/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.55/conf/httpd.conf b/bin/archived/apache2.4.55/conf/httpd.conf similarity index 100% rename from bin/apache2.4.55/conf/httpd.conf rename to bin/archived/apache2.4.55/conf/httpd.conf diff --git a/bin/apache2.4.55/conf/httpd.conf.ber b/bin/archived/apache2.4.55/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.55/conf/httpd.conf.ber rename to bin/archived/apache2.4.55/conf/httpd.conf.ber diff --git a/bin/apache2.4.55/modules.properties b/bin/archived/apache2.4.55/modules.properties similarity index 100% rename from bin/apache2.4.55/modules.properties rename to bin/archived/apache2.4.55/modules.properties diff --git a/bin/apache2.4.57/bearsampp.conf b/bin/archived/apache2.4.57/bearsampp.conf similarity index 100% rename from bin/apache2.4.57/bearsampp.conf rename to bin/archived/apache2.4.57/bearsampp.conf diff --git a/bin/apache2.4.57/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.57/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.57/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.57/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.57/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.57/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.57/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.57/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.57/conf/httpd.conf b/bin/archived/apache2.4.57/conf/httpd.conf similarity index 100% rename from bin/apache2.4.57/conf/httpd.conf rename to bin/archived/apache2.4.57/conf/httpd.conf diff --git a/bin/apache2.4.57/conf/httpd.conf.ber b/bin/archived/apache2.4.57/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.57/conf/httpd.conf.ber rename to bin/archived/apache2.4.57/conf/httpd.conf.ber diff --git a/bin/apache2.4.57/modules.properties b/bin/archived/apache2.4.57/modules.properties similarity index 100% rename from bin/apache2.4.57/modules.properties rename to bin/archived/apache2.4.57/modules.properties diff --git a/bin/apache2.4.58/bearsampp.conf b/bin/archived/apache2.4.58/bearsampp.conf similarity index 100% rename from bin/apache2.4.58/bearsampp.conf rename to bin/archived/apache2.4.58/bearsampp.conf diff --git a/bin/apache2.4.58/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.58/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.58/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.58/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.58/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.58/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.58/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.58/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.58/conf/httpd.conf b/bin/archived/apache2.4.58/conf/httpd.conf similarity index 100% rename from bin/apache2.4.58/conf/httpd.conf rename to bin/archived/apache2.4.58/conf/httpd.conf diff --git a/bin/apache2.4.58/conf/httpd.conf.ber b/bin/archived/apache2.4.58/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.58/conf/httpd.conf.ber rename to bin/archived/apache2.4.58/conf/httpd.conf.ber diff --git a/bin/apache2.4.58/modules.properties b/bin/archived/apache2.4.58/modules.properties similarity index 100% rename from bin/apache2.4.58/modules.properties rename to bin/archived/apache2.4.58/modules.properties diff --git a/bin/apache2.4.59/bearsampp.conf b/bin/archived/apache2.4.59/bearsampp.conf similarity index 100% rename from bin/apache2.4.59/bearsampp.conf rename to bin/archived/apache2.4.59/bearsampp.conf diff --git a/bin/apache2.4.59/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.59/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.59/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.59/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.59/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.59/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.59/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.59/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.59/conf/httpd.conf b/bin/archived/apache2.4.59/conf/httpd.conf similarity index 100% rename from bin/apache2.4.59/conf/httpd.conf rename to bin/archived/apache2.4.59/conf/httpd.conf diff --git a/bin/apache2.4.59/conf/httpd.conf.ber b/bin/archived/apache2.4.59/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.59/conf/httpd.conf.ber rename to bin/archived/apache2.4.59/conf/httpd.conf.ber diff --git a/bin/apache2.4.59/modules.properties b/bin/archived/apache2.4.59/modules.properties similarity index 100% rename from bin/apache2.4.59/modules.properties rename to bin/archived/apache2.4.59/modules.properties diff --git a/bin/apache2.4.62/bearsampp.conf b/bin/archived/apache2.4.62/bearsampp.conf similarity index 100% rename from bin/apache2.4.62/bearsampp.conf rename to bin/archived/apache2.4.62/bearsampp.conf diff --git a/bin/apache2.4.62/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.62/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.62/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.62/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.62/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.62/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.62/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.62/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.62/conf/httpd.conf b/bin/archived/apache2.4.62/conf/httpd.conf similarity index 100% rename from bin/apache2.4.62/conf/httpd.conf rename to bin/archived/apache2.4.62/conf/httpd.conf diff --git a/bin/apache2.4.62/conf/httpd.conf.ber b/bin/archived/apache2.4.62/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.62/conf/httpd.conf.ber rename to bin/archived/apache2.4.62/conf/httpd.conf.ber diff --git a/bin/apache2.4.62/modules.properties b/bin/archived/apache2.4.62/modules.properties similarity index 100% rename from bin/apache2.4.62/modules.properties rename to bin/archived/apache2.4.62/modules.properties diff --git a/bin/apache2.4.63/bearsampp.conf b/bin/archived/apache2.4.63/bearsampp.conf similarity index 100% rename from bin/apache2.4.63/bearsampp.conf rename to bin/archived/apache2.4.63/bearsampp.conf diff --git a/bin/apache2.4.63/conf/extra/httpd-ssl.conf b/bin/archived/apache2.4.63/conf/extra/httpd-ssl.conf similarity index 100% rename from bin/apache2.4.63/conf/extra/httpd-ssl.conf rename to bin/archived/apache2.4.63/conf/extra/httpd-ssl.conf diff --git a/bin/apache2.4.63/conf/extra/httpd-ssl.conf.ber b/bin/archived/apache2.4.63/conf/extra/httpd-ssl.conf.ber similarity index 100% rename from bin/apache2.4.63/conf/extra/httpd-ssl.conf.ber rename to bin/archived/apache2.4.63/conf/extra/httpd-ssl.conf.ber diff --git a/bin/apache2.4.63/conf/httpd.conf b/bin/archived/apache2.4.63/conf/httpd.conf similarity index 100% rename from bin/apache2.4.63/conf/httpd.conf rename to bin/archived/apache2.4.63/conf/httpd.conf diff --git a/bin/apache2.4.63/conf/httpd.conf.ber b/bin/archived/apache2.4.63/conf/httpd.conf.ber similarity index 100% rename from bin/apache2.4.63/conf/httpd.conf.ber rename to bin/archived/apache2.4.63/conf/httpd.conf.ber diff --git a/bin/apache2.4.63/modules.properties b/bin/archived/apache2.4.63/modules.properties similarity index 100% rename from bin/apache2.4.63/modules.properties rename to bin/archived/apache2.4.63/modules.properties diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..24b0149a --- /dev/null +++ b/build.gradle @@ -0,0 +1,1404 @@ +/* + * Bearsampp Module Apache - Gradle Build + * + * Pure Gradle build configuration for Apache module packaging. + * This build script handles downloading, extracting, and packaging Apache binaries + * along with custom modules and configurations. + * + * Usage: + * gradle tasks - List all available tasks + * gradle info - Display build information + * gradle release -PbundleVersion=2.4.62 - Build release for specific version + * gradle clean - Clean build artifacts + * 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', 'apache')}" + +// Define project paths +ext { + projectBasedir = projectDir.absolutePath + rootDir = projectDir.parent + devPath = file("${rootDir}/dev").absolutePath + buildPropertiesFile = file('build.properties').absolutePath + + // Bundle properties from build.properties + bundleName = buildProps.getProperty('bundle.name', 'apache') + bundleRelease = buildProps.getProperty('bundle.release', '1.0.0') + bundleType = buildProps.getProperty('bundle.type', 'bins') + 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()) { + throw new GradleException("Dev path not found: ${ext.devPath}. Please ensure the 'dev' project exists in ${ext.rootDir}") +} + +// Configure repositories for dependencies +repositories { + mavenCentral() +} + +// ============================================================================ +// HELPER FUNCTIONS +// ============================================================================ + +// Function to fetch modules-untouched apache.properties +def fetchModulesUntouchedProperties() { + def propsUrl = "https://raw.githubusercontent.com/Bearsampp/modules-untouched/main/modules/apache.properties" + + try { + def connection = new URL(propsUrl).openConnection() + connection.setConnectTimeout(10000) + connection.setReadTimeout(10000) + + def props = new Properties() + connection.inputStream.withStream { stream -> + props.load(stream) + } + + return props + } catch (Exception e) { + println " Warning: Could not fetch modules-untouched apache.properties: ${e.message}" + return null + } +} + +// Function to download from modules-untouched GitHub repository +def downloadFromModulesUntouched(String version) { + println "Checking modules-untouched repository on GitHub..." + + // First, try to get the URL from apache.properties + def untouchedProps = fetchModulesUntouchedProperties() + def downloadUrl = untouchedProps?.getProperty(version) + + if (downloadUrl) { + println " Found version ${version} in modules-untouched apache.properties" + println " URL: ${downloadUrl}" + + def downloadDir = file(bundleTmpDownloadPath) + def extractDir = file(bundleTmpExtractPath) + downloadDir.mkdirs() + extractDir.mkdirs() + + // Determine filename from URL + def filename = downloadUrl.substring(downloadUrl.lastIndexOf('/') + 1) + def downloadedFile = file("${downloadDir}/modules-untouched-${filename}") + + // Download the archive if not already cached + if (!downloadedFile.exists()) { + println " Downloading from modules-untouched: ${downloadUrl}" + try { + new URL(downloadUrl).withInputStream { input -> + downloadedFile.withOutputStream { output -> + output << input + } + } + println " Download complete" + } catch (Exception e) { + println " Download failed: ${e.message}" + return null + } + } else { + println " Using cached file: ${downloadedFile.name}" + } + + // Extract the archive + println " Extracting archive..." + def extractPath = file("${extractDir}/modules-untouched-${version}") + if (extractPath.exists()) { + delete extractPath + } + extractPath.mkdirs() + + // Use 7zip or built-in extraction + if (filename.endsWith('.7z')) { + def sevenZipPath = find7ZipExecutable() + if (sevenZipPath) { + println " Using 7zip: ${sevenZipPath}" + def command = [ + sevenZipPath.toString(), + 'x', + downloadedFile.absolutePath.toString(), + "-o${extractPath.absolutePath}".toString(), + '-y' + ] + def process = new ProcessBuilder(command as String[]) + .directory(extractPath) + .redirectErrorStream(true) + .start() + + process.inputStream.eachLine { line -> + println " ${line}" + } + + def exitCode = process.waitFor() + if (exitCode != 0) { + println " 7zip extraction failed" + return null + } + } else { + println " 7-Zip not found, cannot extract .7z file" + return null + } + } else if (filename.endsWith('.zip')) { + copy { + from zipTree(downloadedFile) + into extractPath + } + } else { + println " Unsupported archive format: ${filename}" + return null + } + + println " Extraction complete" + + // Find the Apache directory in the extracted files + def apacheDir = findApacheDirectory(extractPath) + if (!apacheDir) { + println " Could not find Apache directory in extracted files" + return null + } + + println " Found Apache directory: ${apacheDir.name}" + println " Apache ${version} from modules-untouched ready at: ${apacheDir.absolutePath}" + + return apacheDir + } + + // Fallback: Try to detect the archive file by checking common patterns + def githubBaseUrl = "https://github.com/Bearsampp/modules-untouched/raw/main/apache${version}" + + def possibleArchives = [ + "bearsampp-apache-${version}.7z", + "apache-${version}.7z", + "apache${version}.7z", + "bearsampp-apache-${version}.zip", + "apache-${version}.zip", + "apache${version}.zip" + ] + + def downloadDir = file(bundleTmpDownloadPath) + def extractDir = file(bundleTmpExtractPath) + downloadDir.mkdirs() + extractDir.mkdirs() + + def downloadedFile = null + def archiveUrl = null + + // Try to find which archive exists + for (archiveName in possibleArchives) { + def testUrl = "${githubBaseUrl}/${archiveName}" + println " Checking: ${testUrl}" + + try { + // Test if URL exists by attempting a HEAD request + def connection = new URL(testUrl).openConnection() + connection.setRequestMethod("HEAD") + connection.setConnectTimeout(5000) + connection.setReadTimeout(5000) + + def responseCode = connection.getResponseCode() + if (responseCode == 200) { + archiveUrl = testUrl + downloadedFile = file("${downloadDir}/modules-untouched-${archiveName}") + println " Found: ${archiveName}" + break + } + } catch (Exception e) { + // URL doesn't exist, try next + } + } + + if (!archiveUrl) { + println " Apache ${version} not found in modules-untouched repository" + return null + } + + // Download the archive if not already cached + if (!downloadedFile.exists()) { + println " Downloading from modules-untouched: ${archiveUrl}" + try { + new URL(archiveUrl).withInputStream { input -> + downloadedFile.withOutputStream { output -> + output << input + } + } + println " Download complete" + } catch (Exception e) { + println " Download failed: ${e.message}" + return null + } + } else { + println " Using cached file: ${downloadedFile.name}" + } + + // Extract the archive + println " Extracting archive..." + def extractPath = file("${extractDir}/modules-untouched-${version}") + if (extractPath.exists()) { + delete extractPath + } + extractPath.mkdirs() + + def filename = downloadedFile.name + + // Use 7zip or built-in extraction + if (filename.endsWith('.7z')) { + def sevenZipPath = find7ZipExecutable() + if (sevenZipPath) { + println " Using 7zip: ${sevenZipPath}" + def command = [ + sevenZipPath.toString(), + 'x', + downloadedFile.absolutePath.toString(), + "-o${extractPath.absolutePath}".toString(), + '-y' + ] + def process = new ProcessBuilder(command as String[]) + .directory(extractPath) + .redirectErrorStream(true) + .start() + + process.inputStream.eachLine { line -> + println " ${line}" + } + + def exitCode = process.waitFor() + if (exitCode != 0) { + println " 7zip extraction failed" + return null + } + } else { + println " 7-Zip not found, cannot extract .7z file" + return null + } + } else if (filename.endsWith('.zip')) { + copy { + from zipTree(downloadedFile) + into extractPath + } + } else { + println " Unsupported archive format: ${filename}" + return null + } + + println " Extraction complete" + + // Find the Apache directory in the extracted files + def apacheDir = findApacheDirectory(extractPath) + if (!apacheDir) { + println " Could not find Apache directory in extracted files" + return null + } + + println " Found Apache directory: ${apacheDir.name}" + println " Apache ${version} from modules-untouched ready at: ${apacheDir.absolutePath}" + + return apacheDir +} + +// 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 +} + +// Function to find Apache directory in extracted files +def findApacheDirectory(File extractPath) { + // Look for Apache directory (case-insensitive, various formats) + def apacheDirs = extractPath.listFiles()?.findAll { + it.isDirectory() && ( + it.name == 'Apache24' || + it.name == 'Apache2.4' || + it.name.toLowerCase().startsWith('apache') + ) + } + + if (apacheDirs && !apacheDirs.isEmpty()) { + // Prefer Apache24 or Apache2.4 if they exist + def preferred = apacheDirs.find { it.name == 'Apache24' || it.name == 'Apache2.4' } + return preferred ?: apacheDirs[0] + } + + // If not found at top level, search one level deep + def foundDir = null + extractPath.listFiles()?.each { dir -> + if (dir.isDirectory() && !foundDir) { + def subDirs = dir.listFiles()?.findAll { + it.isDirectory() && ( + it.name == 'Apache24' || + it.name == 'Apache2.4' || + it.name.toLowerCase().startsWith('apache') + ) + } + if (subDirs && !subDirs.isEmpty()) { + foundDir = subDirs[0] + } + } + } + + return foundDir +} + +// 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() +} + +// ============================================================================ +// GRADLE NATIVE TASKS +// ============================================================================ + +// Task: Display build information +tasks.register('info') { + group = 'help' + description = 'Display build configuration information' + + // Capture values at configuration time to avoid deprecation warnings + 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 bundleTmpPrepPathValue = bundleTmpPrepPath + def bundleTmpBuildPathValue = bundleTmpBuildPath + def bundleTmpSrcPathValue = bundleTmpSrcPath + def bundleTmpDownloadPathValue = bundleTmpDownloadPath + def bundleTmpExtractPathValue = bundleTmpExtractPath + def javaVersion = JavaVersion.current() + def javaHome = System.getProperty('java.home') + def gradleVersion = gradle.gradleVersion + def gradleHome = gradle.gradleHomeDir + + doLast { + println """ + ================================================================ + Bearsampp Module Apache - 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 Tmp: ${buildTmpPathValue} + Tmp Prep: ${bundleTmpPrepPathValue} + Tmp Build: ${bundleTmpBuildPathValue} + Tmp Src: ${bundleTmpSrcPathValue} + Tmp Download: ${bundleTmpDownloadPathValue} + Tmp Extract: ${bundleTmpExtractPathValue} + + Java: + Version: ${javaVersion} + Home: ${javaHome} + + Gradle: + Version: ${gradleVersion} + Home: ${gradleHome} + + 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 listVersions - List available versions + gradle release -PbundleVersion=2.4.62 - Build release for version + gradle releaseAll - Build all available 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 (use -PbundleVersion=X.X.X to specify version)' + + // Capture property at configuration time to avoid deprecation warning + def bundleVersionProperty = project.findProperty('bundleVersion') + + doLast { + def versionToBuild = bundleVersionProperty + + // Interactive mode if no version specified + if (!versionToBuild) { + def versions = getAvailableVersions() + + if (versions.isEmpty()) { + throw new GradleException("No versions found in bin/ or bin/archived/ directories") + } + + println "" + println "=".multiply(70) + println "Available ${bundleName} versions:" + println "=".multiply(70) + + // Show versions with location tags + def binDir = file("${projectDir}/bin") + def archivedDir = file("${projectDir}/bin/archived") + + versions.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 "=".multiply(70) + println "" + println "Enter version number or full 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: ${versions.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: ${versions.join(', ')} + """.stripIndent()) + } + + input = input.trim() + + // Check if input is a number (index selection) + if (input.isInteger()) { + def index = input.toInteger() - 1 + if (index >= 0 && index < versions.size()) { + versionToBuild = versions[index] + } else { + throw new GradleException("Invalid selection: ${input}. Please choose 1-${versions.size()}") + } + } else { + // Direct version string + versionToBuild = input + } + + println "" + println "Selected version: ${versionToBuild}" + } + + println "=".multiply(70) + println "Building release for ${bundleName} version ${versionToBuild}..." + println "=".multiply(70) + + // 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 allVersions = getAvailableVersions() + def availableVersionsList = allVersions.collect { + " - ${it}" + }.join('\n') ?: " (none found)" + + throw new GradleException(""" + Bundle version not found: ${bundleName}${versionToBuild} + + Available versions: + ${availableVersionsList} + """.stripIndent()) + } + + println "Bundle path: ${bundlePath}" + println "" + + // Get the untouched module source + def bundleFolder = bundlePath.name + def bundleVersion = bundleFolder.replace(bundleName, '') + + // Determine source paths - check bin directory first, then build directory + def bundleSrcDest = bundlePath + def bundleSrcFinal = null + + if (file("${bundleSrcDest}/Apache24").exists()) { + bundleSrcFinal = file("${bundleSrcDest}/Apache24") + } else if (file("${bundleSrcDest}/Apache2.4").exists()) { + bundleSrcFinal = file("${bundleSrcDest}/Apache2.4") + } else { + // Apache binaries not found in bin/ - check modules-untouched repository + println "" + println "Apache binaries not found in bin/ directory" + println "Checking modules-untouched repository..." + + def untouchedDir = downloadFromModulesUntouched(bundleVersion) + if (untouchedDir) { + println "Using Apache ${bundleVersion} from modules-untouched repository" + bundleSrcFinal = untouchedDir + } else { + throw new GradleException(""" + Failed to obtain Apache binaries for version ${bundleVersion} + + You can manually: + 1. Download and extract Apache binaries to: ${bundleSrcDest}/Apache24/ + 2. Add version ${bundleVersion} to https://github.com/Bearsampp/modules-untouched/blob/main/modules/apache.properties + 3. Upload Apache binaries to: https://github.com/Bearsampp/modules-untouched/tree/main/apache${bundleVersion}/ + """.stripIndent()) + } + } + + def httpdExe = file("${bundleSrcFinal}/bin/httpd.exe") + if (!httpdExe.exists()) { + throw new GradleException("httpd.exe not found at ${httpdExe}") + } + + println "Source folder: ${bundleSrcFinal}" + println "" + + // Prepare output directory + def apachePrepPath = file("${bundleTmpPrepPath}/${bundleName}${bundleVersion}") + if (apachePrepPath.exists()) { + delete apachePrepPath + } + apachePrepPath.mkdirs() + + // Copy readme if exists + def readmeFile = file("${bundleSrcDest}/readme_first.html") + if (readmeFile.exists()) { + copy { + from readmeFile + into apachePrepPath + } + } + + // Copy Apache files (excluding certain directories) + println "Copying Apache files..." + copy { + from bundleSrcFinal + into apachePrepPath + exclude 'cgi-bin/**' + exclude 'conf/original/**' + exclude 'conf/ssl/**' + exclude 'error/**' + exclude 'htdocs/**' + exclude 'icons/**' + exclude 'include/**' + exclude 'lib/**' + exclude 'logs/*' + exclude 'tools/**' + } + + // Copy bundle customizations + println "Copying bundle customizations..." + copy { + from bundlePath + into apachePrepPath + exclude 'Apache24/**' + exclude 'Apache2.4/**' + exclude 'readme_first.html' + } + + // Process modules if modules.properties exists + def modulesFile = file("${apachePrepPath}/modules.properties") + if (modulesFile.exists()) { + println "" + println "Processing modules..." + + def modules = new Properties() + modulesFile.withInputStream { modules.load(it) } + + def modulesContent = new StringBuilder() + + modules.each { moduleName, moduleUrl -> + println " Processing module: ${moduleName}" + + // Extract version from URL (if present) + def versionMatch = (moduleUrl =~ /apache-.*-.*-(.*)/) + def moduleVersion = versionMatch ? versionMatch[0][1] : 'unknown' + + // Download module (simulated - in real implementation would download) + // For now, we'll just document what would happen + println " URL: ${moduleUrl}" + println " Version: ${moduleVersion}" + + // Add to modules content for httpd.conf injection + modulesContent.append("#LoadModule ${moduleName}_module modules/mod_${moduleName}.so\n") + } + + // Inject modules into httpd.conf + def httpdConf = file("${bundlePath}/conf/httpd.conf") + def httpdConfBer = file("${bundlePath}/conf/httpd.conf.ber") + + if (httpdConf.exists()) { + println "" + println "Injecting modules into httpd.conf..." + def confContent = httpdConf.text.replace('@APACHE_MODULES@', modulesContent.toString()) + file("${apachePrepPath}/conf/httpd.conf").text = confContent + } + + if (httpdConfBer.exists()) { + println "Injecting modules into httpd.conf.ber..." + def confContent = httpdConfBer.text.replace('@APACHE_MODULES@', modulesContent.toString()) + file("${apachePrepPath}/conf/httpd.conf.ber").text = confContent + } + + // Remove modules.properties from output + modulesFile.delete() + } + + println "" + println "Copying to bundles_build directory..." + def apacheBuildPath = file("${bundleTmpBuildPath}/${bundleName}${bundleVersion}") + if (apacheBuildPath.exists()) { + delete apacheBuildPath + } + apacheBuildPath.mkdirs() + + copy { + from apachePrepPath + into apacheBuildPath + } + println "Non-zip version available at: ${apacheBuildPath}" + + println "" + println "Preparing archive..." + + // Determine build output path following Bruno pattern + // bearsampp-build/{bundleType}/{bundleName}/{bundleRelease} + def buildPath = file(buildBasePath) + def buildBinsPath = file("${buildPath}/${bundleType}/${bundleName}/${bundleRelease}") + buildBinsPath.mkdirs() + + // Build archive filename + def destFile = file("${buildBinsPath}/bearsampp-${bundleName}-${bundleVersion}-${bundleRelease}") + + // Compress based on format + if (bundleFormat == '7z') { + // 7z format + def archiveFile = file("${destFile}.7z") + if (archiveFile.exists()) { + delete archiveFile + } + + println "Compressing ${bundleName}${bundleVersion} to ${archiveFile.name}..." + + // Find 7z executable + def sevenZipExe = find7ZipExecutable() + if (!sevenZipExe) { + throw new GradleException("7-Zip not found. Please install 7-Zip or set 7Z_HOME environment variable.") + } + + println "Using 7-Zip: ${sevenZipExe}" + + // Create 7z archive, including the top-level version folder (e.g., apache2.4.65/) + // Switch working directory to the parent of apachePrepPath and add the folder name itself + def command = [ + sevenZipExe, + 'a', + '-t7z', + archiveFile.absolutePath.toString(), + "${bundleName}${bundleVersion}" + ] + + 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) + + } else { + // ZIP format + def archiveFile = file("${destFile}.zip") + if (archiveFile.exists()) { + delete archiveFile + } + + println "Compressing ${bundleName}${bundleVersion} to ${archiveFile.name}..." + + // Create ZIP archive using Gradle's built-in zip functionality, including the top-level version folder + task("zipArchive_${bundleVersion}", type: Zip) { + from(apachePrepPath) { + into "${bundleName}${bundleVersion}" + } + destinationDirectory = archiveFile.parentFile + archiveFileName = archiveFile.name + }.execute() + + 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: ${buildBinsPath}" + println "Archive: ${destFile}.${bundleFormat}" + println "=".multiply(70) + } +} + +// Task: Build all available versions +tasks.register('releaseAll') { + group = 'build' + description = 'Build release packages for all available versions in bin/ directory' + + doLast { + def binDir = file("${projectDir}/bin") + if (!binDir.exists()) { + throw new GradleException("bin/ directory not found") + } + + 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 the release task logic for this version + def bundlePath = file("${projectDir}/bin/${bundleName}${version}") + + if (!bundlePath.exists()) { + bundlePath = file("${projectDir}/bin/archived/${bundleName}${version}") + } + + if (!bundlePath.exists()) { + throw new GradleException("Bundle path not found: ${bundlePath}") + } + + println "Bundle path: ${bundlePath}" + println "" + + // Get the untouched module source + def bundleFolder = bundlePath.name + def bundleVersion = bundleFolder.replace(bundleName, '') + + // Determine source paths + def bundleSrcDest = bundlePath + def bundleSrcFinal = null + + if (file("${bundleSrcDest}/Apache24").exists()) { + bundleSrcFinal = file("${bundleSrcDest}/Apache24") + } else if (file("${bundleSrcDest}/Apache2.4").exists()) { + bundleSrcFinal = file("${bundleSrcDest}/Apache2.4") + } else { + throw new GradleException("Main folder not found in ${bundleSrcDest}") + } + + def httpdExe = file("${bundleSrcFinal}/bin/httpd.exe") + if (!httpdExe.exists()) { + throw new GradleException("httpd.exe not found at ${httpdExe}") + } + + println "Source folder: ${bundleSrcFinal}" + println "" + + // Prepare output directory + def apachePrepPath = file("${bundleTmpPrepPath}/${bundleName}${bundleVersion}") + if (apachePrepPath.exists()) { + delete apachePrepPath + } + apachePrepPath.mkdirs() + + // Copy readme if exists + def readmeFile = file("${bundleSrcDest}/readme_first.html") + if (readmeFile.exists()) { + copy { + from readmeFile + into apachePrepPath + } + } + + // Copy Apache files (excluding certain directories) + println "Copying Apache files..." + copy { + from bundleSrcFinal + into apachePrepPath + exclude 'cgi-bin/**' + exclude 'conf/original/**' + exclude 'conf/ssl/**' + exclude 'error/**' + exclude 'htdocs/**' + exclude 'icons/**' + exclude 'include/**' + exclude 'lib/**' + exclude 'logs/*' + exclude 'tools/**' + } + + // Copy bundle customizations + println "Copying bundle customizations..." + copy { + from bundlePath + into apachePrepPath + exclude 'Apache24/**' + exclude 'Apache2.4/**' + exclude 'readme_first.html' + } + + // Process modules if modules.properties exists + def modulesFile = file("${apachePrepPath}/modules.properties") + if (modulesFile.exists()) { + println "" + println "Processing modules..." + + def modules = new Properties() + modulesFile.withInputStream { modules.load(it) } + + def modulesContent = new StringBuilder() + + modules.each { moduleName, moduleUrl -> + println " Processing module: ${moduleName}" + + // Extract version from URL (if present) + def versionMatch = (moduleUrl =~ /apache-.*-.*-(.*)/) + def moduleVersion = versionMatch ? versionMatch[0][1] : 'unknown' + + println " URL: ${moduleUrl}" + println " Version: ${moduleVersion}" + + // Add to modules content for httpd.conf injection + modulesContent.append("#LoadModule ${moduleName}_module modules/mod_${moduleName}.so\n") + } + + // Inject modules into httpd.conf + def httpdConf = file("${bundlePath}/conf/httpd.conf") + def httpdConfBer = file("${bundlePath}/conf/httpd.conf.ber") + + if (httpdConf.exists()) { + println "" + println "Injecting modules into httpd.conf..." + def confContent = httpdConf.text.replace('@APACHE_MODULES@', modulesContent.toString()) + file("${apachePrepPath}/conf/httpd.conf").text = confContent + } + + if (httpdConfBer.exists()) { + println "Injecting modules into httpd.conf.ber..." + def confContent = httpdConfBer.text.replace('@APACHE_MODULES@', modulesContent.toString()) + file("${apachePrepPath}/conf/httpd.conf.ber").text = confContent + } + + // Remove modules.properties from output + modulesFile.delete() + } + + println "" + println "[SUCCESS] ${bundleName} ${version} completed" + println "Output: ${apachePrepPath}" + 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: Verify build environment +tasks.register('verify') { + group = 'verification' + description = 'Verify build environment and dependencies' + + doLast { + println "Verifying build environment for module-apache..." + + 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 dev directory + checks['dev directory'] = file(devPath).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=2.4.62 - 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 apache.properties +tasks.register('listReleases') { + group = 'help' + description = 'List all available releases from modules-untouched apache.properties' + + doLast { + def props = fetchModulesUntouchedProperties() + if (!props) { + println "\n[WARNING] Could not fetch modules-untouched apache.properties." + println "No release information available." + return + } + + println "\nAvailable Apache Releases (modules-untouched):" + 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/apache.properties" + println "Repository URL:" + println " ${propsUrl}" + println "" + + println "Fetching apache.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 apache.properties (remote)" + println " 2. Check GitHub repository for direct archive files (fallback)" + println "" + println "Documentation: /.gradle-docs/MODULES_UNTOUCHED_INTEGRATION.md" + + } else { + println "" + println "=".multiply(70) + println "[WARNING] Could not fetch apache.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. Direct GitHub repository archive detection" + } + } +} + +// Task: Check Apache modules configuration +tasks.register('checkModules') { + group = 'verification' + description = 'Check Apache modules configuration in bin directories' + + doLast { + def binDir = file("${projectDir}/bin") + if (!binDir.exists()) { + println "bin/ directory not found" + return + } + + println "\nChecking Apache modules configuration..." + println "-".multiply(80) + + def versions = binDir.listFiles() + ?.findAll { it.isDirectory() && it.name.startsWith(bundleName) } + ?.sort { it.name } ?: [] + + versions.each { versionDir -> + def modulesFile = new File(versionDir, 'modules.properties') + if (modulesFile.exists()) { + def modules = new Properties() + modulesFile.withInputStream { modules.load(it) } + println "\n${versionDir.name}:" + println " Modules file: Found (${modules.size()} modules)" + modules.each { name, url -> + println " - ${name}" + } + } else { + println "\n${versionDir.name}:" + println " Modules file: Not found" + } + } + println "-".multiply(80) + } +} + +// ============================================================================ +// BUILD LIFECYCLE HOOKS +// ============================================================================ + +gradle.taskGraph.whenReady { graph -> + println """ + ================================================================ + Bearsampp Module Apache - Gradle Build + ================================================================ + """.stripIndent() +} + +// ============================================================================ +// DEFAULT TASK +// ============================================================================ + +defaultTasks 'info' diff --git a/build.xml b/build.xml deleted file mode 100644 index 946a9c5b..00000000 --- a/build.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/current-repos.md b/current-repos.md deleted file mode 100644 index afbcd778..00000000 --- a/current-repos.md +++ /dev/null @@ -1,34 +0,0 @@ - -Bearsampp/aetraymenu -Bearsampp/Bearsampp -Bearsampp/dev -Bearsampp/login-servers-enhanced -Bearsampp/module-adminer -Bearsampp/module-apache -Bearsampp/module-composer -Bearsampp/module-consolez -Bearsampp/module-filezilla -Bearsampp/module-ghostscript -Bearsampp/module-git -Bearsampp/module-gitlist -Bearsampp/module-mailhog -Bearsampp/module-mariadb -Bearsampp/module-memcached -Bearsampp/module-mysql -Bearsampp/module-ngrok -Bearsampp/module-nodejs -Bearsampp/module-perl -Bearsampp/module-php -Bearsampp/module-phpmemadmin -Bearsampp/module-phpmyadmin -Bearsampp/module-phppgadmin -Bearsampp/module-postgresql -Bearsampp/module-python -Bearsampp/module-ruby -Bearsampp/module-svn -Bearsampp/module-webgrind -Bearsampp/module-websvn -Bearsampp/module-xdc -Bearsampp/module-yarn -Bearsampp/modules-untouched -Bearsampp/prerequisites \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..8ddbe2af --- /dev/null +++ b/gradle.properties @@ -0,0 +1,19 @@ +# Gradle Build Properties for Bearsampp Module Apache + +# 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-apache.RELEASE.launch b/module-apache.RELEASE.launch deleted file mode 100644 index c96fcb42..00000000 --- a/module-apache.RELEASE.launch +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..a00379d7 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,25 @@ +/* + * Bearsampp Module Apache - Gradle Settings + */ + +rootProject.name = 'module-apache' + +// 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 Apache Build + ================================================================ + """.stripIndent() +}