Menu

Distribution and Deployment

Relevant source files

This page covers the packaging, distribution, and deployment mechanisms for OwnLang applications and the language runtime itself. The system provides multiple deployment options including standalone JAR distributions, cross-platform launcher scripts, Docker containerization, and code optimization through ProGuard.

For information about the build system that creates these distribution artifacts, see Gradle Build System. For details on the modular project structure that supports this distribution model, see Multi-Project Structure.

Distribution Pipeline

The OwnLang distribution system transforms source code through a multi-stage pipeline to create deployable artifacts:

Sources: Dockerfile1-26 proguard.properties1-49 dist/ownlang1-38 dist/ownlang.cmd1-6

JAR Packaging and Shadow Plugin

The distribution system uses the Gradle Shadow plugin to create self-contained executable JARs. The main application is packaged as OwnLang.jar containing all core dependencies, while extension modules are packaged as separate JAR files.

Shadow JAR Configuration

The Shadow plugin creates fat JARs by bundling all runtime dependencies into a single executable file. This eliminates the need for complex classpath management during deployment:

ComponentJAR OutputContents
Core RuntimeOwnLang.jarcom.annimon.ownlang.Main, parser, lexer, core libraries
JDBC Modulemodules/jdbc-*.jarDatabase connectivity, JDBC drivers
Server Modulemodules/server-*.jarJavalin web server, HTTP handling
Socket Modulemodules/socket-*.jarSocket.io client, real-time communication

The main entry point com.annimon.ownlang.Main is specified in the JAR manifest, allowing direct execution via java -jar OwnLang.jar.

Sources: Dockerfile17-20 dist/ownlang17 dist/ownlang.cmd4-5

Cross-Platform Launcher Scripts

The distribution includes platform-specific launcher scripts that handle classpath construction and JVM invocation:

Unix/Linux Launcher

The ownlang script provides POSIX-compliant execution with Cygwin compatibility:

Key implementation details from dist/ownlang4-38:

  • Symlink Resolution: Lines 4-15 resolve the actual script location through symlink chains
  • Classpath Construction: Lines 17-36 build the full classpath including main JAR, modules, and libraries
  • Cygwin Support: Lines 18-26 convert Unix paths to Windows format when running under Cygwin

Windows Launcher

The ownlang.cmd batch script provides simplified execution for Windows environments:

  • Direct Classpath: Uses Windows path separators (;) and wildcard expansion
  • Parameter Forwarding: Passes all command-line arguments via %*
  • JAR Discovery: Automatically includes all JAR files in modules/ and libs/ directories

Sources: dist/ownlang1-38 dist/ownlang.cmd1-6 dist/own1-2 dist/own.cmd1-2

Docker Containerization

The Docker deployment uses a multi-stage build process optimized for layer caching and minimal image size:

Docker Build Stages

The Dockerfile1-26 implements a three-stage build:

  1. Cache Stage (Lines 1-6): Prepares Gradle dependencies for layer caching
  2. Builder Stage (Lines 8-12): Executes the full build with shadowJar task
  3. Runtime Stage (Lines 14-25): Creates minimal runtime image with JRE and artifacts

Container Structure

The final container includes:

  • Runtime Path: /opt/ownlang working directory with PATH configuration
  • Main JAR: libs/OwnLang.jar (copied from desktop build output)
  • Module JARs: modules/ directory with extension modules
  • Executable Scripts: own and ownlang with execute permissions

Sources: Dockerfile1-26

ProGuard Optimization

The ProGuard configuration provides code optimization and obfuscation for production distributions:

Optimization Rules

The proguard.properties1-49 configuration includes:

Rule CategoryPurposeConfiguration Lines
Keep RulesPreserve public APIs and entry points13-15, 37, 40-42
Warning SuppressionHandle third-party library warnings8-11
Attribute PreservationMaintain reflection compatibility5-6, 21-22
Module InterfacePreserve module loading mechanism37

Critical Keep Rules

  • Main Entry Point: keepclasseswithmembers public class * { public static void main(...); }
  • Module Interface: keep public class * implements com.annimon.ownlang.modules.Module
  • Third-party Libraries: Specific rules for OkHttp, Swing UI components

Obfuscation Modes

The configuration supports both soft and hard obfuscation:

  • Soft Mode (Active): Preserves public/protected members for debugging
  • Hard Mode (Commented): Aggressive optimization with repackaging and access modification

Sources: proguard.properties1-49

Package Manager Distribution

The OwnLang package manager (own command) is distributed alongside the main runtime:

Package Manager Structure

The package manager leverages the same distribution mechanism as the main runtime:

  • Unified Runtime: Uses the same OwnLang.jar and module system
  • Script-based Implementation: Package manager logic written in OwnLang itself
  • Cross-platform Launchers: Separate own and own.cmd scripts for platform compatibility

Sources: dist/own1-2 dist/own.cmd1-2 ownlang-desktop/src/main/resources/scripts/listscripts.own1-7

Runtime Environment Structure

The deployed OwnLang runtime follows a standardized directory structure:

Directory/FilePurposeContents
OwnLang.jarMain executableCore runtime, parser, standard library
modules/Extension modulesJDBC, server, socket, and other optional modules
libs/External dependenciesThird-party libraries (when not using Shadow JAR)
ownlang / ownlang.cmdMain launcherCross-platform execution scripts
own / own.cmdPackage managerPackage management and project tools

This structure supports both standalone distributions and containerized deployments while maintaining consistent module loading and classpath management across platforms.

Sources: dist/ownlang17-36 dist/ownlang.cmd4-5 Dockerfile15-24