Complete API reference for the Bearsampp Module Ghostscript Gradle build system.
Type: String
Default: com.bearsampp.modules
Description: Maven group ID for the project
group = 'com.bearsampp.modules'Type: String
Default: Value from build.properties
Description: Project version
version = buildProps.getProperty('bundle.release', '1.0.0')Type: String
Default: Generated from bundle name
Description: Project description
description = "Bearsampp Module - ${buildProps.getProperty('bundle.name', 'ghostscript')}"Type: String
Description: Absolute path to project directory
ext.projectBasedir = projectDir.absolutePathType: String
Description: Absolute path to parent directory
ext.rootDir = projectDir.parentType: String
Description: Absolute path to dev directory
ext.devPath = file("${rootDir}/dev").absolutePathType: String
Default: ghostscript
Description: Name of the bundle from build.properties
ext.bundleName = buildProps.getProperty('bundle.name', 'ghostscript')Type: String
Default: 1.0.0
Description: Release version from build.properties
ext.bundleRelease = buildProps.getProperty('bundle.release', '1.0.0')Type: String
Default: tools
Description: Bundle type from build.properties
ext.bundleType = buildProps.getProperty('bundle.type', 'tools')Type: String
Default: 7z
Description: Archive format from build.properties
ext.bundleFormat = buildProps.getProperty('bundle.format', '7z')Type: String
Description: Base path for build output (configurable via build.properties, environment variable, or default)
def buildPathFromProps = buildProps.getProperty('build.path', '').trim()
def buildPathFromEnv = System.getenv('BEARSAMPP_BUILD_PATH') ?: ''
def defaultBuildPath = "${rootDir}/bearsampp-build"
ext.buildBasePath = buildPathFromProps ?: (buildPathFromEnv ?: defaultBuildPath)Type: String
Description: Absolute path to temporary build directory
ext.buildTmpPath = file("${buildBasePath}/tmp").absolutePathType: String
Description: Absolute path to bundle build directory
ext.bundleTmpBuildPath = file("${buildTmpPath}/bundles_build/${bundleType}/${bundleName}").absolutePathType: String
Description: Absolute path to bundle preparation directory
ext.bundleTmpPrepPath = file("${buildTmpPath}/bundles_prep/${bundleType}/${bundleName}").absolutePathType: String
Description: Absolute path to download cache directory
ext.bundleTmpDownloadPath = file("${buildTmpPath}/downloads/${bundleName}").absolutePathType: String
Description: Absolute path to extraction directory
ext.bundleTmpExtractPath = file("${buildTmpPath}/extract/${bundleName}").absolutePathDescription: Fetch ghostscript.properties from modules-untouched repository
Parameters: None
Returns: Properties - Properties object or null if fetch fails
Example:
def props = fetchModulesUntouchedProperties()
if (props) {
def url = props.getProperty('10.05.1')
}Process:
- Construct URL to modules-untouched properties file
- Download properties file
- Parse and return Properties object
- Return null on failure
Description: Get Ghostscript module from modules-untouched repository (local or remote)
Parameters:
| Parameter | Type | Description |
|---|---|---|
name |
String | Module name (ghostscript) |
version |
String | Version to retrieve |
Returns: File - Directory containing Ghostscript files or null
Example:
def ghostscriptDir = getModuleUntouched('ghostscript', '10.05.1')
if (ghostscriptDir) {
println "Found at: ${ghostscriptDir}"
}Process:
- Check local modules-untouched repository
- If not found, check remote properties file
- Download and extract if found remotely
- Return directory or null
Description: Get download URL from modules-untouched remote properties file
Parameters:
| Parameter | Type | Description |
|---|---|---|
name |
String | Module name (ghostscript) |
version |
String | Version to retrieve |
Returns: String - Download URL or null
Example:
def url = getModuleUntouchedRemoteUrl('ghostscript', '10.05.1')
if (url) {
println "Download URL: ${url}"
}Description: Download and extract Ghostscript from URL
Parameters:
| Parameter | Type | Description |
|---|---|---|
downloadUrl |
String | URL to download from |
version |
String | Version being downloaded |
name |
String | Module name |
Returns: File - Directory containing extracted files
Example:
def ghostscriptDir = downloadAndExtractFromUrl(
'https://example.com/gs10.05.1.7z',
'10.05.1',
'ghostscript'
)Process:
- Download archive from URL
- Extract to temporary directory
- Find Ghostscript directory in extracted files
- Return directory
Description: Download and extract Ghostscript binaries (with fallback logic)
Parameters:
| Parameter | Type | Description |
|---|---|---|
version |
String | Ghostscript version |
destDir |
File | Destination directory |
Returns: File - Directory containing Ghostscript files
Example:
def ghostscriptDir = downloadAndExtractGhostscript('10.05.1', file(bundleTmpExtractPath))Process:
- Try modules-untouched repository (local)
- Try modules-untouched repository (remote)
- Try releases.properties
- Download and extract
- Return directory
Description: Find Ghostscript directory in extracted files
Parameters:
| Parameter | Type | Description |
|---|---|---|
extractPath |
File | Directory to search |
Returns: File - Ghostscript directory or null
Example:
def ghostscriptDir = findGhostscriptDirectory(file("${bundleTmpExtractPath}/10.05.1"))Process:
- Check if extractPath itself contains gswin64c.exe or gswin32c.exe
- Search top-level directories
- Search one level deep
- Return directory or null
Description: Find 7-Zip executable on system
Parameters: None
Returns: String - Path to 7z.exe or null
Example:
def sevenZipPath = find7ZipExecutable()
if (sevenZipPath) {
println "7-Zip found at: ${sevenZipPath}"
}Process:
- Check 7Z_HOME environment variable
- Check common installation paths
- Check PATH environment variable
- Return path or null
Description: Generate hash files (MD5, SHA1, SHA256, SHA512) for archive
Parameters:
| Parameter | Type | Description |
|---|---|---|
file |
File | File to generate hashes for |
Returns: void
Example:
generateHashFiles(file('bearsampp-ghostscript-10.05.1-2025.7.31.7z'))Process:
- Calculate MD5 hash
- Calculate SHA1 hash
- Calculate SHA256 hash
- Calculate SHA512 hash
- Write each hash to separate file
Description: Calculate hash for file using specified algorithm
Parameters:
| Parameter | Type | Description |
|---|---|---|
file |
File | File to hash |
algorithm |
String | Hash algorithm (MD5, SHA-1, SHA-256, SHA-512) |
Returns: String - Hex-encoded hash
Example:
def md5 = calculateHash(file('archive.7z'), 'MD5')
def sha256 = calculateHash(file('archive.7z'), 'SHA-256')Description: Get list of available Ghostscript versions from bin/ and bin/archived/
Parameters: None
Returns: List<String> - List of version strings
Example:
def versions = getAvailableVersions()
versions.each { version ->
println "Version: ${version}"
}Process:
- Scan bin/ directory
- Scan bin/archived/ directory
- Remove duplicates
- Sort versions
- Return list
Register custom tasks using Gradle's task API:
tasks.register('customTask') {
group = 'custom'
description = 'Custom task description'
doLast {
// Task implementation
}
}Add custom validation tasks:
tasks.register('customValidation') {
group = 'verification'
description = 'Custom validation'
doLast {
// Validation logic
}
}Override download behavior by modifying releases.properties or implementing custom download logic:
def customDownloadGhostscript(String version) {
// Custom download implementation
}Access via project.findProperty():
def bundleVersion = project.findProperty('bundleVersion')Access via loaded Properties object:
def buildProps = new Properties()
file('build.properties').withInputStream { buildProps.load(it) }
def bundleName = buildProps.getProperty('bundle.name')
def bundleRelease = buildProps.getProperty('bundle.release')Access via System.getProperty():
def javaHome = System.getProperty('java.home')
def javaVersion = System.getProperty('java.version')Access via System.getenv():
def buildPath = System.getenv('BEARSAMPP_BUILD_PATH')
def sevenZipHome = System.getenv('7Z_HOME')tasks.register('taskName') {
group = 'groupName'
description = 'Task description'
doFirst {
// Executed first
}
doLast {
// Executed last
}
}tasks.register('taskB') {
dependsOn 'taskA'
doLast {
// Executed after taskA
}
}tasks.named('existingTask') {
// Configure existing task
doLast {
// Add additional action
}
}// Create file object
def file = file('path/to/file')
// Check existence
if (file.exists()) { }
// Create directory
file.mkdirs()
// Delete file/directory
delete file
// Copy files
copy {
from 'source'
into 'destination'
include '*.exe'
exclude 'doc/**'
}// Extract ZIP
copy {
from zipTree('archive.zip')
into 'destination'
}
// Create 7z archive
def command = [
sevenZipExe,
'a',
'-t7z',
archiveFile.absolutePath,
'.'
]
def process = new ProcessBuilder(command)
.directory(sourceDir)
.redirectErrorStream(true)
.start()def process = new ProcessBuilder(['command', 'arg1', 'arg2'])
.directory(workingDir)
.redirectErrorStream(true)
.start()
process.inputStream.eachLine { line ->
println line
}
def exitCode = process.waitFor()def command = ['powershell', '-Command', 'Get-Date']
def process = new ProcessBuilder(command)
.redirectErrorStream(true)
.start()
def output = process.inputStream.textlogger.error('Error message')
logger.warn('Warning message')
logger.lifecycle('Lifecycle message')
logger.quiet('Quiet message')
logger.info('Info message')
logger.debug('Debug message')throw new GradleException('Error message')tasks.register('downloadGhostscript') {
group = 'download'
description = 'Download Ghostscript version'
doLast {
def version = project.findProperty('gsVersion')
if (!version) {
throw new GradleException('gsVersion property required')
}
def ghostscriptDir = downloadAndExtractGhostscript(
version,
file(bundleTmpExtractPath)
)
println "Downloaded to: ${ghostscriptDir}"
}
}tasks.register('validateGhostscript') {
group = 'verification'
description = 'Validate Ghostscript installation'
doLast {
def versions = getAvailableVersions()
versions.each { version ->
def binDir = file("bin/ghostscript${version}")
if (!binDir.exists()) {
binDir = file("bin/archived/ghostscript${version}")
}
def gsExe64 = file("${binDir}/bin/gswin64c.exe")
def gsExe32 = file("${binDir}/bin/gswin32c.exe")
if (!gsExe64.exists() && !gsExe32.exists()) {
throw new GradleException("No Ghostscript executable found for version ${version}")
}
println "[PASS] ${version}"
}
println '[SUCCESS] All versions validated'
}
}tasks.register('ghostscriptInfo') {
group = 'help'
description = 'Display Ghostscript version information'
doLast {
def versions = getAvailableVersions()
println 'Ghostscript Versions:'
println '-'.multiply(60)
versions.each { version ->
def binDir = file("bin/ghostscript${version}")
def location = 'bin'
if (!binDir.exists()) {
binDir = file("bin/archived/ghostscript${version}")
location = 'bin/archived'
}
def gsExe64 = file("${binDir}/bin/gswin64c.exe")
def gsExe32 = file("${binDir}/bin/gswin32c.exe")
def arch = gsExe64.exists() ? '64-bit' : '32-bit'
def size = (gsExe64.exists() ? gsExe64.length() : gsExe32.length()) / 1024 / 1024
println " ${version.padRight(15)} [${location}] ${arch} ${String.format('%.2f', size)} MB"
}
println '-'.multiply(60)
println "Total versions: ${versions.size()}"
}
}Last Updated: 2025-01-31
Version: 2025.7.31