{
  "format": "code-as-usual.installation-package-template",
  "formatVersion": 2,
  "templateName": "Apache Tomcat archive",
  "templateDescription": "Creates a verified Apache Tomcat package. The template supplies Tomcat's archive layout and generic runtime contract. Code as Usual chooses the installation location; the administrator supplies only release-specific values.",
  "parameters": [
    {
      "key": "version",
      "label": "Tomcat version",
      "help": "Enter the complete Apache Tomcat release version. It must match both the archive name and the directory at the root of the archive.",
      "inputType": "version",
      "required": true,
      "defaultValue": "",
      "example": "11.0.14"
    },
    {
      "key": "downloadUrl",
      "label": "Official archive URL",
      "help": "Paste the direct HTTPS URL of the versioned tar.gz archive from an Apache download or archive host. Do not enter a web page, a latest-version redirect or a checksum URL.",
      "inputType": "url",
      "required": true,
      "defaultValue": "",
      "example": "https://archive.apache.org/dist/tomcat/tomcat-11/v11.0.14/bin/apache-tomcat-11.0.14.tar.gz"
    },
    {
      "key": "sha512",
      "label": "Published SHA-512 checksum",
      "help": "Copy the complete SHA-512 value published for exactly the archive URL above. Code as Usual verifies it before extracting any file.",
      "inputType": "checksum",
      "required": true,
      "defaultValue": "",
      "example": "128 hexadecimal characters"
    }
  ],
  "definition": {
    "packageKey": "apache.tomcat",
    "versionLabel": "${version}",
    "name": "Apache Tomcat",
    "description": "Servlet container distributed as a checksum-verified Apache archive.",
    "installationMethod": "ARCHIVE",
    "operatingSystemPackages": [],
    "sourceUrl": "${downloadUrl}",
    "checksumAlgorithm": "SHA512",
    "checksum": "${sha512}",
    "archiveFormat": "TAR_GZIP",
    "extractionDirectory": "",
    "executableLinks": [
      {
        "sourcePath": "apache-tomcat-{version}/bin/catalina.sh",
        "targetPath": "/usr/local/bin/catalina"
      }
    ],
    "environment": [
      {
        "name": "CATALINA_HOME",
        "value": "{installPath}/apache-tomcat-{version}"
      }
    ],
    "validationCommand": [
      "/usr/bin/test",
      "-x",
      "/usr/local/bin/catalina"
    ],
    "usageGuide": "## Runtime layout\n\n`CATALINA_HOME` points to the read-only package installation at `{installPath}/apache-tomcat-{version}`. Do not write applications, configuration, logs, temporary files or generated state into that directory. The Java package selected for the project supplies `JAVA_HOME`.\n\nCreate a writable, project-local `CATALINA_BASE`, normally below the project directory in `/workspace`. On first use, copy the default configuration without replacing later project changes:\n\n```sh\nexport CATALINA_BASE=\"$PWD/.runtime/tomcat\"\nmkdir -p \"$CATALINA_BASE\"\nif [ ! -f \"$CATALINA_BASE/conf/server.xml\" ]; then\n  cp -a \"$CATALINA_HOME/conf\" \"$CATALINA_BASE/conf\"\nfi\nmkdir -p \"$CATALINA_BASE/bin\" \"$CATALINA_BASE/lib\" \"$CATALINA_BASE/logs\" \"$CATALINA_BASE/temp\" \"$CATALINA_BASE/webapps\" \"$CATALINA_BASE/work\"\n```\n\nBuild the web application with the project's own build tool and copy its WAR to `$CATALINA_BASE/webapps`. For a root application, use `ROOT.war`. Start and stop it with `/usr/local/bin/catalina start` and `/usr/local/bin/catalina stop`. Tomcat's default HTTP port is 8080; use the environment preview for port 8080 unless the project deliberately changes `conf/server.xml`.\n\nKeep reusable build, deploy, start and stop commands in project-owned scripts so people and AI agents run the same workflow. Check `$CATALINA_BASE/logs` when startup or preview fails.",
    "capabilities": [
      {
        "key": "java.servlet-container",
        "version": "${version}"
      }
    ],
    "requirements": [
      {
        "key": "java",
        "versionConstraint": ">=17"
      }
    ],
    "networkDestinations": []
  }
}
